Convert Figma logo to code with AI

Loyalsoldier logov2ray-rules-dat

🦄 🎃 👻 V2Ray 路由规则文件加强版,可代替 V2Ray 官方 geoip.dat 和 geosite.dat,适用于 V2Ray、Xray-core、mihomo(Clash-Meta)、hysteria、Trojan-Go 和 leaf。Enhanced edition of V2Ray rules dat files, applicable to V2Ray, Xray-core, mihomo(Clash-Meta), hysteria, Trojan-Go and leaf.

14,574
1,680
14,574
6

Top Related Projects

Community managed domain list

搜集、整理、维护 Surge / Quantumult (X) / Shadowrocket / Surfboard / clash (Premium) 实用规则。

提供多款 Shadowrocket 规则,带广告过滤功能。用于 iOS 未越狱设备选择性地自动翻墙。

3,266

SSR 去广告ACL规则/SS完整GFWList规则/Clash规则碎片,Telegram频道订阅地址

Quick Overview

Loyalsoldier/v2ray-rules-dat is a project that provides enhanced rule sets and domain lists for V2Ray, a popular platform for building proxies to bypass network restrictions. It offers regularly updated, comprehensive lists of domains, IP addresses, and routing rules to improve V2Ray's performance and effectiveness in various network environments.

Pros

  • Frequently updated rule sets and domain lists
  • Comprehensive coverage of popular websites and services
  • Easy integration with V2Ray configuration
  • Community-driven project with active maintenance

Cons

  • Requires manual updates or additional scripts for automatic updates
  • May include unnecessary rules for some users' specific needs
  • Potential for false positives or negatives in domain categorization
  • Dependency on external sources for some rule sets

Getting Started

To use Loyalsoldier/v2ray-rules-dat with V2Ray:

  1. Download the latest release files from the GitHub repository.
  2. Update your V2Ray configuration to include the downloaded rule sets.
  3. Add the following to your V2Ray configuration file:
{
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "outboundTag": "proxy",
        "domain": [
          "geosite:category-ads-all",
          "geosite:cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:private",
          "geosite:apple-cn",
          "geosite:google-cn"
        ]
      }
    ]
  }
}
  1. Restart V2Ray to apply the new configuration.

For automatic updates, consider setting up a cron job or scheduled task to download the latest rule sets periodically.

Competitor Comparisons

Community managed domain list

Pros of domain-list-community

  • More comprehensive domain list with broader coverage
  • Community-driven approach allows for frequent updates and contributions
  • Integrated with the official V2Ray project, ensuring compatibility

Cons of domain-list-community

  • Less focused on specific rule sets for different regions or use cases
  • May require more manual configuration for optimal performance
  • Larger file size due to extensive domain listings

Code Comparison

v2ray-rules-dat:

include:category-ads-all
include:category-porn
domain:example.com
full:www.example.com

domain-list-community:

# Domain list for Category
include:category-ads
include:category-social-media
domain:example.org
regexp:^(www\.)?example\.(com|net)$

The code snippets show that v2ray-rules-dat uses a more straightforward approach with specific categories and domain types, while domain-list-community employs a more flexible system with regular expressions and broader category inclusions.

Both repositories serve as valuable resources for V2Ray users, with v2ray-rules-dat offering a more curated and optimized experience, while domain-list-community provides a comprehensive and community-driven approach to domain categorization.

搜集、整理、维护 Surge / Quantumult (X) / Shadowrocket / Surfboard / clash (Premium) 实用规则。

Pros of SS-Rule-Snippet

  • More comprehensive rule sets covering various scenarios and platforms
  • Includes Surge-specific configurations and optimizations
  • Offers more granular control over traffic routing

Cons of SS-Rule-Snippet

  • Less frequent updates compared to v2ray-rules-dat
  • Larger file sizes due to more extensive rule sets
  • May require more manual configuration and tweaking

Code Comparison

SS-Rule-Snippet:

