Loyalsoldier / geoip

🌚 🌍 🌝 GeoIP 规则文件加强版,支持自行定制 V2Ray dat 格式文件 geoip.dat、MaxMind mmdb 格式文件、sing-box SRS 格式文件、mihomo MRS 格式文件、Clash ruleset、Surge ruleset 等。Enhanced edition of GeoIP files for V2Ray, Xray-core, sing-box, Clash, mihomo, Shadowrocket, Quantumult X, Surge, hysteria, Trojan-Go, Leaf, etc.
Creative Commons Attribution Share Alike 4.0 International
3.7k stars 629 forks source link

为什么自己添加 IP 源后生成会被自动修改或删除很多 IP 段? #137

Closed DustinWin closed 11 months ago

DustinWin commented 11 months ago

如我添加了 blackmatrix7/ios_rule_script/Clash/ChinaIPs 这个 IP 源(不管是通过 config.yaml 还是通过 build.yml),里面有 IP 段 18000 多条,而在生成 geoip.dat 或 Country.mmdb 后导入 Clash,发现只有 10000 条左右了 请问里面有什么筛选机制吗?如果有,能够去除这个筛选机制吗? 举个具体的例子: 我添加了一个 geoip:telegram 的 IP 源,为 https://core.telegram.org/resources/cidr.txt ,可以获知里面的 IP 段有 14 条,而生成 geoip.dat 或 Country.mmdb 后导入 Clash,发现只有 12 条了且部分 IP 段被修改。对比一下: 原 telegram IP 段:

91.105.192.0/23
91.108.4.0/22
91.108.8.0/22
91.108.12.0/22
91.108.16.0/22
91.108.20.0/22
91.108.56.0/22
149.154.160.0/20
185.76.151.0/24
2001:67c:4e8::/48
2001:b28:f23c::/48
2001:b28:f23d::/48
2001:b28:f23f::/48
2a0a:f280::/32

生成 geoip.dat 或 Country.mmdb 后 telegram IP 段:

91.105.192.0/23
91.108.4.0/22
91.108.8.0/21
91.108.16.0/21
91.108.56.0/22
95.161.64.0/20
149.154.160.0/20
185.76.151.0/24
2001:67c:4e8::/48
2001:b28:f23c::/47
2001:b28:f23f::/48
2a0a:f280::/32
Loyalsoldier commented 11 months ago

两行 /22 段合并成一行 /21 段了嘛

DustinWin commented 11 months ago

两行 /22 段合并成一行 /21 段了嘛

我举的例子可能不是很恰当,因为 cn_ip 源少了几千条 IP 段并不是因为 IP 段合并,而是被删除了

例如我使用的是白名单模式,dns 策略是没有命中规则的 IP(MATCH,即漏网之鱼) 全部使用代理服务器解析,当我使用 RULE-SET,cnip,DIRECT,链接使用 https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaIPs/ChinaIPs_IP.yaml 时,游戏可以正常登录;而当我使用 GEOIP,cn,DIRECT,使用源采用 https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaIPs/ChinaIPs_IP.yaml 所定制的 geoip.dat 时,游戏就无法登录

Loyalsoldier commented 11 months ago

是 DNS 解析的问题吧。

RULE-SET,cnip,DIRECT 这条规则在 Clash 里是会触发 DNS 解析的,而 GEOIP,cn,DIRECT 这条规则 + "domainStrategy": "AsIs" 在 V2Ray 和 XRay 中不会触发 DNS 解析。

DustinWin commented 11 months ago

是 DNS 解析的问题吧。

RULE-SET,cnip,DIRECT 这条规则在 Clash 里是会触发 DNS 解析的,而 GEOIP,cn,DIRECT 这条规则 + "domainStrategy": "AsIs" 在 V2Ray 和 XRay 中不会触发 DNS 解析。

好的,我再去看看,感谢!

kang000feng commented 6 months ago

还是通过 build.yml

你好,请教一下我想添加自己的ip 源,用fork后在线生成的方式, 在config.yaml 中增加了uri 地址, 有两个疑问,想向您请教.

  1. 需要在setting -secret 中填写自己的GITHUB_TOKEN 吗?
  2. 如果我没有注册获得MAXMIND_GEOLITE2_LICENSE ,是不是要去build.yml 把底下两个steps 删除掉? name: Get GeoLite2和name: download GeoLite2

