bypass dns queries for popular sites in china

This commit is contained in:
Max Lv
2014-03-07 13:07:44 +08:00
parent 5052b74893
commit 1beb175957
4 changed files with 32 additions and 11 deletions
@@ -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")
val conf = ConfigUtils.PDNSD.format("0.0.0.0", getString(R.string.exclude))
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf)
})
@@ -113,9 +113,12 @@ class ShadowsocksVpnService extends VpnService with BaseService {
version
}
def startVpn() {
def isByass(info: SubnetUtils.SubnetInfo): Boolean = {
info.isInRange(config.proxy) || info.isInRange("114.114.114.114")
|| info.isInRange("114.114.115.115")
}
val proxy_address = config.proxy
def startVpn() {
val builder = new Builder()
builder
@@ -136,7 +139,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
gfwList.foreach(cidr => {
val net = new SubnetUtils(cidr).getInfo
if (!net.isInRange(proxy_address)) {
if (!isByass(net)) {
val addr = cidr.split('/')
builder.addRoute(addr(0), addr(1).toInt)
}
@@ -148,7 +151,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val cidr = addr + "/8"
val net = new SubnetUtils(cidr).getInfo
if (!net.isInRange(proxy_address)) {
if (!isByass(net)) {
if (!InetAddress.getByName(addr).isSiteLocalAddress) {
builder.addRoute(addr, 8)
}
@@ -157,7 +160,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 (!subNet.isInRange(proxy_address)) {
if (!isByass(subNet)) {
if (!InetAddress.getByName(subAddr).isSiteLocalAddress) {
builder.addRoute(subAddr, 16)
}