DOMAIN-SUFFIX,googleapis.cn,🍎 Only
DOMAIN-SUFFIX,mzstatic.com,🍎 Only
DOMAIN-SUFFIX,akadns.net,🍎 Only
DOMAIN-SUFFIX,icloud.com,🍎 Only
DOMAIN-SUFFIX,icloud-content.com,🍎 Only

v2ray-rules-dat:

apple.com
icloud.com
cdn-apple.com
apple-cloudkit.com
apple-mapkit.com

The code snippets show different approaches to rule definition. SS-Rule-Snippet uses more specific DOMAIN-SUFFIX rules with associated actions, while v2ray-rules-dat employs a simpler domain list format.

Both repositories aim to provide rule sets for traffic routing and filtering in various proxy tools, but they differ in their focus, update frequency, and rule structure. Users should choose based on their specific needs, preferred proxy software, and desired level of customization.

提供多款 Shadowrocket 规则,带广告过滤功能。用于 iOS 未越狱设备选择性地自动翻墙。

Pros of Shadowrocket-ADBlock-Rules

  • Specifically designed for Shadowrocket, offering optimized performance for iOS devices
  • Includes a wider range of rule categories, including adult content blocking and social media filters
  • More frequent updates, ensuring up-to-date blocking of new ad domains and trackers

Cons of Shadowrocket-ADBlock-Rules

  • Limited compatibility with other proxy tools, primarily focused on Shadowrocket
  • Less granular control over rule selection compared to v2ray-rules-dat
  • Smaller community and fewer contributors, potentially leading to slower issue resolution

Code Comparison

Shadowrocket-ADBlock-Rules:

DOMAIN-SUFFIX,googleapis.cn,🍎 Only
DOMAIN-SUFFIX,mzstatic.com,🍎 Only
DOMAIN-SUFFIX,akadns.net,🍎 Only

v2ray-rules-dat:

apple.com
icloud.com
cdn-apple.com
apple-cloudkit.com

The code snippets show different approaches to rule definition. Shadowrocket-ADBlock-Rules uses more specific domain matching with additional proxy information, while v2ray-rules-dat employs a simpler domain list format.

3,266

SSR 去广告ACL规则/SS完整GFWList规则/Clash规则碎片,Telegram频道订阅地址

Pros of ACL4SSR

  • More comprehensive rule sets, including specialized lists for different purposes
  • Frequent updates and active community contributions
  • Includes additional tools and scripts for rule management

Cons of ACL4SSR

  • May be overly complex for users seeking simpler configurations
  • Some rule sets might be region-specific, potentially less relevant for global users
  • Larger file sizes due to extensive rule coverage

Code Comparison

v2ray-rules-dat:

geoip:cn
geoip:private
domain:example.com

ACL4SSR:

[Rule]
DOMAIN-SUFFIX,example.com,DIRECT
IP-CIDR,192.168.0.0/16,DIRECT
GEOIP,CN,DIRECT

Both repositories provide rule sets for network traffic management, but ACL4SSR offers more detailed and customizable configurations. v2ray-rules-dat focuses on simplicity and efficiency, while ACL4SSR provides a wider range of options for advanced users. The code comparison shows that ACL4SSR uses a more structured format with explicit rule types, whereas v2ray-rules-dat employs a more concise syntax. Users should choose based on their specific needs and technical expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

简介

V2Ray 路由规则文件加强版,可代替 V2Ray 官方 geoip.dat 和 geosite.dat,适用于 V2Ray、Xray-core、mihomo、hysteria、Trojan-Go、leaf。使用 GitHub Actions 北京时间每天早上 6 点自动构建,保证规则最新。

规则文件生成方式

