Skip to content

Commit

Permalink
Revert "bypass dns queries for popular sites in china"
Browse files Browse the repository at this point in the history
This reverts commit 1beb175.
  • Loading branch information
madeye committed Mar 7, 2014
1 parent 61df2c4 commit eb046e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 32 deletions.
4 changes: 0 additions & 4 deletions src/main/res/values/configs.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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")
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf)
})
Expand Down Expand Up @@ -302,17 +302,10 @@ class ShadowsocksNatService extends Service with BaseService {
val http_sb = new ArrayBuffer[String]
init_sb.append(Utils.getIptables + " -t nat -F OUTPUT")
val cmd_bypass = Utils.getIptables + CMD_IPTABLES_RETURN

// Bypass proxy servers
if (!InetAddressUtils.isIPv6Address(config.proxy.toUpperCase)) {
init_sb.append(cmd_bypass.replace("0.0.0.0", config.proxy))
init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-d " + config.proxy))
}

// Bypass DNS servers
init_sb.append(cmd_bypass.replace("0.0.0.0", "127.0.0.1"))
init_sb.append(cmd_bypass.replace("0.0.0.0", "114.114.114.114"))
init_sb.append(cmd_bypass.replace("0.0.0.0", "114.114.115.115"))

if (hasRedirectSupport) {
init_sb
.append(Utils.getIptables + " -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf)
})
Expand All @@ -113,13 +113,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
version
}

def isByass(info: SubnetUtils.SubnetInfo): Boolean = {
info.isInRange(config.proxy) || info.isInRange("114.114.114.114")
|| info.isInRange("114.114.115.115")
}

def startVpn() {

val proxy_address = config.proxy

val builder = new Builder()
builder
.setSession(config.profileName)
Expand All @@ -139,7 +136,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
gfwList.foreach(cidr => {
val net = new SubnetUtils(cidr).getInfo
if (!isByass(net)) {
if (!net.isInRange(proxy_address)) {
val addr = cidr.split('/')
builder.addRoute(addr(0), addr(1).toInt)
}
Expand All @@ -151,7 +148,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val cidr = addr + "/8"
val net = new SubnetUtils(cidr).getInfo

if (!isByass(net)) {
if (!net.isInRange(proxy_address)) {
if (!InetAddress.getByName(addr).isSiteLocalAddress) {
builder.addRoute(addr, 8)
}
Expand All @@ -160,7 +157,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val subAddr = i.toString + "." + j.toString + ".0.0"
val subCidr = subAddr + "/16"
val subNet = new SubnetUtils(subCidr).getInfo
if (!isByass(subNet)) {
if (!subNet.isInRange(proxy_address)) {
if (!InetAddress.getByName(subAddr).isSiteLocalAddress) {
builder.addRoute(subAddr, 16)
}
Expand Down
13 changes: 3 additions & 10 deletions src/main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,8 @@ object ConfigUtils {
|}
|
|server {
| label = "google-servers";
| ip = 8.8.8.8, 8.8.4.4;
| exclude = %s;
| timeout = 5;
|}
|
|server {
| label = "china-servers";
| ip = 114.114.114.114, 114.114.115.115;
| label = "root-servers";
| ip = 8.8.8.8, 8.8.4.4, 208.67.222.222, 208.67.220.220;
| timeout = 5;
|}
|
Expand Down Expand Up @@ -163,4 +156,4 @@ object ConfigUtils {
new Config(isGlobalProxy, isGFWList, isBypassApps, isTrafficStat, isUdpDns, profileName, proxy,
sitekey, encMethod, proxiedAppString, remotePort, localPort)
}
}
}

0 comments on commit eb046e4

Please sign in to comment.