以及到config.yaml 中把input 中 Csv 这段删除吗?

感谢您的回复

{ "type": "maxmindGeoLite2CountryCSV", "action": "add", "args": { "country": "./geolite2/GeoLite2-Country-Locations-en.csv", "ipv4": "./geolite2/GeoLite2-Country-Blocks-IPv4.csv", "ipv6": "./geolite2/GeoLite2-Country-Blocks-IPv6.csv" }

Loyalsoldier commented 6 months ago

@kang000feng

其实可以不 fork 本项目,而是自己新建项目,然后把本项目生成的 GeoIP 文件作为你的项目的 input。这样做的话,本项目更新代码后,你不需要同步最新代码。

不需要的输入都要删掉。另外,你要的文件在 release 分支:https://github.com/Loyalsoldier/geoip/tree/release

kang000feng commented 6 months ago

@kang000feng

其实可以不 fork 本项目,而是自己新建项目,然后把本项目生成的 GeoIP 文件作为你的项目的 input。这样做的话,本项目更新代码后,你不需要同步最新代码。

不需要的输入都要删掉。另外,你要的文件在 release 分支:https://github.com/Loyalsoldier/geoip/tree/release

非常感谢大佬提供建议. 谢谢🙏 这个方法非常好 我把您的mmdb及其他仓库的作为input , 请问我的config .yaml 及build.yaml 这样修改对吗?

Config :

{ ** "input": [

{ "type": "maxmindMMDB", "action": "add", "args": { "uri": "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb" } },

    {
  "type": "maxmindMMDB",
  "action": "add",
  "args": {
    "uri": "https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/Country.mmdb"
  }**
}

], "output": [ { "type": "v2rayGeoIPDat", "action": "output", "args": { "outputName": "geoip.dat" } }, { "type": "v2rayGeoIPDat", "action": "output", "args": { "outputName": "geoip-only-cn-private.dat", "wantedList": ["cn", "private"] } }, { "type": "v2rayGeoIPDat", "action": "output", "args": { "outputName": "geoip-asn.dat", "wantedList": [ "cloudflare", "cloudfront", "facebook", "fastly", "google", "netflix", "telegram", "twitter" ] } }, { "type": "v2rayGeoIPDat", "action": "output", "args": { "oneFilePerList": true, "wantedList": ["cn", "private"] } }, { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country.mmdb", "overwriteList": [ "cn", "private", "cloudflare", "cloudfront", "facebook", "fastly", "google", "netflix", "telegram", "twitter" ] } }, { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country-only-cn-private.mmdb", "wantedList": ["cn", "private"] } }, { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country-asn.mmdb", "wantedList": [ "cloudflare", "cloudfront", "facebook", "fastly", "google", "netflix", "telegram", "twitter" ] } }, { "type": "text", "action": "output" } ] }

Build.yaml

kang000feng commented 6 months ago

@kang000feng

其实可以不 fork 本项目,而是自己新建项目,然后把本项目生成的 GeoIP 文件作为你的项目的 input。这样做的话,本项目更新代码后,你不需要同步最新代码。

不需要的输入都要删掉。另外,你要的文件在 release 分支:https://github.com/Loyalsoldier/geoip/tree/release

这是我 build.yaml 的修改,能否再提点意见?

https://github.com/kang000feng/geoip/blob/master/.github/workflows/build.yml#L4

kang000feng commented 6 months ago

@kang000feng

其实可以不 fork 本项目,而是自己新建项目,然后把本项目生成的 GeoIP 文件作为你的项目的 input。这样做的话,本项目更新代码后,你不需要同步最新代码。

不需要的输入都要删掉。另外,你要的文件在 release 分支:https://github.com/Loyalsoldier/geoip/tree/release

尊敬的开发者,我用您上面推荐的这种方法生成geoip.dat 发现他没有自动去重? 文件居然有10M这么大?

https://github.com/kang000feng/geoip/blob/release/geoip.dat

Loyalsoldier commented 6 months ago

@kang000feng

https://github.com/alecthw/mmdb_china_ip_list 这个项目的 IP 地址是本项目的超集,所以没有必要使用本项目的 mmdb 文件