Unverified Commit 269b0486 authored by Mygod's avatar Mygod Committed by GitHub

Suppress EPERM for bind

parent 1fb529fb
...@@ -29,6 +29,7 @@ import android.net.Network ...@@ -29,6 +29,7 @@ import android.net.Network
import android.os.Build import android.os.Build
import android.os.ParcelFileDescriptor import android.os.ParcelFileDescriptor
import android.system.ErrnoException import android.system.ErrnoException
import android.system.OsConstants
import com.github.shadowsocks.Core import com.github.shadowsocks.Core
import com.github.shadowsocks.VpnRequestActivity import com.github.shadowsocks.VpnRequestActivity
import com.github.shadowsocks.acl.Acl import com.github.shadowsocks.acl.Acl
...@@ -72,8 +73,11 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface { ...@@ -72,8 +73,11 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
DnsResolverCompat.bindSocket(network, fd) DnsResolverCompat.bindSocket(network, fd)
return@let true return@let true
} catch (e: IOException) { } catch (e: IOException) {
// suppress ENONET (Machine is not on the network) when ((e.cause as? ErrnoException)?.errno) {
if ((e.cause as? ErrnoException)?.errno != 64) printLog(e) // also suppress ENONET (Machine is not on the network)
OsConstants.EPERM, 64 -> e.printStackTrace()
else -> printLog(e)
}
return@let false return@let false
} catch (e: ReflectiveOperationException) { } catch (e: ReflectiveOperationException) {
check(Build.VERSION.SDK_INT < 23) check(Build.VERSION.SDK_INT < 23)
......
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