mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-13 22:11:03 +00:00
1. fixed unnecessary empty array condition
This commit is contained in:
parent
ae9f154dca
commit
a1c175e9a4
@ -124,6 +124,8 @@ class YggdrasilTunService : VpnService() {
|
|||||||
//System.out.println("packet size:"+packet.size+" "+byteArrayToHex(packet))
|
//System.out.println("packet size:"+packet.size+" "+byteArrayToHex(packet))
|
||||||
//System.out.println("buffer size:"+buffer.array().size+" "+byteArrayToHex(buffer.array()))
|
//System.out.println("buffer size:"+buffer.array().size+" "+byteArrayToHex(buffer.array()))
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
|
// Ignore control messages, which start with zero.
|
||||||
|
if (packet.get(0).compareTo(0)!=0) {
|
||||||
var buffer = ByteBuffer.allocate(length);
|
var buffer = ByteBuffer.allocate(length);
|
||||||
buffer.put(packet, 0, length)
|
buffer.put(packet, 0, length)
|
||||||
buffer.limit(length)
|
buffer.limit(length)
|
||||||
@ -131,6 +133,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun isBufferEmpty(buffer: ByteArray): Boolean {
|
private fun isBufferEmpty(buffer: ByteArray): Boolean {
|
||||||
var sum: Byte = 0
|
var sum: Byte = 0
|
||||||
@ -143,11 +146,9 @@ class YggdrasilTunService : VpnService() {
|
|||||||
private fun writePacketsToTun() {
|
private fun writePacketsToTun() {
|
||||||
if(tunOutputStream != null) {
|
if(tunOutputStream != null) {
|
||||||
val buffer = yggConduitEndpoint.recv()
|
val buffer = yggConduitEndpoint.recv()
|
||||||
if (!isBufferEmpty(buffer)) {
|
|
||||||
tunOutputStream!!.write(buffer)
|
tunOutputStream!!.write(buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRevoke() {
|
override fun onRevoke() {
|
||||||
super.onRevoke()
|
super.onRevoke()
|
||||||
|
Loading…
Reference in New Issue
Block a user