pass the tun fd directly to tun2socks

This commit is contained in:
Max Lv
2014-11-25 08:59:30 +08:00
parent 383e9404ec
commit 6c7f62c237
8 changed files with 12 additions and 371 deletions
@@ -123,7 +123,7 @@ object Shadowsocks {
val FEATRUE_PREFS = Array(Key.route, Key.isGlobalProxy, Key.proxyedApps,
Key.isUdpDns, Key.isAutoConnect)
val EXECUTABLES = Array(Executable.PDNSD, Executable.REDSOCKS, Executable.SS_TUNNEL, Executable.SS_LOCAL)
val EXECUTABLES = Array(Executable.PDNSD, Executable.REDSOCKS, Executable.SS_TUNNEL, Executable.SS_LOCAL, Executable.TUN2SOCKS)
// Helper functions
def updateListPreference(pref: Preference, value: String) {
@@ -322,25 +322,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
Tun2Socks.start(cmd.split(" "))
}
def startTunFdServer() {
spawn {
val fdServer = new LocalServerSocket("tun2socks")
try {
val localSocket = fdServer.accept()
localSocket.setFileDescriptorsForSend(Array(conn.getFileDescriptor))
val output = localSocket.getOutputStream
output.write(1)
output.flush()
output.close()
localSocket.close()
fdServer.close()
} catch {
case ex: Exception => Log.e(TAG, "Exception", ex) // Ignored
}
}
System.exec(cmd);
}
/** Called when the activity is first created. */