This project automatically generates GeoIP files every Thursday, and provides a command line interface (CLI) for users to customize GeoIP files, including but not limited to V2Ray dat format routing rule file geoip.dat
and MaxMind mmdb format file Country.mmdb
.
This project releases GeoIP files automatically every Thursday. It also provides a command line interface(CLI) for users to customize their own GeoIP files, included but not limited to V2Ray dat format file geoip.dat
and MaxMind mmdb format file Country.mmdb
.
- Mainland China IPv4 address data is integrated with IPIP.net and [@gaoyifan/china-operator-ip](https:// github.com/gaoyifan/china-operator-ip/blob/ip-lists/china.txt)
- Mainland China IPv6 address data combined with MaxMind GeoLite2 and @gaoyifan/china-operator-ip
- New category (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
)
Use the reference configuration of this project's .dat
format file in V2Ray:
"routing": {
"rules": [
{
"type": "field",
"outboundTag": "Direct",
"ip": [
"geoip:ir",
"geoip:private",
"ext:ir.dat:ir",
"ext:private.dat:private",
"ext:geoip-only-ir-private.dat:ir",
"ext:geoip-only-ir-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"
]
}
]
}
Use the reference configuration of this project's .mmdb
format file in Clash:
rules:
- GEOIP,PRIVATE,DIRECT,no-resolve
- GEOIP,FACEBOOK,DIRECT
- GEOIP,IR,DIRECT
Use the reference configuration of this project's .mmdb
format file in Leaf, see Official README.
If the domain
raw.githubusercontent.com
cannot be accessed, the second addresscdn.jsdelivr.net
can be used. *.sha256sum is the verification file.
Available for V2Ray, Xray-core and [Trojan-Go](https https://github.com/p4gefau1t/trojan-go).
- geoip.dat:
- geoip.dat.sha256sum:
- geoip-only-ir-private.dat (Lite version of GeoIP, only contains
geoip:ir
andgeoip:private
): - geoip-only-ir-private.dat.sha256sum:
- geoip-asn.dat (Lite version of GeoIP, containing only the above added categories):
- geoip-asn.dat.sha256sum:
- ir.dat (Lite version of GeoIP, contains only
geoip:ir
): - ir.dat.sha256sum:
- private.dat (Lite version of GeoIP, only contains
geoip:private
): - private.dat.sha256sum:
- Country.mmdb:
- Country.mmdb.sha256sum:
- Country-only-ir-private.mmdb (Lite version of GeoIP, only contains
GEOIP,IR
andGEOIP,PRIVATE
): - Country-only-ir-private.mmdb.sha256sum:
- Country-asn.mmdb (Lite version of GeoIP, only contains the above added categories):
- Country-asn.mmdb.sha256sum:
GeoIP files can be customized in several ways:
- Online generation: Fork After this warehouse, modify the configuration file
config.json
and GitHub Workflow.github/workflows in your own warehouse/build.yml
- local generation:
Special Note:
- Online Generation: Fork After this project, if you need to use the MaxMind GeoLite2 Country CSV data file, you need to use **[Settings] in your warehouse Add a secret named MAXMIND_GEOLITE2_LICENSE to the [Secrets] page of the ** tab, otherwise GitHub Actions will fail to run. The value of this secret is the LICENSE KEY of the MAXMIND account. After registering a MAXMIND account, go to the [personal account management page] ](https://www.maxmind.com/en/account) generated in [My License Key] under the [Services] item on the left sidebar.
- Local generation: If you need to use the MaxMind GeoLite2 Country CSV data file (
GeoLite2-Country-CSV.zip
), you need to download it from MaxMind in advance, or from the project [release branch](https://github. com/MiSaturo/GeoIP-DB-For-Iran/tree/release)Download, and extract it to a directory namedgeolite2
.
This project has two concepts: input
and output
. input
refers to the data source (data source) and its input format, and output
refers to the destination of the data (data destination) and its output format. The role of the CLI is to aggregate all data sources provided by the user by reading the options in the configuration file, deduplicate them, 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, see the config-example.json
file of this project.
Supported input
input formats:
- text: plaintext IP and CIDR (eg:
1.1.1.1
or1.0.0.0/24
) - private: LAN and private network CIDR (eg:
192.168.0.0/16
and127.0.0.0/8
) - cutter: used to crop the data in the previous step
- v2rayGeoIPDat: V2Ray GeoIP dat format (
geoip.dat
) - maxmindMMDB: MaxMind mmdb data format (
GeoLite2-Country.mmdb
) - maxmindGeoLite2CountryCSV: MaxMind GeoLite2 country CSV data (
GeoLite2-Country-CSV.zip
) - clashRuleSetClassical: classical type of Clash RuleSet
- clashRuleSet: Clash RuleSet of type ipcidr
- surgeRuleSet: Surge RuleSet
Supported output
output formats:
- text: plain text CIDR (eg:
1.0.0.0/24
) - v2rayGeoIPDat: V2Ray GeoIP dat format (
geoip.dat
, suitable for V2Ray, Xray-core and Trojan-Go) - maxmindMMDB: MaxMind mmdb data format (
GeoLite2-Country.mmdb
for Clash and Leaf) - clashRuleSetClassical: classical type of Clash RuleSet
- clashRuleSet: Clash RuleSet of type ipcidr
- surgeRuleSet: Surge RuleSet
Due to the limitation of the MaxMind mmdb file format, when the IP or CIDR data of different lists overlap or overlap, the IP or CIDR data of the list written later will overwrite (overwrite) the data of the previously written list. For example, IP 1.1.1.1
belongs to both list AU
and list Cloudflare
. If Cloudflare
is written after AU
, the 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 output
output format as maxmindMMDB
, the list specified in this option will be Write one by one at the end, the last item in the list 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, and the last item in the list has the highest priority.
The CLI can be installed directly via go install -v github.com/MiSaturo/GeoIP-DB-For-Iran@latest
.
$./geoip -h
Usage of./geoip:
-c string
URI of the JSON format config file, support both local file path and remote HTTP(S) URL (default "config.json")
-l List all available input and output formats
$./geoip -c config.json
2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip.dat --> output/dat
2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip-only-ir-private.dat --> output/dat
2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] geoip-asn.dat --> output/dat
2021/08/29 12:11:35 ✅ [v2rayGeoIPDat] ir.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-ir-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] ir.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
$./geoip -l
All available input formats:
- v2rayGeoIPDat (Convert V2Ray GeoIP dat to other formats)
- maxmindMMDB (Convert MaxMind mmdb database to other formats)
- maxmindGeoLite2CountryCSV (Convert MaxMind GeoLite2 country CSV data to other formats)
- private (Convert LAN and private network CIDR to other formats)
- text (Convert plaintext IP & CIDR to other formats)
- clashRuleSetClassical (Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines))
- clashRuleSet (Convert ipcidr type of Clash RuleSet to other formats)
- surgeRuleSet (Convert Surge RuleSet to other formats (just processing IP & CIDR lines))
- cutter (Remove data from previous steps)
- test (Convert specific CIDR to other formats (for test only))
All available output formats:
- v2rayGeoIPDat (Convert data to V2Ray GeoIP dat format)
- maxmindMMDB (Convert data to MaxMind mmdb database format)
-clashRuleSetClassical (Convert data to classical type of Clash RuleSet)
-clashRuleSet (Convert data to ipcidr type of Clash RuleSet)
- surgeRuleSet (Convert data to Surge RuleSet)
- text (Convert data to plaintext CIDR format)
This product includes GeoLite2 data created by MaxMind, available from MaxMind.