Commit f43362fb authored by Max Lv's avatar Max Lv

Fix overture with NAT mode

parent 4f0e527d
...@@ -123,7 +123,7 @@ trait BaseService extends Service { ...@@ -123,7 +123,7 @@ trait BaseService extends Service {
false false
} else true } else true
def getExternalIp() { def getExternalIp(): String = {
val url = "http://icanhazip.com" val url = "http://icanhazip.com"
val client = new OkHttpClient.Builder() val client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS) .connectTimeout(10, TimeUnit.SECONDS)
...@@ -133,7 +133,11 @@ trait BaseService extends Service { ...@@ -133,7 +133,11 @@ trait BaseService extends Service {
val request = new Request.Builder() val request = new Request.Builder()
.url(url) .url(url)
.build() .build()
client.newCall(request).execute().body.string val response = client.newCall(request).execute()
if (response.isSuccessful)
response.body.string.trim
else
""
} }
def connect() { def connect() {
......
...@@ -89,9 +89,9 @@ class ShadowsocksNatService extends BaseService { ...@@ -89,9 +89,9 @@ class ShadowsocksNatService extends BaseService {
ConfigUtils.OVERTURE_DIRECT.formatLocal(Locale.ENGLISH, ConfigUtils.OVERTURE_DIRECT.formatLocal(Locale.ENGLISH,
profile.localPort + 53, // Local Port profile.localPort + 53, // Local Port
"119.29.29.29", // Primary DNS 1 "119.29.29.29", // Primary DNS 1
"tcp", // DNS type of Primary DNS 1 "udp", // DNS type of Primary DNS 1
"114.114.114.114", // Primary DNS 2 "114.114.114.114", // Primary DNS 2
"tcp", // DNS type of Primary DNS 2 "udp", // DNS type of Primary DNS 2
profile.remoteDns, // Alternative DNS profile.remoteDns, // Alternative DNS
"127.0.0.1:" + profile.localPort, // Local SOCKS5 Proxy "127.0.0.1:" + profile.localPort, // Local SOCKS5 Proxy
externalIp) // External IP externalIp) // External IP
......
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