geoip.dat

  • 通过仓库 @Loyalsoldier/geoip 生成
  • 默认使用 MaxMind GeoLite2 Country CSV 数据生成各个国家和地区的 GeoIP 文件。所有可供使用的国家和地区 geoip 类别(如 geoip:cn,两位英文字母表示国家或地区),请查看:https://www.iban.com/country-codes
  • 中国大陆 (geoip:cn) IPv4 地址数据融合了 IPIP.net 和 @gaoyifan/china-operator-ip
  • 中国大陆 (geoip:cn) IPv6 地址数据融合了 MaxMind GeoLite2 和 @gaoyifan/china-operator-ip
  • 新增类别(方便有特殊需求的用户使用):
    • geoip:cloudflare
    • geoip:cloudfront
    • geoip:facebook
    • geoip:fastly
    • geoip:google
    • geoip:netflix
    • geoip:telegram
    • geoip:twitter

希望定制 geoip.dat 文件?需要适用于其他代理软件的 GeoIP 格式文件?查看项目 @Loyalsoldier/geoip。

geosite.dat

  • 基于 @v2fly/domain-list-community/data 数据,通过仓库 @Loyalsoldier/domain-list-custom 生成
  • 加入大量中国大陆域名、Apple 域名和 Google 域名:
  • 加入 GFWList 域名:
    • 基于 @gfwlist/gfwlist 数据,通过仓库 @cokebar/gfwlist2dnsmasq 生成
    • 加入到 geosite:gfw 类别中,供习惯于 PAC 模式并希望使用 GFWList 的用户使用
    • 同时加入到 geosite:geolocation-!cn 类别中
  • 加入 EasyList 和 EasyListChina 广告域名:通过 @AdblockPlus/EasylistChina+Easylist.txt 获取并加入到 geosite:category-ads-all 类别中
  • 加入 AdGuard DNS Filter 广告域名:通过 @AdGuard/DNS-filter 获取并加入到 geosite:category-ads-all 类别中
  • 加入 Peter Lowe 广告和隐私跟踪域名:通过 @PeterLowe/adservers 获取并加入到 geosite:category-ads-all 类别中
  • 加入 Dan Pollock 广告域名:通过 @DanPollock/hosts 获取并加入到 geosite:category-ads-all 类别中
  • 加入 Windows 操作系统相关的系统升级和隐私跟踪域名:
  • 可添加自定义直连、代理和广告域名:由于上游域名列表更新缓慢或缺失某些域名,所以引入需要添加的域名列表。hidden 分支里的三个文件 direct.txt、proxy.txt 和 reject.txt,分别存放自定义的需要添加的直连、代理、广告域名,最终分别加入到 geosite:cn、geosite:geolocation-!cn 和 geosite:category-ads-all 类别中
  • 可移除自定义直连、代理和广告域名:由于上游域名列表存在需要被移除的域名,所以引入需要移除的域名列表。hidden 分支里的三个文件 direct-need-to-remove.txt、proxy-need-to-remove.txt 和 reject-need-to-remove.txt,分别存放自定义的需要从 direct-list(直连域名列表)、proxy-list(代理域名列表)和 reject-list(广告域名列表) 移除的域名

规则文件下载地址

如果无法访问域名 raw.githubusercontent.com,可以使用第二个地址 cdn.jsdelivr.net。 如果无法访问域名 cdn.jsdelivr.net,可以将其替换为 fastly.jsdelivr.net。

*.sha256sum 为校验文件。

规则文件使用方式

geoip.dat

点击查看在 V2Ray 和 Xray-core 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在程序目录内。

"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"
      ]
    }
  ]
}
点击查看在 mihomo 中的使用方法
geodata-mode: true
geox-url:
  geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat"
点击查看在 hysteria 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在 hysteria 程序目录内。

direct(geoip:cn)
proxy(geoip:telegram)
proxy(geoip:us)
点击查看在 Trojan-Go 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在 Trojan-Go 程序目录内。

"router": {
  "enabled": true,
  "bypass": ["geoip:cn"],
  "proxy": ["geoip:telegram", "geoip:us"],
  "block": ["geoip:jp"],
  "default_policy": "proxy",
  "geoip": "./geoip.dat"
}

