### Sing-box GEOIP Rules Example Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Demonstrates how to configure GEOIP rules within the sing-box client. This JSON-based configuration specifies geo-routing for 'telegram' to 'proxy' and 'cn' to 'direct'. ```json { "rules": [ { "geoip": "telegram", "outbound": "proxy" }, { "geoip": "cn", "outbound": "direct" } ] } ``` -------------------------------- ### Clash/Mihomo GEOIP Rules Example Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Illustrates the usage of GEOIP rules in Clash and Mihomo proxy clients. It shows how to route traffic based on geographical location, such as directing Telegram traffic to a proxy and CN traffic directly. ```yaml rules: - GEOIP,telegram,PROXY - GEOIP,netflix,PROXY - GEOIP,cloudflare,PROXY - GEOIP,CN,DIRECT ``` -------------------------------- ### Bash: Download GeoIP and GeoSite Database Files Source: https://context7.com/metacubex/meta-rules-dat/llms.txt This Bash script provides commands to download GeoIP and GeoSite database files in various formats (.mmdb, .dat, .db, .metadb) from GitHub releases and JSDelivr CDN. These files are essential for proxy clients to perform geo-based routing. ```bash # Download from GitHub releases (latest) curl -L -o country.mmdb https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb curl -L -o geosite.dat https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat curl -L -o geoip.dat https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat # Download from JSDelivr CDN (faster in some regions) curl -o country.mmdb https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/country.mmdb curl -o geosite.db https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.db curl -o geoip.metadb https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.metadb ``` -------------------------------- ### GitHub Actions Workflow for Daily Geo Routing Database Builds (YAML) Source: https://context7.com/metacubex/meta-rules-dat/llms.txt An automated daily build workflow for fetching, processing, and publishing geo routing databases. It outlines the key steps: fetching domain lists, removing redundancy, building .dat files, converting formats, uploading to releases, and pushing to specialized branches. The workflow is triggered daily and can also be run manually from the Actions tab. It uses environment variables for domain list URLs. ```yaml # Workflow runs daily at 6:30 AM UTC+8 # .github/workflows/run.yml # Key workflow steps: # 1. Fetch domain lists from multiple sources # 2. Remove redundant domains # 3. Build geosite.dat and geoip.dat files # 4. Convert to multiple formats (.db, .metadb, rule-set) # 5. Upload to GitHub releases # 6. Push to specialized branches (release, sing, meta) # Trigger manual build: # Go to Actions tab -> Build rules dat files -> Run workflow # Environment variables used: env: CHINA_DOMAINS_URL: https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.txt CUSTOM_PROXY: https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/geolocation-!cn.txt # Build process: # - Checkout multiple repositories (domain-list-community, gfwlist, etc.) # - Run Python scripts to find and remove redundant domains # - Compile using Go tools # - Generate SHA256 checksums # - Purge CDN cache after upload ``` -------------------------------- ### Download and Verify Lite Geo Routing Databases (Shell) Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Downloads the lite versions of country.mmdb and geosite.dat, which are smaller and include major services for CN/JP. It also downloads the SHA256 checksum for geosite.dat and verifies the integrity of the downloaded geosite.dat file using `sha256sum`. ```shell curl -L -o country-lite.mmdb https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb curl -L -o geosite-lite.dat https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite-lite.dat curl -L -o geosite.dat.sha256sum https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat.sha256sum sha256sum -c geosite.dat.sha256sum ``` -------------------------------- ### YAML: Configure Geosite Routing Rules for Clash/Mihomo Source: https://context7.com/metacubex/meta-rules-dat/llms.txt This YAML configuration demonstrates how to set up geosite categories for advanced proxy routing in Clash and Mihomo. It defines rule providers for specific regions and integrates geosite categories like 'category-ads-all', 'cn', and service-specific domains (e.g., 'netflix') into DNS policies and routing rules. ```yaml # Mihomo/Clash Meta configuration example rule-providers: cn: behavior: domain interval: 86400 path: ./provider/rule-set/cn_domain.yaml type: http url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/cn.yaml" dns: nameserver-policy: "geosite:cn,private,apple": - https://doh.pub/dns-query - https://dns.alidns.com/dns-query "geosite:category-ads-all": rcode://success rules: # Block ads using geosite category - GEOSITE,category-ads-all,REJECT # Direct routing for Chinese domains - GEOSITE,cn,DIRECT - GEOSITE,private,DIRECT # Proxy international services - GEOSITE,youtube,PROXY - GEOSITE,google,PROXY - GEOSITE,twitter,PROXY - GEOSITE,netflix,PROXY - GEOSITE,openai,PROXY # Route by geographic location - GEOSITE,geolocation-!cn,PROXY # GeoIP rules - GEOIP,private,DIRECT,no-resolve - GEOIP,telegram,PROXY - GEOIP,CN,DIRECT - MATCH,DIRECT ``` -------------------------------- ### Sing-box Rule-Set Configuration (JSON) Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Configures sing-box proxy using remote rule-set files from the 'sing' branch of the meta-rules-dat repository. It defines three rule sets: 'geosite-cn', 'geosite-geolocation-!cn', and 'geoip-cn', specifying their types as 'remote' and format as 'binary'. The configuration then sets up routing rules to direct traffic based on these rule sets, either directly or through a proxy. ```json { "route": { "rule_set": [ { "type": "remote", "tag": "geosite-cn", "format": "binary", "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs", "download_detour": "direct" }, { "type": "remote", "tag": "geosite-geolocation-!cn", "format": "binary", "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/geolocation-!cn.srs", "download_detour": "direct" }, { "type": "remote", "tag": "geoip-cn", "format": "binary", "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/cn.srs", "download_detour": "direct" } ], "rules": [ { "rule_set": "geosite-cn", "outbound": "direct" }, { "rule_set": "geosite-geolocation-!cn", "outbound": "proxy" }, { "rule_set": "geoip-cn", "outbound": "direct" } ] } } ``` -------------------------------- ### Available GeoSite Categories (YAML Comments) Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Lists various pre-configured domain categories (GeoSite) available for use in proxy configurations. These categories cover major streaming services, social media, tech companies, gaming, geographic regions, and specialized lists like ads and trackers. Each entry is presented as a comment in YAML format, indicating the category tag. ```yaml # Major streaming services geosite:netflix # Netflix domains geosite:youtube # YouTube and related Google video services geosite:bilibili # Bilibili (Chinese video platform) geosite:biliintl # Bilibili International geosite:spotify # Spotify music streaming geosite:abema # AbemaTV (Japanese streaming) geosite:bahamut # Bahamut (Taiwanese platform) # Social media and communication geosite:telegram # Telegram messaging geosite:twitter # Twitter/X geosite:facebook # Facebook and Instagram geosite:tiktok # TikTok # Tech companies geosite:google # Google services geosite:apple # Apple services geosite:apple-cn # Apple services in China geosite:microsoft # Microsoft services geosite:microsoft@cn # Microsoft services in China geosite:github # GitHub geosite:cloudflare # Cloudflare services geosite:openai # OpenAI and ChatGPT # Gaming geosite:steam # Steam gaming platform geosite:steam@cn # Steam China region geosite:category-games@cn # Chinese game services # Geographic categories geosite:cn # Chinese domains (comprehensive) geosite:geolocation-!cn # Non-Chinese international domains geosite:private # Private/local domains geosite:gfw # Domains blocked by GFW # Specialized geosite:category-ads-all # Ad and tracking domains (for blocking) geosite:tracker # BitTorrent trackers geosite:onedrive # Microsoft OneDrive geosite:pixiv # Pixiv (Japanese art platform) geosite:ehentai # EHentai domains ``` -------------------------------- ### Python: Detect Redundant Domains Using Tree Algorithm Source: https://context7.com/metacubex/meta-rules-dat/llms.txt This Python script identifies and removes redundant subdomains from a given list. It utilizes a tree-based algorithm to determine if a parent domain already covers a child subdomain, thus marking the child as redundant. This helps in optimizing domain lists for routing rules. ```python # findRedundantDomain.py - Detect redundant domains # Usage: python findRedundantDomain.py # Example: Find redundant domains in a proxy list # Input file (proxy-domains.txt): # google.com # mail.google.com # drive.google.com # facebook.com # Command: python ./resouces/findRedundantDomain.py proxy-domains.txt removed-domains.txt # Output (removed-domains.txt): # Redundant found: mail.google.com at google.com # Redundant found: drive.google.com at google.com # removed-domains.txt will contain: # mail.google.com # drive.google.com # The script builds a domain tree from TLD to subdomain: # { 'com': { 'google': LEAF, 'facebook': LEAF } } # Any subdomain under an existing parent is marked redundant ``` -------------------------------- ### Python: Filter Domains From Master List Source: https://context7.com/metacubex/meta-rules-dat/llms.txt This Python script efficiently filters a master domain list by removing specified domains. It leverages set operations for high performance, creating a clean output list suitable for proxy routing configurations. The script takes a list of domains to remove and a source list as input. ```python # removeFrom.py - Filter domains from lists # Usage: python removeFrom.py -remove -from -out # Example: Remove unwanted domains from a proxy list # domains-to-remove.txt: # ads.example.com # tracker.example.com # source-proxy-list.txt: # google.com # facebook.com # ads.example.com # twitter.com # tracker.example.com # Command: python ./resouces/removeFrom.py -remove domains-to-remove.txt -from source-proxy-list.txt -out clean-proxy-list.txt # Output (clean-proxy-list.txt): # google.com # facebook.com # twitter.com # The script uses set operations for efficient filtering: # remaining = all_domains - domains_to_remove ``` -------------------------------- ### GeoIP ASN Categories (YAML Comments) Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Lists available GeoIP ASN (Autonomous System Number) categories, presented as comments in YAML format. These categories represent IP address ranges associated with major service providers and networks, such as cloud providers (Cloudflare, AWS CloudFront, Google Cloud), CDNs (Fastly), and large tech companies (Facebook/Meta, Netflix). ```yaml # Cloud providers and CDNs geoi p:cloudflare # Cloudflare IP ranges geoi p:cloudfront # AWS CloudFront IPs geoi p:google # Google Cloud and services geoi p:facebook # Facebook/Meta infrastructure geoi p:fastly # Fastly CDN geoi p:netflix # Netflix IP ranges ``` -------------------------------- ### Special GeoIP Categories for Bilibili and Apple Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Defines special categories for Bilibili CDN and Apple services using the 'geoip' directive. These are typically available in the lite version of the ruleset. ```plaintext geoip:bilibili # Bilibili CDN IPs geoip:apple # Apple services IPs ``` -------------------------------- ### GeoIP Definitions for Telegram and Twitter Source: https://context7.com/metacubex/meta-rules-dat/llms.txt Defines server IP addresses for Telegram and Twitter using the 'geoip' directive. This is used for geo-based routing rules in proxy clients. ```plaintext geoip:telegram # Telegram server IPs geoip:twitter # Twitter infrastructure ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.