MCPcopy Index your code
hub / github.com/Loyalsoldier/geoip

github.com/Loyalsoldier/geoip @main sqlite

repository ↗ · DeepWiki ↗
328 symbols 884 edges 46 files 11 documented · 3%
README

GeoIP 增强版:自由定制多种格式 GeoIP 文件

GeoIP project hero image

Loyalsoldier%2Fgeoip | Trendshift

Ask DeepWiki badge jsdelivr stats badge

GitHub Downloads badge (all assets, all releases) GitHub Downloads badge (all assets, latest release)

名词解析

GeoIP,意为 IP geographic location,即 IP 地址所对应的地理位置信息,例如所属的国家、地区等。GeoIP 数据文件则存储着 IP 地址所对应的地理位置信息。

GeoIP, which stands for IP geographic location, refers to the geographic location information associated with an IP address, such as the country or region. And GeoIP data files store the geographic location information corresponding to IP addresses.

项目简介

本项目每周四自动生成多种格式 GeoIP 数据文件,同时提供命令行界面(CLI)工具供用户自行定制 GeoIP 数据文件,包括但不限于 V2Ray dat 格式文件 geoip.dat、MaxMind mmdb 格式文件 Country.mmdb(GeoIP2-Country.mmdb、GeoLite2-Country.mmdb)、sing-box SRS 格式文件、mihomo MRS 格式文件、Clash ruleset 规则文件、Surge ruleset 规则文件、Nginx allow list(允许访问列表)和 Nginx deny list(拒绝访问列表)。

This project releases various formats of GeoIP files automatically every Thursday, and provides a command line interface (CLI) tool for users to customize their own GeoIP files, including but not limited to V2Ray dat format file geoip.dat, MaxMind mmdb format file Country.mmdb(GeoIP2-Country.mmdb, GeoLite2-Country.mmdb), sing-box SRS format file, mihomo MRS format file, Clash ruleset file, Surge ruleset file, Nginx allow list and Nginx deny list.

GeoIP 类别

本项目默认使用 MaxMind GeoLite2 Country CSV 数据生成各个国家和地区的 GeoIP 文件。类别有:

  • geoip:cnGEOIP,CN):中国大陆(Mainland China)
  • geoip:hkGEOIP,HK):香港(Hong Kong)
  • geoip:moGEOIP,MO):澳门(Macau)
  • geoip:twGEOIP,TW):台湾(Taiwan)
  • geoip:usGEOIP,US):美国(America)
  • geoip:jpGEOIP,JP):日本(Japan)
  • geoip:krGEOIP,KR):韩国(Korea)
  • geoip:sgGEOIP,SG):新加坡(Singapore)
  • geoip:mmGEOIP,MM):缅甸(Myanmar)
  • geoip:irGEOIP,IR):伊朗(Iran)
  • geoip:ruGEOIP,RU):俄罗斯(Russia)
  • geoip:byGEOIP,BY):白俄罗斯(Belarus)
  • geoip:tmGEOIP,TM):土库曼斯坦(Turkmenistan)
  • geoip:privateGEOIP,PRIVATE):内网 IP 地址保留 IP 地址等特殊 IP 地址的集合
  • 更多可用的类别(以两位英文字母表示国家或地区),请查看:https://www.iban.com/country-codes

与 MaxMind 官方 GeoIP 数据的区别

本项目对 MaxMind 官方 GeoIP 数据做了如下修改新增

  • 中国大陆 IPv4 地址数据使用 @gaoyifan/china-operator-ip
  • 中国大陆 IPv6 地址数据使用 @gaoyifan/china-operator-ip
  • 新增类别(方便有特殊需求的用户使用):
  • geoip:cloudflareGEOIP,CLOUDFLARE
  • geoip:cloudfrontGEOIP,CLOUDFRONT
  • geoip:facebookGEOIP,FACEBOOK
  • geoip:fastlyGEOIP,FASTLY
  • geoip:googleGEOIP,GOOGLE
  • geoip:netflixGEOIP,NETFLIX
  • geoip:telegramGEOIP,TELEGRAM
  • geoip:twitterGEOIP,TWITTER
  • geoip:torGEOIP,TOR

下载地址与使用方法

[!NOTE] 如果无法访问域名 raw.githubusercontent.com,可以使用第二个地址 cdn.jsdelivr.net。 如果无法访问域名 cdn.jsdelivr.net,可以将其替换为 fastly.jsdelivr.net

