Commit 1c4c54e9 authored by Max Lv's avatar Max Lv

bypass system dns addr

parent 056bd56d
...@@ -45,4 +45,5 @@ public class System { ...@@ -45,4 +45,5 @@ public class System {
public static native void exec(String cmd); public static native void exec(String cmd);
public static native String getABI(); public static native String getABI();
public static native String getDNS1();
} }
...@@ -6,11 +6,18 @@ ...@@ -6,11 +6,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <cpu-features.h> #include <cpu-features.h>
#include <sys/system_properties.h>
#define LOGI(...) do { __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0) #define LOGI(...) do { __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGW(...) do { __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0) #define LOGW(...) do { __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGE(...) do { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0) #define LOGE(...) do { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
jstring Java_com_github_shadowsocks_system_getdns1(JNIEnv *env, jobject thiz) {
char dns1[PROP_VALUE_MAX];
__system_property_get("net.dns1", dns1);
return env->NewStringUTF(dns1);
}
jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) { jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) {
AndroidCpuFamily family = android_getCpuFamily(); AndroidCpuFamily family = android_getCpuFamily();
uint64_t features = android_getCpuFeatures(); uint64_t features = android_getCpuFeatures();
...@@ -45,7 +52,9 @@ static JNINativeMethod method_table[] = { ...@@ -45,7 +52,9 @@ static JNINativeMethod method_table[] = {
{ "exec", "(Ljava/lang/String;)V", { "exec", "(Ljava/lang/String;)V",
(void*) Java_com_github_shadowsocks_system_exec }, (void*) Java_com_github_shadowsocks_system_exec },
{ "getABI", "()Ljava/lang/String;", { "getABI", "()Ljava/lang/String;",
(void*) Java_com_github_shadowsocks_system_getabi } (void*) Java_com_github_shadowsocks_system_getabi },
{ "getDNS1", "()Ljava/lang/String;",
(void*) Java_com_github_shadowsocks_system_getdns1 }
}; };
/* /*
......
...@@ -118,7 +118,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -118,7 +118,7 @@ class ShadowsocksNatService extends Service with BaseService {
Path.BASE + "ss-local.pid") Path.BASE + "ss-local.pid")
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod) .format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod)
} else { } else {
val conf = ConfigUtils.PDNSD.format("127.0.0.1", getString(R.string.exclude)); val conf = ConfigUtils.PDNSD.format("127.0.0.1", getString(R.string.exclude), System.getDNS1);
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
}) })
......
...@@ -91,7 +91,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -91,7 +91,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
Path.BASE + "ss-tunnel.pid") Path.BASE + "ss-tunnel.pid")
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod) .format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod)
} else { } else {
val conf = ConfigUtils.PDNSD.format("0.0.0.0", getString(R.string.exclude)) val conf = ConfigUtils.PDNSD.format("0.0.0.0", getString(R.string.exclude), System.getDNS1)
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
}) })
......
...@@ -86,7 +86,7 @@ object ConfigUtils { ...@@ -86,7 +86,7 @@ object ConfigUtils {
| |
|server { |server {
| label = "china-servers"; | label = "china-servers";
| ip = 114.114.114.114, 114.114.115.115; | ip = %s, 114.114.114.114, 114.114.115.115;
| timeout = 5; | timeout = 5;
|} |}
| |
......
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