geosite.dat

跟 V2Ray 官方 geosite.dat 配置方式相同。相比官方 geosite.dat 文件,本项目特有的类别:

  • geosite:china-list:包含 @felixonmars/dnsmasq-china-list/accelerated-domains.china.conf 文件里的域名,供有特殊 DNS 分流需求的用户使用。
  • geosite:apple-cn:包含 @felixonmars/dnsmasq-china-list/apple.china.conf 文件里的域名,供希望 Apple 域名直连(不走代理)的用户使用。
  • geosite:google-cn:包含 @felixonmars/dnsmasq-china-list/google.china.conf 文件里的域名,供希望 Google 域名直连(不走代理)的用户使用。
  • [慎用]geosite:win-spy:包含 @crazy-max/WindowsSpyBlocker/hosts/spy.txt 文件里的域名,供希望屏蔽 Windows 操作系统隐私跟踪域名的用户使用。
  • [慎用]geosite:win-update:包含 @crazy-max/WindowsSpyBlocker/hosts/update.txt 文件里的域名,供希望屏蔽 Windows 操作系统自动升级的用户使用。
  • [慎用]geosite:win-extra:包含 @crazy-max/WindowsSpyBlocker/hosts/extra.txt 文件里的域名,供希望屏蔽 Windows 操作系统附加隐私跟踪域名的用户使用。

⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 geosite:apple-cn 和 geosite:google-cn 要放置在 geosite:geolocation-!cn 前(上)面才能生效。

高级用法

v2fly/domain-list-community 项目 data 目录中某些列表里的规则会被标记诸如 @cn 的 attribute(如下所示),意为该域名在中国大陆有接入点,可直连。

steampowered.com.8686c.com @cn
steamstatic.com.8686c.com @cn

对于玩 Steam 国区游戏,想要直连的用户,可以设置类别 geosite:steam@cn 为直连,意为将 steam 列表内所有被标记了 @cn attribute 的规则(域名)设置为直连。同理,由于 category-games 列表包含了 steam、ea、blizzard、epicgames 和 nintendo 等常见的游戏厂商。设置类别 geosite:category-games@cn 为直连,即可节省大量服务器流量。

⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 geosite:category-games@cn 等所有带有 @cn attribute 的规则都要放置在 geosite:geolocation-!cn 前(上)面才能生效。

category-games 列表内的规则(域名)可能会有疏漏,请留意规则命中情况。如发现遗漏,欢迎到项目 v2fly/domain-list-community 提 issue 反馈。

配置参考下面 👇👇👇

白名单模式 Routing 配置方式:

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Reject",
      "domain": ["geosite:category-ads-all"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "domain": [
        "geosite:private",
        "geosite:apple-cn",
        "geosite:google-cn",
        "geosite:tld-cn",
        "geosite:category-games@cn"
      ]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "domain": ["geosite:geolocation-!cn"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "domain": ["geosite:cn"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "network": "tcp,udp"
    }
  ]
}

黑名单模式 Routing 配置方式:

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Reject",
      "domain": ["geosite:category-ads-all"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "domain": ["geosite:gfw"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "ip": ["geoip:telegram"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "network": "tcp,udp"
    }
  ]
}

DNS 配置方式:

"dns": {
  "hosts": {
    "dns.google": "8.8.8.8",
    "dns.pub": "119.29.29.29",
    "dns.alidns.com": "223.5.5.5",
    "geosite:category-ads-all": "127.0.0.1"
  },
  "servers": [
    {
      "address": "https://1.1.1.1/dns-query",
      "domains": ["geosite:geolocation-!cn"],
      "expectIPs": ["geoip:!cn"]
    },
    "8.8.8.8",
    {
      "address": "114.114.114.114",
      "port": 53,
      "domains": ["geosite:cn", "geosite:category-games@cn"],
      "expectIPs": ["geoip:cn"],
      "skipFallback": true
    },
    {
      "address": "localhost",
      "skipFallback": true
    }
  ]
}

