Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加一种判断方案 #36

Closed
fonlan opened this issue Oct 11, 2018 · 8 comments
Closed

增加一种判断方案 #36

fonlan opened this issue Oct 11, 2018 · 8 comments

Comments

@fonlan
Copy link

fonlan commented Oct 11, 2018

导入国内三大运营商的IP地址列表,配置文件里可以自定义运营商,比如电信,则返回查询到的IP地址里属于电信的那个结果,无需查询实际延迟,若有多个电信的IP或者无电信IP则按现有方案测速后返回,若为内网地址也测速后返回。
本地判断应该比实际测速要快吧?

@pymumu
Copy link
Owner

pymumu commented Oct 12, 2018

IP地址列表体积会不小的,占用空间会很多,对于CGN网络下,IP地址列表可能无效,没有判断的途径。

这样做的原因是什么?检测耗时,耗CPU?

@fonlan
Copy link
Author

fonlan commented Oct 12, 2018

IP地址列表也可以在程序安装的时候或者运行的时候动态下载。只是觉得本地判断下总应该比实际测速要来得快,SmartDNS的目的不就是为了极致的速度么。这功能可以在配置文件里加开关的,由用户自己决定是否开启。CGN网络如果不适用就在配置文件里禁用就好了。

@pymumu
Copy link
Owner

pymumu commented Oct 12, 2018

我想了一下,对于你说的这个方案,没有特别好的办法。
IP地址库不容易处理,并且后面IPV6的话,基本就不可行了。即使下载也会占用很大的存储空间。
还有,现在大部分用户其实都是CGN网络了,如果大部分用户都不用这功能的话,价值就不是很大了。

所以,目前暂不考虑你的这个建议。

如果是为了DNS解析速度的话,可以强制将TTL调大,这样smartdns就会一直缓存。查询的时候,直接内存返回结果了。

@fonlan
Copy link
Author

fonlan commented Oct 13, 2018

好吧,我也只是个脑洞给个建议,不好使就算了吧

@cjameslynn
Copy link

#!/bin/sh
#借用koolshare的国内IP库
curl 'https://raw.githubusercontent.com/koolshare/ledesoft/master/policy/policy/policy/telecom.txt' |grep -v "routes" > /etc/routeIP/telecom.txt
curl 'https://raw.githubusercontent.com/koolshare/ledesoft/master/policy/policy/policy/unicom.txt' |grep -v "routes" > /etc/routeIP/unicom.txt
curl 'https://raw.githubusercontent.com/koolshare/ledesoft/master/policy/policy/policy/mobile.txt' |grep -v "routes" > /etc/routeIP/mobile.txt
curl 'https://raw.githubusercontent.com/koolshare/ledesoft/master/policy/policy/policy/chnroute.txt' |grep -v "routes" > /etc/routeIP/chnroute.txt
#以下分别把下载好的运营商IP集写入到ipset,对应ipset名称为 chnroute/telecom/mobile和unicom,可自行修改
##电信IP
ROUTES=/etc/routeIP/telecom.txt
ipset flush telecom
ipset -N telecom nethash
for network in cat $ROUTES; do
ipset -A telecom $network
done

##移动IP
ROUTES=/etc/routeIP/mobile.txt
ipset flush mobile
ipset -N mobile nethash
for network in cat $ROUTES; do
ipset -A mobile $network
done

##联通IP
ROUTES=/etc/routeIP/unicom.txt
ipset flush unicom
ipset -N unicom nethash
for network in cat $ROUTES; do
ipset -A unicom $network
done

##国内IP
ROUTES=/etc/routeIP/chnroute.txt
ipset flush chnroute
ipset -N chnroute nethash
for network in cat $ROUTES; do
ipset -A chnroute $network
done

@cjameslynn
Copy link

得到的ipset可以用到负载均衡插件的规则里

@pymumu
Copy link
Owner

pymumu commented Jan 7, 2019

@fonlan
Release 18优化了响应时间,在测速的情况下也能保证响应时效。
可以获取验证。

Release 18也新增了ipset的支持,有需要可以使用。

@pymumu pymumu closed this as completed Jan 7, 2019
@fonlan
Copy link
Author

fonlan commented Jan 8, 2019

好的,已更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants