Extract information from geoip and geosite files from Project X and Sing-box.
Usage of geoview:
-action string
action: extract | convert | lookup (default "extract")
-append
append to existing file instead of overwriting
-format string
convert output format. type: ruleset(srs) | quantumultx(qx) | json | geosite | geoip (default "ruleset")
-input string
datafile
-ipv4
enable ipv4 output (default true)
-ipv6
enable ipv6 output (default true)
-list string
comma separated site or geo list, e.g. "cn,jp" or "youtube,google"
-lowmem
low memory mode, reduce memory cost by partial file reading
-output string
output to file, leave empty to print to console
-regex
allow regex rules in the geosite result
-strict
strict mode, non-existent code will result in an error (default true)
-type string
datafile type: geoip | geosite (default "geoip")
-value string
ip or domain to lookup, required only for lookup action
-version
print version
./geoview -type geoip -input geoip.dat -list cn,jp -output cn_jp.txt
./geoview -type geosite -input geosite.dat -list gfw -output gfw.txt
The -action lookup
flag will search for your target ip or domain in the geoip or geosite file and output all the list codes that contain the desired IP or domain, including all possible domain attributes (no support for sing-box geosite)
./geoview.exe -input geoip.dat -type geoip -action lookup -value 1.1.1.1
AU
CLOUDFLARE
./geoview.exe -input geosite.dat -type geosite -action lookup -value samsung
TLD-!CN
PRIVATE
CATEGORY-COMPANIES
SAMSUNG
GEOLOCATION-!CN
./geoview.exe -input geosite.dat -type geosite -action lookup -value xp.apple.com
APPLE
APPLE@cn
APPLE-CN
CATEGORY-COMPANIES
CATEGORY-COMPANIES@cn
GEOLOCATION-!CN
APPLE-UPDATE
The following conversions are supported
- srs ruleset for singbox (*default)
- filter for QuantumultX
- converting from geosite to a subset of geosite
- converting from geoip to a subset of geoip
Format can be set by -format
flag. abbr. is also accepted, such as qx
for quantumultx
./geoview -type geosite -action convert -input geosite.dat -list medium -output medium.json
./geoview -type geosite -action convert -input geosite.dat -list medium -output medium.srs
./geoview -type geosite -action convert -input geosite.dat -list medium -output medium.conf -format qx
./geoview -type geosite -action convert -input geosite.dat -list medium -output medium.dat -format geosite
./geoview -type geoip -action convert -input geoip.dat -list CN,JP -output cnjp.dat -format geoip
-
Regex rules of geosite are ignored by default.
-
When using
-append=true
to ruleset and the output format is JSON, existing rules will be kept and new rules will be appended. -
When converting geo files to ruleset, the output format is determined by
-format
flag. The format is alwaysJSON
ifoutput
is not specified for ruleset conversion. -
Binary ruleset conversion doesn't support appending, it always creates a new file.
By adding -lowmem
to the command, the program will read the file partially to reduce memory usage. This is useful when execute on devices with limited memory.
Download the latest Openwrt source and clone this repository to the package directory.
git clone https://github.com/snowie2000/geoview.git package/geoview
Follow the steps below to compile the package.
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
Network ---> IP Addresses and Names ---> <*> geoview
make package/geoview/{clean,compile} V=s
To compile the golang projects under Linux/arm64
, you need to manually install golang and set external golang environment in the make menuconfig
menu.