diff --git a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala index 7b1ed966..941e27d4 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -313,7 +313,7 @@ trait BaseService extends Service { } } - protected def buildShadowsocksConfig(file: String, localPortOffset: Int = 0): String = { + protected def buildShadowsocksConfig(file: String, localPortOffset: Int = 0, vpn: Boolean = false): String = { val config = new JSONObject() config.put("server", profile.host) config.put("server_port", profile.remotePort) @@ -323,7 +323,13 @@ trait BaseService extends Service { if (profile.auth) config.put("auth", true) if (pluginPath != null) { config.put("plugin", pluginPath) - config.put("plugin_opts", plugin.toString) + val plugin_opts = if (vpn) { + "V;P=" + getApplicationInfo.dataDir + ";" + plugin.toString + } else { + plugin.toString + } + Log.d("shadowsocks", plugin_opts) + config.put("plugin_opts", plugin_opts) } IOUtils.writeString(file, config.toString) file diff --git a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala index a9b8550a..194c8b25 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala @@ -167,7 +167,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { , "-b", "127.0.0.1" , "-t", "600" , "-P", getApplicationInfo.dataDir - , "-c", buildShadowsocksConfig(getApplicationInfo.dataDir + "/ss-local-vpn.conf")) + , "-c", buildShadowsocksConfig(getApplicationInfo.dataDir + "/ss-local-vpn.conf", 0, true)) if (profile.udpdns) cmd += "-u" @@ -190,7 +190,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { , "-b", "127.0.0.1" , "-L" , if (profile.remoteDns == null) "8.8.8.8:53" else profile.remoteDns + ":53" , "-P", getApplicationInfo.dataDir - , "-c", buildShadowsocksConfig(getApplicationInfo.dataDir + "/ss-tunnel-vpn.conf", 53)) + , "-c", buildShadowsocksConfig(getApplicationInfo.dataDir + "/ss-tunnel-vpn.conf", 53, true)) if (BuildConfig.DEBUG) Log.d(TAG, Commandline.toString(cmd)) sstunnelProcess = new GuardedProcess(cmd).start() }