### Configure text Output with Prefix, Suffix, Directory, and Extension Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'text' type to output GeoIP data to a custom directory ('./text') with a '.conf' extension. Each line will have 'IP-CIDR,' as a prefix and ',no-resolve' as a suffix. ```jsonc { "type": "text", "action": "output", "args": { "outputDir": "./text", // 输出文件到目录 ./text "outputExtension": ".conf", // 输出文件的扩展名为 .conf "addPrefixInLine": "IP-CIDR,", "addSuffixInLine": ",no-resolve" } } ``` -------------------------------- ### Configure text Output with Wanted List and Prefix Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'text' type to output GeoIP data for 'cn', 'us', and 'jp' categories only. It specifies a custom directory, '.conf' extension, and 'HOST,' as a prefix for each line. ```jsonc { "type": "text", "action": "output", "args": { "outputDir": "./text", // 输出文件到目录 ./text "outputExtension": ".conf", // 输出文件的扩展名为 .conf "wantedList": ["cn", "us", "jp"], // 只输出名为 cn、us、jp 这三个类别的 IPv4 和 IPv6 地址 "addPrefixInLine": "HOST," } } ``` -------------------------------- ### Configure Default surgeRuleSet Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration sets up the 'surgeRuleSet' output type with default settings. The output directory defaults to './output/surge'. ```jsonc { "type": "surgeRuleSet", "action": "output" } ``` -------------------------------- ### Configure surgeRuleSet Output with Directory and Extension Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration specifies a custom output directory ('./surge') and file extension ('.conf') for the 'surgeRuleSet' output type. ```jsonc { "type": "surgeRuleSet", "action": "output", "args": { "outputDir": "./surge", // 输出文件到目录 ./surge "outputExtension": ".conf" // 输出文件的扩展名为 .conf } } ``` -------------------------------- ### Add IPs from Local File and Direct IPs/CIDRs using Text Input Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Combines reading IP addresses from a local file and adding specific IP addresses or CIDR blocks to the same category in one operation. ```jsonc { "type": "text", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "uri": "./cn.txt", // 读取本地文件 cn.txt 的 IPv4 和 IPv6 地址,并添加到 cn 类别中 "ipOrCIDR": ["1.0.0.1", "1.0.0.1/24"] // 添加 IP 或 CIDR 到 cn 类别 } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure output to a specific directory and filename, including only 'cn' and 'private' categories. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "outputName": "Country-only-cn-private.mmdb", // 输出文件名为 Country-only-cn-private.mmdb "wantedList": ["cn", "private"] // 只输出 cn、private 类别 } } ``` -------------------------------- ### Add IP Addresses from Standard Input (Basic) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses provided via standard input, assigning them to a specified category (e.g., 'cn'). This is a basic configuration for stdin input. ```jsonc { "type": "stdin", "action": "add", // 添加 IP 地址 "args": { "name": "cn" } } ``` -------------------------------- ### Configure dbipCountryMMDB Output with Overwrite List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output with 'cn' and 'google' in the 'overwriteList'. This ensures 'google' is written last, taking precedence over 'cn' for any overlapping IPs. The output file is named 'Country.mmdb'. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "overwriteList": ["cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 } } ``` -------------------------------- ### Add IPs using specified IPinfo MMDB file Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Specify a local IPinfo country MMDB file path to add IP addresses. Ensure the file exists at the provided URI. ```jsonc { "type": "ipinfoCountryMMDB", "action": "add", // 添加 IP 地址 "args": { "uri": "./ipinfo/country.mmdb" } } ``` -------------------------------- ### Configure Default stdout Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'stdout' type to output all GeoIP categories to the standard output. No specific arguments are provided, so all data will be included. ```jsonc { "type": "stdout", "action": "output" // 输出所有类别到 standard output } ``` -------------------------------- ### Clash RuleSet Output with Custom Directory and Extension Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure the output for Clash rule sets to a custom directory and specify a '.yaml' file extension. This allows for organized storage of generated rules. ```json { "type": "clashRuleSet", "action": "output", "args": { "outputDir": "./clash/ipcidr", // 输出文件到目录 ./clash/ipcidr "outputExtension": ".yaml" // 输出文件的扩展名为 .yaml } } ``` -------------------------------- ### Add IPs using default IPinfo MMDB Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this configuration to add IP addresses using the default IPinfo country MMDB file located at ./ipinfo/country.mmdb. ```jsonc { "type": "ipinfoCountryMMDB", "action": "add" // 添加 IP 地址 } ``` -------------------------------- ### Add IP Addresses using singboxSRS (Directory Scan with Specific Categories and IP Type) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses by scanning a directory for singbox SRS files. It processes only specified files (e.g., 'cn', 'us', 'jp') and targets only IPv6 addresses. ```jsonc { "type": "singboxSRS", "action": "add", // 添加 IP 地址 "args": { "inputDir": "./singbox/srs", // 遍历 ./singbox/srs 目录内的所有文件(不遍历子目录) "wantedList": ["cn", "us", "jp"], // 只需要 ./singbox/srs 目录内文件名去除扩展名后,名为 cn、us、jp 的文件 "onlyIPType": "ipv6" // 只添加 IPv6 地址 } } ``` -------------------------------- ### Configure dbipCountryMMDB Output with Excluded and Overwrite Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output to exclude 'private' and use 'cn' and 'google' in the 'overwriteList'. 'google' will be written last. The output file is named 'Country.mmdb'. 'private' is excluded despite being in the overwrite list. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "overwriteList": ["private" ,"cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### Add All IPs with Default ASN Categories Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds all IP addresses, automatically categorizing them by ASN. Category names are prefixed with 'AS'. ```json // Default use files: // ./geolite2/GeoLite2-ASN-Blocks-IPv4.csv // ./geolite2/GeoLite2-ASN-Blocks-IPv6.csv { "type": "maxmindGeoLite2ASNCSV", "action": "add" } ``` -------------------------------- ### Add IPs using default DB-IP MMDB Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this configuration to add IP addresses using the default DB-IP country MMDB file located at ./db-ip/dbip-country-lite.mmdb. ```jsonc { "type": "dbipCountryMMDB", "action": "add" // 添加 IP 地址 } ``` -------------------------------- ### Add IP Addresses using MaxMind MMDB (Default) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses using the default MaxMind GeoLite2 Country mmdb file. No specific URI is provided, so the system uses a default path. ```jsonc // 默认使用文件: // ./geolite2/GeoLite2-Country.mmdb { "type": "maxmindMMDB", "action": "add" // 添加 IP 地址 } ``` -------------------------------- ### Mihomo GeoIP Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/README.md Enable GeoIP functionality in mihomo and specify the URL for downloading the GeoIP .dat file. This allows for GeoIP-based routing. ```yaml geodata-mode: true geox-url: geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat" ``` -------------------------------- ### Configure dbipCountryMMDB Output with Source MMDB URI Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output with 'cn' and 'google' in the 'overwriteList' and specifies a source MMDB file for additional information. 'private' is excluded. The output file is named 'Country.mmdb'. Note that 'private' and 'google' categories cannot be enriched as they are not country-related. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "overwriteList": ["private" ,"cn", "google"], "sourceMMDBURI": "./db-ip/dbip-country-lite.mmdb" // 用于补全生成的 MMDB 格式文件额外信息的 DB-IP 官方 country MMDB 格式文件。由于 private、google 类别不属于国家/地区类别,无法补全额外信息。 } } ``` -------------------------------- ### Default ipinfoCountryMMDB Output Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This snippet shows the default configuration for outputting data in the ipinfoCountryMMDB format. The output directory defaults to './output/ipinfo'. ```json { "type": "ipinfoCountryMMDB", "action": "output" } ``` -------------------------------- ### Add IP Addresses using mihomoMRS (Directory Scan with Specific Categories and IP Type) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses by scanning a directory for mihomo MRS files. It processes only specified files (e.g., 'cn', 'us', 'jp') and targets only IPv6 addresses. ```jsonc { "type": "mihomoMRS", "action": "add", // 添加 IP 地址 "args": { "inputDir": "./mihomo/mrs", // 遍历 ./mihomo/mrs 目录内的所有文件(不遍历子目录) "wantedList": ["cn", "us", "jp"], // 只需要 ./mihomo/mrs 目录里文件名去除扩展名后,名为 cn、us、jp 的文件 "onlyIPType": "ipv6" // 只添加 IPv6 地址 } } ``` -------------------------------- ### Add IPs using specified DB-IP MMDB file Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Specify a local DB-IP country MMDB file path to add IP addresses. Ensure the file exists at the provided URI. ```jsonc { "type": "dbipCountryMMDB", "action": "add", // 添加 IP 地址 "args": { "uri": "./db-ip/dbip-country-lite.mmdb" } } ``` -------------------------------- ### Add IPs from Local File using Surge Ruleset Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this snippet to add IP addresses from a local file to a Surge ruleset category. Ensure the 'uri' points to a valid local file. ```jsonc { "type": "surgeRuleSet", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "uri": "./cn.txt" // 读取本地文件 cn.txt 的 IPv4 和 IPv6 地址,并添加到 cn 类别中 } } ``` -------------------------------- ### Trojan-Go GeoIP Router Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/README.md Configure the GeoIP router in Trojan-Go to enable GeoIP-based routing. Specify bypass, proxy, and block lists using GeoIP tags and set the default policy. Ensure the geoip.dat file is in the program directory. ```json "router": { "enabled": true, "bypass": ["geoip:cn"], "proxy": ["geoip:telegram", "geoip:us"], "block": ["geoip:jp"], "default_policy": "proxy", "geoip": "./geoip.dat" } ``` -------------------------------- ### Add IP Addresses using singboxSRS (Local File) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses from a local singbox SRS format file, assigning them to a specified category (e.g., 'cn'). This processes both IPv4 and IPv6 addresses from the file. ```jsonc { "type": "singboxSRS", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "uri": "./cn.srs" // 读取本地文件 cn.srs 的 IPv4 和 IPv6 地址,并添加到 cn 类别中 } } ``` -------------------------------- ### Add Specific Categories and IP Types from Local GeoIP Dat File Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure to add specific categories (e.g., 'cn', 'us', 'jp') and only IPv6 addresses from a local geoip.dat file. ```json { "type": "v2rayGeoIPDat", "action": "add", // 添加 IP 地址 "args": { "uri": "./geoip.dat", // 读取本地文件 geoip.dat 中的类别 "wantedList": ["cn", "us", "jp"], // 只需要 geoip.dat 中名为 cn、us、jp 的类别 "onlyIPType": "ipv6" // 只添加 IPv6 地址 } } ``` -------------------------------- ### Configure dbipCountryMMDB Output with Excluded and Wanted Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output to exclude 'private' but include 'au' and 'cloudflare'. 'cloudflare' will be written last among the wanted lists. The output file is named 'Country.mmdb'. Note that 'private' is excluded despite being in the wanted list. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "wantedList": ["private" ,"au", "cloudflare"] // 只输出 au、cloudflare 类别,并确保 cloudflare 比 au 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Overwrite List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Specify an output filename and use 'overwriteList' to ensure 'cn' and 'google' categories are written last, with 'google' having the highest priority. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "overwriteList": ["cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 } } ``` -------------------------------- ### Configure text Output with Excluded List and Prefix Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'text' type to output GeoIP data, excluding 'cn', 'us', and 'jp' categories. It specifies a custom directory, '.conf' extension, and 'HOST,' as a prefix for each line. ```jsonc { "type": "text", "action": "output", "args": { "outputDir": "./text", // 输出文件到目录 ./text "outputExtension": ".conf", // 输出文件的扩展名为 .conf "excludedList": ["cn", "us", "jp"], // 不输出名为 cn、us、jp 这三个类别的 IPv4 和 IPv6 地址 "addPrefixInLine": "HOST," } } ``` -------------------------------- ### V2Ray/Xray-core GeoIP Routing Rules Source: https://github.com/loyalsoldier/geoip/blob/master/README.md Configure routing rules in V2Ray or Xray-core to direct traffic based on GeoIP data, including country-specific and private IP addresses. Ensure .dat files are in the program directory. ```json "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" ] } ] } ``` -------------------------------- ### Lookup IP Address Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This snippet demonstrates how to configure a lookup operation to find the category for a specific IP address. ```json { "type": "lookup", "action": "output", "args": { "search": "1.1.1.1" // 查询 IP 地址 1.1.1.1 所在的类别 } } ``` -------------------------------- ### Configure dbipCountryMMDB Output with Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output to include only 'cn' and 'private' categories. The output file is named 'Country-only-cn-private.mmdb' and placed in the './output' directory. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "outputName": "Country-only-cn-private.mmdb", // 输出文件名为 Country-only-cn-private.mmdb "wantedList": ["cn", "private"] // 只输出 cn、private 类别 } } ``` -------------------------------- ### Clash RuleSet Classical Output with Custom Directory and Extension Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure the output for classical Clash rule sets to a custom directory and specify a '.yaml' file extension. This provides flexibility in organizing generated rule files. ```json { "type": "clashRuleSetClassical", "action": "output", "args": { "outputDir": "./clash/classical", // 输出文件到目录 ./clash/classical "outputExtension": ".yaml" // 输出文件的扩展名为 .yaml } } ``` -------------------------------- ### Configure Default singboxSRS Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this configuration to output GeoIP data using the singboxSRS format with default settings. The output directory defaults to './output/srs'. ```jsonc { "type": "singboxSRS", "action": "output" } ``` -------------------------------- ### Default mihomoMRS Output Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Generates a mihomoMRS file using default settings, outputting to the default directory. ```json // 默认输出目录 ./output/mrs { "type": "mihomoMRS", "action": "output" } ``` -------------------------------- ### Add IP Addresses using mihomoMRS (Local File) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses from a local mihomo MRS format file, assigning them to a specified category (e.g., 'cn'). This processes both IPv4 and IPv6 addresses from the file. ```jsonc { "type": "mihomoMRS", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "uri": "./cn.mrs" // 读取本地文件 cn.mrs 的 IPv4 和 IPv6 地址,并添加到 cn 类别中 } } ``` -------------------------------- ### Configure stdout Output with Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'stdout' type to output only 'cn' and 'private' GeoIP categories to the standard output. Other categories will be excluded. ```jsonc { "type": "stdout", "action": "output", "args": { "wantedList": ["cn", "private"] // 只输出 cn、private 类别到 standard output } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Source MMDB URI Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure output with a specific filename, excluded and overwrite lists, and a source MMDB URI to enrich the output with additional country information. Categories not related to countries (like 'private' or 'google') cannot be enriched. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "overwriteList": ["private" ,"cn", "google"], "sourceMMDBURI": "./ipinfo/country.mmdb" // 用于补全生成的 MMDB 格式文件额外信息的 IPInfo 官方 country MMDB 格式文件。由于 private、google 类别不属于国家/地区类别,无法补全额外信息。 } } ``` -------------------------------- ### maxmindMMDB Output with Excluded and Overwrite Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Demonstrates the interaction between 'excludedList' and 'overwriteList' for maxmindMMDB output. Items in 'excludedList' are omitted, while 'overwriteList' determines the final writing order for remaining lists. ```json { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], // 最终不输出 private 类别 "overwriteList": ["private" ,"cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### Output Each Category to Separate File Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures v2rayGeoIPDat to output each GeoIP category into its own file. ```jsonc { "type": "v2rayGeoIPDat", "action": "output", "args": { "oneFilePerList": true // 每个类别输出为一个单独的文件 } } ``` -------------------------------- ### Default Clash RuleSet Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration outputs GeoIP data in Clash rule set format using default settings. The output directory will be './output/clash/ipcidr'. ```json // 默认输出目录 ./output/clash/ipcidr { "type": "clashRuleSet", "action": "output" } ``` -------------------------------- ### Default maxmindMMDB Output Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Generates a maxmindMMDB file using default settings, outputting to the default directory. ```json // 默认输出目录 ./output/maxmind { "type": "maxmindMMDB", "action": "output" } ``` -------------------------------- ### ipinfoCountryMMDB Output with Excluded and Overwrite Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration excludes 'private' and uses 'overwriteList' for 'cn' and 'google', ensuring 'google' is written last. The 'private' category is excluded due to 'excludedList'. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "overwriteList": ["private" ,"cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### Add IP Addresses using MaxMind MMDB (Local File) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses by specifying a local MaxMind GeoLite2 Country mmdb file path. This allows for custom file locations. ```jsonc { "type": "maxmindMMDB", "action": "add", // 添加 IP 地址 "args": { "uri": "./geolite2/GeoLite2-Country.mmdb" } } ``` -------------------------------- ### Configure surgeRuleSet Output with Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'surgeRuleSet' type to output GeoIP data for 'cn', 'us', and 'jp' categories, with a custom directory and '.conf' extension. Both IPv4 and IPv6 addresses are included by default. ```jsonc { "type": "surgeRuleSet", "action": "output", "args": { "outputDir": "./surge", // 输出文件到目录 ./surge "outputExtension": ".conf", // 输出文件的扩展名为 .conf "wantedList": ["cn", "us", "jp"] // 只输出名为 cn、us、jp 这三个类别的 IPv4 和 IPv6 地址 } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Excluded and Wanted Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration excludes 'private' but includes 'au' and 'cloudflare', ensuring 'cloudflare' is written after 'au'. Note that 'private' is excluded despite being in the wanted list due to the higher priority of 'excludedList'. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], "wantedList": ["private" ,"au", "cloudflare"] // 只输出 au、cloudflare 类别,并确保 cloudflare 比 au 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### maxmindMMDB Output with Source MMDB URI Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures maxmindMMDB output, including an 'overwriteList' and a 'sourceMMDBURI' to supplement the generated MMDB file with additional information from an official MaxMind file. Note that non-country categories cannot be supplemented. ```json { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], // 最终不输出 private 类别 "overwriteList": ["private" ,"cn", "google"], // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 "sourceMMDBURI": "./geolite2/GeoLite2-Country.mmdb" // 用于补全生成的 MMDB 格式文件额外信息的 Maxmind 官方 country MMDB 格式文件。由于 private、google 类别不属于国家/地区类别,无法补全额外信息。 } } ``` -------------------------------- ### Configure text Output for IPv4 Only with Suffix Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'text' type to output only IPv4 addresses for 'cn', 'us', and 'jp' categories. It specifies a custom directory, '.conf' extension, and a semicolon ';' as a suffix for each line. ```jsonc { "type": "text", "action": "output", "args": { "outputDir": "./text", // 输出文件到目录 ./text "outputExtension": ".conf", // 输出文件的扩展名为 .conf "wantedList": ["cn", "us", "jp"], // 只输出名为 cn、us、jp 这三个类别的 IPv4 地址 "onlyIPType": "ipv4", "addSuffixInLine": ";" } } ``` -------------------------------- ### Add IPs from Local File with Prefix/Suffix Removal using Text Input Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This snippet adds IP addresses from a local text file to a category, with options to remove specified prefixes and suffixes from each line before processing. ```jsonc { "type": "text", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "uri": "./cn.txt", // 读取本地文件 cn.txt 的 IPv4 和 IPv6 地址,并添加到 cn 类别中 "removePrefixesInLine": ["Host,", "IP-CIDR"], // 从读取的文件中移除多种不同的行前缀 "removeSuffixesInLine": [",no-resolve"] // 从读取的文件中移除行后缀 } } ``` -------------------------------- ### Default dbipCountryMMDB Output Configuration Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This is the default configuration for the dbipCountryMMDB output type. It specifies the type and action, with the output directory defaulting to './output/db-ip'. ```json { "type": "dbipCountryMMDB", "action": "output" } ``` -------------------------------- ### Configure singboxSRS Output for IPv4 Only Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the singboxSRS format to output only IPv4 addresses. The output directory is not specified, so it will use the default. ```jsonc { "type": "singboxSRS", "action": "output", "args": { "onlyIPType": "ipv4" // 只输出 IPv4 地址 } } ``` -------------------------------- ### Configure singboxSRS Output with Specific Directory and Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration specifies a custom output directory and filters the output to include only 'cn' and 'private' categories when using the singboxSRS format. ```jsonc { "type": "singboxSRS", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "wantedList": ["cn", "private"] // 只输出 cn、private 类别 } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Excluded List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure output to a specific directory and filename, excluding 'cn' and 'private' categories. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "outputName": "Country-without-cn-private.mmdb", // 输出文件名为 Country-without-cn-private.mmdb "excludedList": ["cn", "private"] } } ``` -------------------------------- ### Add IPs or CIDRs using Text Input Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this to add individual IP addresses or CIDR blocks directly to a category using the text input type. ```jsonc { "type": "text", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "ipOrCIDR": ["1.0.0.1", "1.0.0.1/24"] // 添加 IP 或 CIDR 到 cn 类别 } } ``` -------------------------------- ### Default Clash RuleSet Classical Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration outputs GeoIP data in the classical Clash rule set format using default settings. The output directory will be './output/clash/classical'. ```json // 默认输出目录 ./output/clash/classical { "type": "clashRuleSetClassical", "action": "output" } ``` -------------------------------- ### Configure surgeRuleSet Output for IPv4 Only with Wanted List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'surgeRuleSet' type to output only IPv4 addresses for 'cn', 'us', and 'jp' categories. It specifies a custom output directory and '.conf' extension. ```jsonc { "type": "surgeRuleSet", "action": "output", "args": { "outputDir": "./surge", // 输出文件到目录 ./surge "outputExtension": ".conf", // 输出文件的扩展名为 .conf "wantedList": ["cn", "us", "jp"], // 只输出名为 cn、us、jp 这三个类别的 IPv4 地址 "onlyIPType": "ipv4" } } ``` -------------------------------- ### Output Specific Categories with IPv4 Type and Separate Files Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Filters for 'telegram' and 'google' categories, outputs only their IPv4 addresses, and creates a separate file for each category. ```jsonc { "type": "v2rayGeoIPDat", "action": "output", "args": { "wantedList": ["telegram", "google"], // 只输出 telegram、google "onlyIPType": "ipv4", // 只输出 telegram、google 类别的 IPv4 地址 "oneFilePerList": true // 每个类别输出为一个单独的文件 } } ``` -------------------------------- ### maxmindMMDB Output with Excluded and Wanted Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Combines 'excludedList' and 'wantedList' for maxmindMMDB output. 'excludedList' takes precedence, and 'wantedList' determines the final included lists, with the last item having priority. ```json { "type": "maxmindMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "excludedList": ["private"], // 最终不输出 private 类别 "wantedList": ["private" ,"au", "cloudflare"] // 只输出 au、cloudflare 类别,并确保 cloudflare 比 au 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 } } ``` -------------------------------- ### Configure dbipCountryMMDB Output with Excluded List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures the dbipCountryMMDB output to exclude 'cn' and 'private' categories. The output file is named 'Country-without-cn-private.mmdb' and placed in the './output' directory. ```json { "type": "dbipCountryMMDB", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "outputName": "Country-without-cn-private.mmdb", // 输出文件名为 Country-without-cn-private.mmdb "excludedList": ["cn", "private"] } } ``` -------------------------------- ### mihomoMRS Output with Specific Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures mihomoMRS output to include only specified lists ('cn', 'private') and directs output to a specific directory. ```json { "type": "mihomoMRS", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "wantedList": ["cn", "private"] // 只输出 cn、private 类别 } } ``` -------------------------------- ### Add IPs using Default GeoLite2 ASN CSV Files Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses to categories based on ASN. Uses default local CSV files if not specified. ```json // Default use files: // ./geolite2/GeoLite2-ASN-Blocks-IPv4.csv // ./geolite2/GeoLite2-ASN-Blocks-IPv6.csv { "type": "maxmindGeoLite2ASNCSV", "action": "add", "args": { "wantedList": { "facebook": ["AS63293", "AS54115", "AS32934"], "fastly": ["AS54113", "AS394192"] } } } ``` -------------------------------- ### Add IPs from a remote JSON file with specific path Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Add IP addresses from a remote JSON file. Specify the category name, the file URI, and the JSONPath to extract the IP addresses. ```jsonc { "type": "json", "action": "add", // 添加 IP 地址 "args": { "name": "fastly", "uri": "https://api.fastly.com/public-ip-list", "jsonPath": ["addresses", "ipv6_addresses"] } } ``` -------------------------------- ### maxmindMMDB Output with Specific Lists Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configures maxmindMMDB output to include only specified lists ('cn', 'private') and directs output to a specific directory and filename. ```json { "type": "maxmindMMDB", "action": "output", "args": { "outputDir": "./output", // 输出文件到 output 目录 "outputName": "Country-only-cn-private.mmdb", // 输出文件名为 Country-only-cn-private.mmdb "wantedList": ["cn", "private"] // 只输出 cn、private 类别 } } ``` -------------------------------- ### ipinfoCountryMMDB Output with Overwrite and IP Type Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Configure output with a specific filename, overwrite list, and filter for IPv4 addresses only. ```json { "type": "ipinfoCountryMMDB", "action": "output", "args": { "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb "overwriteList": ["cn", "google"], // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 "onlyIPType": "ipv4" // 只输出 cn、private 类别的 IPv4 地址 } } ``` -------------------------------- ### Clash RuleSet Classical Output with Specific Wanted Categories Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Generate classical Clash rule sets including only specified categories (e.g., 'cn', 'us', 'jp'). Both IPv4 and IPv6 addresses for these categories will be included. ```json { "type": "clashRuleSetClassical", "action": "output", "args": { "outputDir": "./clash/classical", // 输出文件到目录 ./clash/classical "outputExtension": ".yaml", // 输出文件的扩展名为 .yaml "wantedList": ["cn", "us", "jp"] // 只输出名为 cn、us、jp 这三个类别的 IPv4 和 IPv6 地址 } } ``` -------------------------------- ### Add IPs from Directory with Prefix/Suffix Removal using Text Input Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This snippet adds IP addresses from files within a specified directory to categories, with options to remove prefixes and suffixes from lines and filter by IP type. ```jsonc { "type": "text", "action": "add", // 添加 IP 地址 "args": { "inputDir": "./text", // 遍历 ./text 目录内的所有文件(不遍历子目录) "wantedList": ["cn", "us", "jp"], // 只需要 ./text 目录里文件名去除扩展名后,名为 cn、us、jp 的文件 "onlyIPType": "ipv6", // 只添加 IPv6 地址 "removePrefixesInLine": ["Host,", "IP-CIDR"], // 从读取的文件中移除多种不同的行前缀 "removeSuffixesInLine": [",no-resolve"] // 从读取的文件中移除行后缀 } } ``` -------------------------------- ### Configure stdout Output for IPv4 Only Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'stdout' type to output only IPv4 addresses to the standard output. No specific categories are filtered. ```jsonc { "type": "stdout", "action": "output", "args": { "onlyIPType": "ipv4" // 只输出 IPv4 地址到 standard output } } ``` -------------------------------- ### Add IP Addresses from Local GeoIP Dat File Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Use this snippet to add IP addresses from a local .dat file. It reads all categories and IP types from the specified file. ```json { "type": "v2rayGeoIPDat", "action": "add", // 添加 IP 地址 "args": { "uri": "./cn.dat" // 读取本地文件 cn.dat 中的类别、IPv4 和 IPv6 地址 } } ``` -------------------------------- ### Add IPs from Directory using Surge Ruleset Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This snippet adds IP addresses from files within a specified directory to categories based on filenames. It supports filtering by IP type and selecting specific files using 'wantedList'. ```jsonc { "type": "surgeRuleSet", "action": "add", // 添加 IP 地址 "args": { "inputDir": "./surge", // 遍历 ./surge 目录内的所有文件(不遍历子目录) "wantedList": ["cn", "us", "jp"], // 只需要 ./surge 目录内文件名去除扩展名后,名为 cn、us、jp 的文件 "onlyIPType": "ipv6" // 只添加 IPv6 地址 } } ``` -------------------------------- ### Add IPv4 IPs with Default ASN Categories Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds only IPv4 addresses, automatically categorizing them by ASN. Category names are prefixed with 'AS'. ```json // Default use files: // ./geolite2/GeoLite2-ASN-Blocks-IPv4.csv // ./geolite2/GeoLite2-ASN-Blocks-IPv6.csv { "type": "maxmindGeoLite2ASNCSV", "action": "add", "args": { "onlyIPType": "ipv4" } } ``` -------------------------------- ### Default v2rayGeoIPDat Output Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Outputs all GeoIP categories to the default directory './output/dat'. ```jsonc // 默认输出目录 ./output/dat { "type": "v2rayGeoIPDat", "action": "output" // 输出全部类别 } ``` -------------------------------- ### Add IP Addresses from Standard Input (Specific IP Type) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses provided via standard input to a specified category (e.g., 'cn'), but only processes IPv6 addresses. ```jsonc { "type": "stdin", "action": "add", // 添加 IP 地址 "args": { "name": "cn", "onlyIPType": "ipv6" // 只添加 IPv6 地址 } } ``` -------------------------------- ### Add IP Addresses using MaxMind MMDB (Remote File with Specific Categories and IP Type) Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Adds IP addresses from a remote MaxMind GeoLite2 Country mmdb file, filtering for specific categories (e.g., 'cn', 'us', 'jp') and only processing IPv4 addresses. ```jsonc { "type": "maxmindMMDB", "action": "add", // 添加 IP 地址 "args": { "uri": "https://example.com/my.mmdb", "wantedList": ["cn", "us", "jp"], // 只需要名为 cn、us、jp 的类别 "onlyIPType": "ipv4" // 只添加 IPv4 地址 } } ``` -------------------------------- ### Configure stdout Output with Excluded List Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md This configuration uses the 'stdout' type to output GeoIP data to standard output, excluding 'cn' and 'private' categories. All other categories will be included. ```jsonc { "type": "stdout", "action": "output", "args": { "excludedList": ["cn", "private"] // 不输出 cn、private 类别到 standard output } } ``` -------------------------------- ### Clash RuleSet Output with Specific Wanted Categories Source: https://github.com/loyalsoldier/geoip/blob/master/configuration.md Generate Clash rule sets including only specified categories (e.g., 'cn', 'us', 'jp'). Both IPv4 and IPv6 addresses for these categories will be included. ```json { "type": "clashRuleSet", "action": "output", "args": { "outputDir": "./clash/ipcidr", // 输出文件到目录 ./clash/ipcidr "outputExtension": ".yaml", // 输出文件的扩展名为 .yaml "wantedList": ["cn", "us", "jp"] // 只输出名为 cn、us、jp 这三个类别的 IPv4 和 IPv6 地址 } } ```