Loyalsoldier / geoip

🌚 🌍 🌝 GeoIP 规则文件加强版,同时支持定制 V2Ray dat 格式路由规则文件 geoip.dat 和 MaxMind mmdb 格式文件 Country.mmdb。Enhanced edition of GeoIP files for V2Ray, Xray-core, Clash, Trojan-Go, Leaf and Hysteria, with replaced CN IPv4 CIDR available from ipip.net, appended CIDR lists and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

定制`Country.mmdb`增加自己IP到HK,本地生成,结果仍归属于CN

imldy opened this issue · comments

生成流程

config.json(我将自定义的放在了input列表最后):

{
  "input": [
    {
      "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"
      }
    },
    {
      "type": "cutter",
      "action": "remove",
      "args": {
        "wantedList": ["cn"],
        "onlyIPType": "ipv4"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "cn",
        "uri": "https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt",
        "onlyIPType": "ipv4"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "cn",
        "uri": "https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china.txt",
        "onlyIPType": "ipv4"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "cn",
        "uri": "https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china6.txt",
        "onlyIPType": "ipv6"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "cloudflare",
        "uri": "https://www.cloudflare.com/ips-v4"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "cloudflare",
        "uri": "https://www.cloudflare.com/ips-v6"
      }
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "telegram",
        "uri": "https://core.telegram.org/resources/cidr.txt"
      }
    },
    {
      "type": "private",
      "action": "add"
    },
    {
      "type": "text",
      "action": "add",
      "args": {
        "name": "hk",
        "uri": "geo/hk.txt"
      }
    }
  ],
  "output": [
    {
      "type": "maxmindMMDB",
      "action": "output",
      "args": {
        "outputName": "Country.mmdb",
        "overwriteList": [
          "hk"
        ]
      }
    },
    {
      "type": "text",
      "action": "output"
    }
  ]
}

geo/hk.txt:

43.198.178.151/32

生成log:

2023/08/14 02:03:00 ✅ [maxmindMMDB] Country.mmdb --> output\maxmind
2023/08/14 02:03:00 ✅ [text] hm.txt --> output\text
2023/08/14 02:03:00 ✅ [text] bj.txt --> output\text
……

测试流程

复制 output/maxmind/Country.mmdbC:\%userprofile%\.config\clash\

重启CFW。

使用 CFW Script Test 功能(基于 Clash Premium Script),对添加的IP进行测试。

代码:

def main(ctx, metadata):
  region = ctx.geoip(metadata["host"])
  return region

仍然返回CN:

image

生成的 Country.mmdb 文件没有问题。应该是 cfw 的问题,但由于 cfw 不开源,没法判断成因。