This project automatically generates GeoIP files in various formats every Thursday, and also provides command line interface (CLI) tools for users to customize GeoIP files, including but not limited to V2Ray dat
format file geoip.dat
, MaxMind mmdb
format file Country.mmdb
, sing -box SRS
format file, mihomo MRS
format file, Clash ruleset and Surge ruleset.
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
, sing-box SRS
format files, mihomo MRS
format files, Clash ruleset files and Surge ruleset files.
By default, this project uses MaxMind GeoLite2 Country CSV data to generate GeoIP files for each country and region. For all available country and region geoip categories (such as geoip:cn
, two English letters represent the country and region), please view: https://www.iban.com/country-codes.
In addition, this project has modified and added new MaxMind official GeoIP data:
Mainland China IPv4 address data combines IPIP.net and @gaoyifan/china-operator-ip
Mainland China IPv6 address data combines MaxMind GeoLite2 and @gaoyifan/china-operator-ip
New categories (convenient for users with special needs):
geoip:cloudflare
( GEOIP,CLOUDFLARE
)
geoip:cloudfront
( GEOIP,CLOUDFRONT
)
geoip:facebook
( GEOIP,FACEBOOK
)
geoip:fastly
( GEOIP,FASTLY
)
geoip:google
( GEOIP,GOOGLE
)
geoip:netflix
( GEOIP,NETFLIX
)
geoip:telegram
( GEOIP,TELEGRAM
)
geoip:twitter
( GEOIP,TWITTER
)
geoip:tor
( GEOIP,TOR
)
For all GeoIP files released by this project, please check the release branch. The following are download addresses for some formats of GeoIP files:
If you cannot access the domain name
raw.githubusercontent.com
, you can use the second addresscdn.jsdelivr.net
. If the domain namecdn.jsdelivr.net
is not accessible, you can replace it withfastly.jsdelivr.net
.*.sha256sum is the verification file.
Applicable to V2Ray, Xray-core, mihomo, hysteria, Trojan-Go.
This dat format file cannot be used with Nginx.
geoip.dat :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat
geoip.dat.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat.sha256sum
geoip-only-cn-private.dat (lite version of GeoIP, only contains geoip:cn
and geoip:private
):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat
geoip-only-cn-private.dat.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat.sha256sum
geoip-asn.dat (lite version of GeoIP, only includes the above new categories):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat
geoip-asn.dat.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat.sha256sum
cn.dat (lite version of GeoIP, only contains geoip:cn
):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat
cn.dat.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat.sha256sum
private.dat (lite version of GeoIP, only contains geoip:private
):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat
private.dat.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat.sha256sum
For dat format files in all countries/regions/new categories , please check the dat directory under the release
branch of this project.
You need to download the .dat
format file first and place it in the program directory.
"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" ] } ] }
geodata-mode: truegeox-url: geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat"
You need to download the .dat
format file first and place it in the hysteria program directory.
direct(geoip:cn) proxy(geoip:telegram) proxy(geoip:us)
You need to download the .dat
format file first and place it in the Trojan-Go program directory.
"router": { "enabled": true, "bypass": ["geoip:cn"], "proxy": ["geoip:telegram", "geoip:us"], "block": ["geoip:jp "], "default_policy": "proxy", "geoip": "./geoip.dat"}
MaxMind official version country/region type mmdb file:
Suitable for Clash, mihomo, Shadowrocket, Quantumult X, Surge, Leaf.
Applicable to Nginx, it needs to be used with the ngx_http_geoip2_module module.
GeoLite2-Country.mmdb :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/GeoLite2-Country.mmdb
GeoLite2-Country.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/GeoLite2-Country.mmdb.sha256sum
MaxMind official version ASN type mmdb file:
Suitable for mihomo, Shadowrocket, Surge.
GeoLite2-ASN.mmdb :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-ASN.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/GeoLite2-ASN.mmdb
GeoLite2-ASN.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-ASN.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/GeoLite2-ASN.mmdb.sha256sum
Country/region type mmdb file generated by this project:
Suitable for Clash, mihomo, Shadowrocket, Quantumult X, Surge, Leaf.
Applicable to Nginx, it needs to be used with the ngx_http_geoip2_module module.
The country/region category retains all fields in
Continent
andCountry
. The new category and geoip:private category only retainiso_code
(country/region code represented by two English letters) field inCountry
. For the complete fields of Maxmind’s official country MMDB format file, please view the code.
Country-without-asn.mmdb (the traditional version of GeoIP only includes country/region categories and does not include the above-mentioned new categories. It is recommended to use it first):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-without-asn.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-without-asn.mmdb
Country-without-asn.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-without-asn.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-without-asn.mmdb.sha256sum
Country.mmdb (enhanced version of GeoIP, including country/region categories, as well as the above-mentioned new categories. However, due to MaxMind mmdb format limitations, the IP address data of some country/region categories are not as accurate as the above-mentioned Country-without-asn.mmdb ):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country.mmdb
Country.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country.mmdb.sha256sum
Country-only-cn-private.mmdb (lite version of GeoIP, only contains GEOIP,CN
and GEOIP,PRIVATE
):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-only-cn-private.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-only-cn-private.mmdb
Country-only-cn-private.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-only-cn-private.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-only-cn-private.mmdb.sha256sum
Country-asn.mmdb (lite version of GeoIP, only includes the above new categories):
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-asn.mmdb
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-asn.mmdb
Country-asn.mmdb.sha256sum :
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country-asn.mmdb.sha256sum
https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country-asn.mmdb.sha256sum
You need to download the .mmdb
format file first, name it Country.mmdb
, and place it in the Clash program directory.
rules: - GEOIP,PRIVATE,policy,no-resolve - GEOIP,FACEBOOK,policy - GEOIP,CN,policy,no-resolve
geodata-mode: truegeox-url: mmdb: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/Country.mmdb" asn: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/GeoLite2-ASN.mmdb"
The download address needs to be filled in the settings of Shadowrocket.
[Rule]
GEOIP,PRIVATE,DIRECT
GEOIP,FACEBOOK,PROXY
GEOIP,CN,DIRECT
The download address needs to be filled in the settings of Quantumult X.
[filter_local]
GEOIP,PRIVATE,DIRECT
GEOIP,FACEBOOK,PROXY
GEOIP,CN,DIRECT
The download address needs to be filled in the Surge settings.
[Rule]
GEOIP,PRIVATE,policy,no-resolve
GEOIP,FACEBOOK,policy
GEOIP,CN,policy,no-resolve
Suitable for sing-box.
Please check the srs directory under the release
branch of this project.
"route": { "rules": [ { "rule_set": "geoip-cn", "outbound": "direct"}, { "rule_set": "geoip-us", "outbound": "block"} ], "rule_set": [ { "tag": "geoip-cn", "type": "remote", "format": "binary", "url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/ srs/cn.srs"}, { "tag": "geoip-us", "type": "remote", "format": "binary", "url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/ srs/us.srs"} ] }
Suitable for mihomo.
Please check the mrs directory under the release
branch of this project.
rule-providers: cn-cidr:type: httpbehavior: ipcidrformat: mrsurl: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/mrs/cn.mrs" path: ./mrs/geoip/cn .mrsinterval: 86400 google-cidr:type: httpbehavior: ipcidrformat: mrsurl: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/mrs/google.mrs" path: ./mrs/geoip/google.mrsinterval: 86400rules : - RULE-SET,cn-cidr,DIRECT - RULE-SET,google-cidr,PROXY,no-resolve
Applicable to Clash Premium, mihomo.
Please check the crash directory under the release
branch of this project.
rule-providers: cn-cidr:type: httpbehavior: ipcidrformat: yamlurl: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/clash/ipcidr/cn.txt" path: ./ruleset/ipcidr /cn.yamlinterval: 86400 telegram-cidr:type: httpbehavior: ipcidrformat: yamlurl: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/clash/ipcidr/telegram.txt" path: ./ruleset/ipcidr/telegram.yamlinterval :86400rules: - RULE-SET,cn-cidr,DIRECT - RULE-SET,telegram-cidr,PROXY,no-resolve
Suitable for Surge.
Please check the surge directory under the release
branch of this project.
[Rule]
RULE-SET,https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/surge/us.txt,REJECT
RULE-SET,https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/surge/cn.txt,DIRECT
RULE-SET,https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/surge/telegram.txt,PROXY,no-resolve
Please check the text directory under the release
branch of this project.
allow
and deny
files Please check the nginx directory under the release
branch of this project.
GeoIP files can be customized in the following ways:
Online generation : After Fork this warehouse, modify the configuration files config.json
and GitHub Workflow .github/workflows/build.yml
in your own warehouse
Local generation :
Install Golang and Git
Pull the project code: git clone https://github.com/Loyalsoldier/geoip.git
Enter the project root directory: cd geoip
Modify the configuration file config.json
Run the code: go run ./ convert -c ./config.json
Special instructions:
Online generation : Fork After this project, if you need to use the MaxMind GeoLite2 official data file, you need to add a file named MAXMIND_GEOLITE2_LICENSE to the [Actions] tab page under [Secrets and variables] on the left sidebar of the [Settings] page of your warehouse secret, otherwise GitHub Actions will fail to run. The value of this secret is the LICENSE KEY of the MaxMind account. It needs to be generated in [ Manage License Keys ] in the left sidebar of the personal account management page after registering a MaxMind account .
Local generation : If you need to use MaxMind's official GeoLite2 data file, you need to download it from MaxMind in advance, or download it from the release branch of this project (the file name is prefixed with GeoLite2
), and unzip it to a directory named geolite2
.
This project has two concepts: input
and output
. input
refers to the data source and its input format, and output
refers to the data destination and its output format. The function of the CLI is to aggregate all data sources provided by the user by reading the options in the configuration file, remove duplicates, convert them to the target format, and output them to a file.
These two concepts are notable: input
and output
. The input
is the data source and its input format, whereas the output
is the destination of the converted data and its output format. What the CLI does is to aggregate all input format data, then convert them to output format and write them to GeoIP files by using the options in the config file.
For configuration options supported by each format, view the configuration.md
file of this project.
Supported input
formats:
text : Plain text IP and CIDR (for example: 1.1.1.1
or 1.0.0.0/24
)
stdin : Get plain text IP and CIDR from standard input (for example: 1.1.1.1
or 1.0.0.0/24
)
private : LAN and private network CIDR (for example: 192.168.0.0/16
and 127.0.0.0/8
)
cutter : used to cut the data in the previous step
json : JSON data format
v2rayGeoIPDat : V2Ray GeoIP dat data format ( geoip.dat
)
maxmindMMDB : MaxMind GeoLite2 country mmdb data format ( GeoLite2-Country.mmdb
)
maxmindGeoLite2ASNCSV : MaxMind GeoLite2 ASN CSV data format ( GeoLite2-ASN-CSV.zip
)
maxmindGeoLite2CountryCSV : MaxMind GeoLite2 country CSV data format ( GeoLite2-Country-CSV.zip
)
dbipCountryMMDB : DB-IP country mmdb data format ( dbip-country-lite.mmdb
)
ipinfoCountryMMDB : IPInfo country mmdb data format ( country.mmdb
)
mihomoMRS : mihomo MRS data format ( geoip-cn.mrs
)
singboxSRS : sing-box SRS data format ( geoip-cn.srs
)
clashRuleSetClassical : Clash RuleSet of classic type
clashRuleSet : Clash RuleSet of type ipcidr
surgeRuleSet : SurgeRuleSet
Supported output
formats:
text : Plain text CIDR (for example: 1.0.0.0/24
)
stdout : Output plain text CIDR to standard output (for example: 1.0.0.0/24
)
lookup : Find the specified IP or CIDR from the specified list
v2rayGeoIPDat : V2Ray GeoIP dat data format ( geoip.dat
)
maxmindMMDB : MaxMind GeoLite2 country mmdb data format ( GeoLite2-Country.mmdb
)
dbipCountryMMDB : DB-IP country mmdb data format ( dbip-country-lite.mmdb
)
ipinfoCountryMMDB : IPInfo country mmdb data format ( country.mmdb
)
mihomoMRS : mihomo MRS data format ( geoip-cn.mrs
)
singboxSRS : sing-box SRS data format ( geoip-cn.srs
)
clashRuleSetClassical : Clash RuleSet of classic type
clashRuleSet : Clash RuleSet of type ipcidr
surgeRuleSet : SurgeRuleSet
Due to the limitations of the mmdb file format of MaxMind, DB-IP, and IPInfo, when the IP or CIDR data of different lists have intersections or duplicates, the IP or CIDR data of the list written later will overwrite the previously written one. List of data. For example, IP 1.1.1.1
belongs to both list AU
and list Cloudflare
. If Cloudflare
writes after AU
, then IP 1.1.1.1
belongs to the list Cloudflare
.
In order to ensure that certain specified lists and modified lists must include all IP or CIDR data belonging to it, the option overwriteList
can be added to the configuration of the corresponding output format output
. The lists specified in this option will be written one by one at the end. The last item has the highest priority. If the option wantedList
is set, there is no need to set overwriteList
. The list specified in wantedList
will be written one by one at the end, with the last item in the list having the highest priority.
The CLI tool can be installed directly through go install -v github.com/Loyalsoldier/geoip@latest
.
The functions provided by the CLI are as follows:
List supported input
and output
formats ( list
)
GeoIP data format conversion ( convert
)
Find the category of IP or CIDR ( lookup
)
Deduplication and merging IP and CIDR ( merge
)
$ ./geoip geoip is a convenient tool to merge, convert and lookup IP & CIDR from various formats of geoip data. Usage: geoip [command] Available Commands: convert Convert geoip data from one format to another by using config file help Help about any command list List all available input and output formats lookup Lookup specified IP or CIDR in specified lists merge Merge plaintext IP & CIDR from standard input, then print to standard output Flags: -h, --help help for geoip Use "geoip [command] --help" for more information about a command.
input
and output
formats ( list
)$ ./geoip list All available input formats: - clashRuleSet (Convert ipcidr type of Clash RuleSet to other formats) - clashRuleSetClassical (Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines)) - cutter (Remove data from previous steps) - dbipCountryMMDB (Convert DB-IP country mmdb database to other formats) - ipinfoCountryMMDB (Convert IPInfo country mmdb database to other formats) - json (Convert JSON data to other formats) - maxmindGeoLite2ASNCSV (Convert MaxMind GeoLite2 ASN CSV data to other formats) - maxmindGeoLite2CountryCSV (Convert MaxMind GeoLite2 country CSV data to other formats) - maxmindMMDB (Convert MaxMind mmdb database to other formats) - mihomoMRS (Convert mihomo MRS data to other formats) - private (Convert LAN and private network CIDR to other formats) - singboxSRS (Convert sing-box SRS data to other formats) - stdin (Accept plaintext IP & CIDR from standard input, separated by newline) - surgeRuleSet (Convert Surge RuleSet to other formats (just processing IP & CIDR lines)) - test (Convert specific CIDR to other formats (for test only)) - text (Convert plaintext IP & CIDR to other formats) - v2rayGeoIPDat (Convert V2Ray GeoIP dat to other formats) All available output formats: - clashRuleSet (Convert data to ipcidr type of Clash RuleSet) - clashRuleSetClassical (Convert data to classical type of Clash RuleSet) - dbipCountryMMDB (Convert data to DB-IP country mmdb database format) - ipinfoCountryMMDB (Convert data to IPInfo country mmdb database format) - lookup (Lookup specified IP or CIDR from various formats of data) - maxmindMMDB (Convert data to MaxMind mmdb database format) - mihomoMRS (Convert data to mihomo MRS format) - singboxSRS (Convert data to sing-box SRS format) - stdout (Convert data to plaintext CIDR format and output to standard output) - surgeRuleSet (Convert data to Surge RuleSet) - text (Convert data to plaintext CIDR format) - v2rayGeoIPDat (Convert data to V2Ray GeoIP dat format)
merge
)$ curl -s https://core.telegram.org/resources/cidr.txt | ./geoip merge -t ipv4 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 149.154.160.0/20 185.76.151.0/24
convert
)$ ./geoip convert -c config.json 2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip.dat --> output/dat 2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip-only-cn-private.dat --> output/dat 2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip-asn.dat --> output/dat 2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] cn.dat --> output/dat 2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] private.dat --> output/dat 2021/08/29 12:11:39 ✅ [maxmindMMDB] Country.mmdb --> output/maxmind 2021/08/29 12:11:39 ✅ [maxmindMMDB] Country-only-cn-private.mmdb --> output/maxmind 2021/08/29 12:11:39 ✅ [text] netflix.txt --> output/text 2021/08/29 12:11:39 ✅ [text] telegram.txt --> output/text 2021/08/29 12:11:39 ✅ [text] cn.txt --> output/text 2021/08/29 12:11:39 ✅ [text] cloudflare.txt --> output/text 2021/08/29 12:11:39 ✅ [text] cloudfront.txt --> output/text 2021/08/29 12:11:39 ✅ [text] facebook.txt --> output/text 2021/08/29 12:11:39 ✅ [text] fastly.txt --> output/text 2021/08/29 12:11:45 ✅ [singboxSRS] netflix.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] telegram.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] cn.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] cloudflare.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] cloudfront.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] facebook.txt --> output/srs 2021/08/29 12:11:45 ✅ [singboxSRS] fastly.txt --> output/srs 2021/08/29 12:11:50 ✅ [mihomoMRS] netflix.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] telegram.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] cn.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] cloudflare.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] cloudfront.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] facebook.txt --> output/mrs 2021/08/29 12:11:50 ✅ [mihomoMRS] fastly.txt --> output/mrs
lookup
)Possible return results:
The query string is not a valid IP or CIDR, and false
is returned.
The queried IP or CIDR does not exist in any category, return false
The queried IP or CIDR exists in a single category in a file of some format:
If the format file contains only one category, return true
If the format file contains multiple categories, return the matching category name
The queried IP or CIDR exists in multiple categories, and the category names separated by English commas are returned, such as au,cloudflare
# ================= One-time Mode ================= ## From local files in text format (only containing Lookup IP from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt 1.0.1.1true# Lookup IP from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt 1.0.1.1true# Lookup IP from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt 2.2.2.2false# Lookup CIDR from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt 1.0.1.1/24true# Lookup CIDR from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt 1.0.1.1 /23false# Lookup IP from remote URL (with only one list) in text format$ ./geoip lookup -f text -u https:// example.com/cn.txt 1.0.1.1true# Lookup IP from local file (with only one list) in v2rayGeoIPDat format$ ./geoip lookup -f v2rayGeoIPDat -u ./cn.dat 1.0.1.1true# Lookup IP from local file (with multiple lists) in v2rayGeoIPDat format$ ./ geoip lookup -f v2rayGeoIPDat -u ./geoip.dat 1.0.1.1 cn# Lookup IP from local file (with multiple lists) in v2rayGeoIPDat format$ ./geoip lookup -f v2rayGeoIPDat -u ./geoip.dat 1.0 .0.1 au,cloudflare# lookup CIDR from remote URL (with multiple lists) in v2rayGeoIPDat format$ ./geoip lookup -f v2rayGeoIPDat -u https://example .com/geoip.dat 1.0.0.1/24 au,cloudflare# ================= REPL Mode ================= ## From local files in text format (only Lookup IP or CIDR from local file (with only one list) in text format$ ./geoip lookup -f text -u ./cn.txt Enter IP or CIDR (type "exit" to quit):>> 1.0.1.1true>> 1.0.1.1/24true>> 1.0.1.1/23false>> 2.2.2.2false>> 2.2.2.2/24false>> 300.300. 300.300false>> 300.300.300.300/24false>> exit# lookup IP or CIDR from remote URL (with only one list) in text format $ ./geoip lookup -f text -u https://example.com/cn.txt Enter IP or CIDR (type "exit" to quit):>> 1.0.1.1true>> 1.0.1.1/24true>> 1.0.1.1/23false>> 2.2.2.2false>> 2.2.2.2/24false>> 300.300. 300.300false>> 300.300.300.300/24false>> exit# lookup IP or CIDR from local file (with only one list) in v2rayGeoIPDat format $ ./geoip lookup -f v2rayGeoIPDat -u ./cn.dat Enter IP or CIDR (type "exit" to quit):>> 1.0.1.1true>> 1.0.1.1/24true>> 1.0.1.1/23false>> 2.2.2.2false>> 2.2.2.2/24false>> 300.300. 300.300false>> 300.300.300.300/24false>> exit# lookup IP or CIDR from remote URL (with multiple list) in v2rayGeoIPDat format$ ./geoip lookup -f v2rayGeoIPDat -u https://example.com/geoip.dat Enter IP or CIDR (type "exit" to quit):>> 1.0.1.1 cn>> 1.0.1.1/24 cn>> 1.0.1.1/23false>> 1.0.0.1 au,cloudflare>> 1.0.0.1/24 au,cloudflare>> 300.300.300.300false>> 300.300.300.300/24false>> exit
@Loyalsoldier/v2ray-rules-dat
@Loyalsoldier/clash-rules
@Loyalsoldier/surge-rules
CC-BY-SA-4.0 and GPL-3.0
This product includes GeoLite2 data created by MaxMind, available from MaxMind.