自用 V2Ray v4 版本客户端配置(不适用于 V2Ray v5 及更新的版本)

注意事项:

  • 由于下面客户端配置的 DNS 使用了 skipFallback 选项,所以必须使用 v4.37.2 或更新版本的 V2Ray
  • 下面客户端配置使 V2Ray 在本机开启 SOCKS 代理(监听 1080 端口)和 HTTP 代理(监听 2080 端口),允许局域网内其他设备连接并使用代理
  • BT 流量统统直连(实测依然会有部分 BT 流量走代理,如果服务商禁止 BT 下载,请不要为下载软件设置代理)
  • 最后,不命中任何路由规则的请求和流量,统统走代理
  • outbounds 里的第一个大括号内的配置,即为 V2Ray 代理服务的配置。请根据自身需求进行修改,并参照 V2Ray 官网配置文档中的 配置 > Outbounds > OutboundObject 部分进行补全
{
  "log": {
    "loglevel": "warning"
  },
  "dns": {
    "hosts": {
      "dns.google": "8.8.8.8",
      "dns.pub": "119.29.29.29",
      "dns.alidns.com": "223.5.5.5",
      "geosite:category-ads-all": "127.0.0.1"
    },
    "servers": [
      {
        "address": "https://1.1.1.1/dns-query",
        "domains": ["geosite:geolocation-!cn", "geosite:google@cn"],
        "expectIPs": ["geoip:!cn"]
      },
      "8.8.8.8",
      {
        "address": "114.114.114.114",
        "port": 53,
        "domains": [
          "geosite:cn",
          "geosite:icloud",
          "geosite:category-games@cn"
        ],
        "expectIPs": ["geoip:cn"],
        "skipFallback": true
      },
      {
        "address": "localhost",
        "skipFallback": true
      }
    ]
  },
  "inbounds": [
    {
      "protocol": "socks",
      "listen": "0.0.0.0",
      "port": 1080,
      "tag": "Socks-In",
      "settings": {
        "ip": "127.0.0.1",
        "udp": true,
        "auth": "noauth"
      },
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      }
    },
    {
      "protocol": "http",
      "listen": "0.0.0.0",
      "port": 2080,
      "tag": "Http-In",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      }
    }
  ],
  "outbounds": [
    {
      //下面这行,协议类别要改为socks、shadowsocks、vmess或vless等(记得删除本行文字说明)
      "protocol": "协议类别",
      "settings": {},
      //下面这行,tag的值对应Routing里的outboundTag,这里为Proxy(记得删除本行文字说明)
      "tag": "Proxy",
      "streamSettings": {},
      "mux": {}
    },
    {
      "protocol": "dns",
      "tag": "Dns-Out"
    },
    {
      "protocol": "freedom",
      "tag": "Direct",
      "settings": {
        "domainStrategy": "UseIPv4"
      }
    },
    {
      "protocol": "blackhole",
      "tag": "Reject",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "mph",
    "rules": [
      {
        "type": "field",
        "outboundTag": "Direct",
        "protocol": ["bittorrent"]
      },
      {
        "type": "field",
        "outboundTag": "Dns-Out",
        "inboundTag": ["Socks-In", "Http-In"],
        "network": "udp",
        "port": 53
      },
      {
        "type": "field",
        "outboundTag": "Reject",
        "domain": ["geosite:category-ads-all"]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "domain": [
          "full:www.icloud.com",
          "domain:icloud-content.com",
          "geosite:google"
        ]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "domain": [
          "geosite:tld-cn",
          "geosite:icloud",
          "geosite:category-games@cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "domain": ["geosite:geolocation-!cn"]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "domain": ["geosite:cn", "geosite:private"]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "ip": ["geoip:cn", "geoip:private"]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "network": "tcp,udp"
      }
    ]
  }
}

致谢

项目 Star 数增长趋势

Stargazers over time