bypass system dns addr

This commit is contained in:
Max Lv
2014-03-07 13:47:44 +08:00
parent 056bd56d90
commit 1c4c54e962
5 changed files with 14 additions and 4 deletions
@@ -45,4 +45,5 @@ public class System {
public static native void exec(String cmd);
public static native String getABI();
public static native String getDNS1();
}
+10 -1
View File
@@ -6,11 +6,18 @@
#include <stdlib.h>
#include <unistd.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 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)
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) {
AndroidCpuFamily family = android_getCpuFamily();
uint64_t features = android_getCpuFeatures();
@@ -45,7 +52,9 @@ static JNINativeMethod method_table[] = {
{ "exec", "(Ljava/lang/String;)V",
(void*) Java_com_github_shadowsocks_system_exec },
{ "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 {
Path.BASE + "ss-local.pid")
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod)
} 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 => {
p.println(conf)
})
@@ -91,7 +91,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
Path.BASE + "ss-tunnel.pid")
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod)
} 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 => {
p.println(conf)
})
@@ -86,7 +86,7 @@ object ConfigUtils {
|
|server {
| label = "china-servers";
| ip = 114.114.114.114, 114.114.115.115;
| ip = %s, 114.114.114.114, 114.114.115.115;
| timeout = 5;
|}
|