*.sha256sum 为校验文件。

本项目发布的所有 GeoIP 文件,请查看 release 分支。以下是部分格式 GeoIP 文件的下载地址和使用方法:

V2Ray dat 使用方法

点击查看在 V2RayXray-core 中的使用方法

需要先下载 .dat 格式文件,并放置在程序目录内。

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Direct",
      "ip": [
        "geoip:cn",
        "geoip:private",
        "ext:cn.dat:cn",
        "ext:private.dat:private",
        "ext:geoip-only-cn-private.dat:cn",
        "ext:geoip-only-cn-private.dat:private"
      ]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "ip": [
        "geoip:us",
        "geoip:jp",
        "geoip:facebook",
        "geoip:telegram",
        "ext:geoip-asn.dat:facebook",
        "ext:geoip-asn.dat:telegram"
      ]
    }
  ]
}

点击查看在 mihomo 中的使用方法

geodata-mode: true
geox-url:
  geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat"

点击查看在 hysteria 中的使用方法

需要先下载 .dat 格式文件,并放置在 hysteria 程序目录内。

direct(geoip:cn)
proxy(geoip:telegram)
proxy(geoip:us)

点击查看在 Trojan-Go 中的使用方法

需要先下载 .dat 格式文件,并放置在 Trojan-Go 程序目录内。

"router": {
  "enabled": true,
  "bypass": ["geoip:cn"],
  "proxy": ["geoip:telegram", "geoip:us"],
  "block": ["geoip:jp"],
  "default_policy": "proxy",
  "geoip": "./geoip.dat"
}

点击查看在 dae 中的使用方法

点击前往查看:《吃鹅直通手册》


V2Ray dat 下载地址

适用于 V2RayXray-coremihomohysteriaTrojan-Godae

此 dat 格式文件不能用于 Nginx。

所有国家/地区新增类别的 dat 格式文件,请查看本项目 release 分支下的 dat 目录

部分国家/地区类别:

新增类别:

  • cloudflare
  • [https://raw.githubusercontent.com/Loy

Extension points exported contracts — how you extend this code

Typer (Interface)
(no doc) [18 implementers]
lib/lib.go
Container (Interface)
(no doc) [1 implementers]
lib/container.go
Instance (Interface)
(no doc) [1 implementers]
lib/instance.go
Actioner (Interface)
(no doc) [18 implementers]
lib/lib.go
Descriptioner (Interface)
(no doc) [18 implementers]
lib/lib.go
InputConverter (Interface)
(no doc) [11 implementers]
lib/lib.go
OutputConverter (Interface)
(no doc) [7 implementers]
lib/lib.go

Core symbols most depended-on inside this repo

GetName
called by 41
lib/entry.go
AddPrefix
called by 18
lib/entry.go
RegisterInputConverter
called by 17
lib/converter.go
RegisterInputConfigCreator
called by 17
lib/config.go
GetIgnoreIPType
called by 16
lib/common.go
NewEntry
called by 13
lib/entry.go
RegisterOutputConverter
called by 12
lib/converter.go
RegisterOutputConfigCreator
called by 12
lib/config.go

Shape

Method 206
Function 74
Struct 35
Interface 7
FuncType 3
TypeAlias 3

Languages

Go100%

Modules by API surface

plugin/v2ray/geoip.pb.go27 symbols
lib/instance.go21 symbols
lib/entry.go18 symbols
lib/container.go17 symbols
lib/lib.go16 symbols
plugin/maxmind/common_out.go13 symbols
plugin/mihomo/mrs_in.go12 symbols
plugin/v2ray/dat_out.go11 symbols
plugin/singbox/srs_out.go11 symbols
plugin/singbox/srs_in.go11 symbols
plugin/mihomo/mrs_out.go11 symbols
lib/config.go11 symbols

Dependencies from manifests, versioned

github.com/inconshreveable/mousetrapv1.1.0 · 1×
github.com/maxmind/mmdbwriterv1.2.0 · 1×
github.com/miekg/dnsv1.1.72 · 1×
github.com/oschwald/maxminddb-golang/v2v2.4.1 · 1×
github.com/sagernet/singv0.8.11 · 1×
github.com/tailscale/hujsonv0.0.0-2026030221245 · 1×

For agents

$ claude mcp add geoip \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact