Commit f2297f92 authored by Mygod's avatar Mygod

Ignore ENONET when bindSocket

parent ec3e86d1
...@@ -43,6 +43,7 @@ import java.io.File ...@@ -43,6 +43,7 @@ import java.io.File
import java.io.FileDescriptor import java.io.FileDescriptor
import java.io.IOException import java.io.IOException
import java.lang.reflect.Method import java.lang.reflect.Method
import java.net.SocketException
import java.util.* import java.util.*
import android.net.VpnService as BaseVpnService import android.net.VpnService as BaseVpnService
...@@ -83,7 +84,12 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface { ...@@ -83,7 +84,12 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
socket.outputStream.write(if (try { socket.outputStream.write(if (try {
val network = underlyingNetwork val network = underlyingNetwork
if (network != null && Build.VERSION.SDK_INT >= 23) { if (network != null && Build.VERSION.SDK_INT >= 23) {
try {
network.bindSocket(fd) network.bindSocket(fd)
} catch (e: SocketException) {
// silently ignore ENONET (Machine is not on the network)
if ((e.cause as? ErrnoException)?.errno == 64) e.printStackTrace() else throw e
}
true true
} else protect(getInt.invoke(fd) as Int) } else protect(getInt.invoke(fd) as Int)
} finally { } finally {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment