Fix socket protect in simple-obfs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user