v2fly/domain-list-community
GitHub: v2fly/domain-list-community
社区维护的 V2Ray 域名路由规则库,生成 geosite.dat 用于网络分流配置。
Stars: 7893 | Forks: 1245
# Domain list 社区
该项目管理一个域名列表,用作 Project V 中用于路由目的的 geosite。
## 项目目的
该项目不带主观色彩。换句话说,它不背书、声明或暗示某个域名应该被屏蔽或代理。它可以用于按需生成路由规则。
## 下载链接
- **dlc.dat**:[https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat](https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat)
- **dlc.dat.sha256sum**:[https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat.sha256sum](https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat.sha256sum)
- **dlc.dat_plain.yml**:[https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat_plain.yml](https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat_plain.yml)
- **dlc.dat_plain.yml.sha256sum**:[https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat_plain.yml.sha256sum](https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat_plain.yml.sha256sum)
## 注意事项
- 带有 `@!cn` 属性的规则已从 cn 列表中剔除。`geosite:geolocation-cn@!cn` 不再可用。查看 [#390](https://github.com/v2fly/domain-list-community/issues/390)、[#3119](https://github.com/v2fly/domain-list-community/pull/3119) 和 [#3198](https://github.com/v2fly/domain-list-community/pull/3198) 了解更多信息。
- 专用的非类别广告列表(如 `geosite:xxx-ads`)已被移除。请改用 `geosite:xxx@ads`。`geosite:category-ads[-xx]` 不受影响。
如有任何问题或疑问,请提交报告。
## 使用示例
`data` 目录中的每个文件都可以用作以下格式的规则:`geosite:filename`。
```
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"outboundTag": "Reject",
"domain": [
"geosite:category-ads-all",
"geosite:category-porn"
]
},
{
"type": "field",
"outboundTag": "Direct",
"domain": [
"domain:icloud.com",
"domain:icloud-content.com",
"domain:cdn-apple.com",
"geosite:cn",
"geosite:private"
]
},
{
"type": "field",
"outboundTag": "Proxy-1",
"domain": [
"geosite:category-anticensorship",
"geosite:category-media",
"geosite:category-vpnservices"
]
},
{
"type": "field",
"outboundTag": "Proxy-2",
"domain": [
"geosite:category-dev"
]
},
{
"type": "field",
"outboundTag": "Proxy-3",
"domain": [
"geosite:geolocation-!cn"
]
}
]
}
```
## 手动生成 `dlc.dat`
- 安装 `golang` 和 `git`
- 克隆项目代码:`git clone https://github.com/v2fly/domain-list-community.git`
- 进入项目根目录:`cd domain-list-community`
- 安装项目依赖:`go mod download`
- 生成 `dlc.dat`(不带 `datapath` 选项意味着使用当前工作目录下 `data` 目录中的域名列表):
- `go run ./`
- `go run ./ --datapath=/path/to/your/custom/data/directory`
运行 `go run ./ --help` 获取更多用法信息。
## 数据结构
所有数据位于 `data` 目录下。目录中的每个文件代表一个域名子列表,以文件名命名。文件内容格式如下。
```
# 评论
include:another-file
domain:google.com @attr1 @attr2
full:analytics.google.com @ads
keyword:google
regexp:^odd[1-7]\.example\.org(\.[a-z]{2})?$
```
**语法:**
- 注释以 `#` 开头。它可以出现在文件的任何位置。`#` 之后的内容被视为注释,在生产环境中会被忽略。
- 子域名以 `domain:` 开头,后跟一个有效的域名。前缀 `domain:` 可以省略。
- 完整域名以 `full:` 开头,后跟一个完整且有效的域名。
- 关键词以 `keyword:` 开头,后跟有效域名的子串。
- 正则表达式以 `regexp:` 开头,后跟有效的正则表达式(遵循 Golang 标准)。
- 域名规则(包括 `domain`、`full`、`keyword` 和 `regexp`)可以没有、有一个或多个属性。每个属性以 `@` 开头,后跟属性名称。属性将保留在最终列表和 `dlc.dat` 中。
- 域名规则可以没有、有一个或多个归属关系,这会将域名规则额外添加到归属的目标列表中。每个归属关系以 `&` 开头,后跟目标列表的名称(无论该目标在数据路径中是否有专用文件)。这是一种数据管理方法,不会保留在最终列表或 `dlc.dat` 中。
- 包含以 `include:` 开头,后跟另一个有效域名列表的名称。在 `lista` 文件中简单的 `include:listb` 意味着将 `listb` 的所有域名规则添加到 `lista` 中。带有属性的包含表示选择性包含。`include:listb @attr1 @-attr2` 意味着仅添加那些*带有* `@attr1` **且** *不带* `@attr2` 的域名规则。这是一种用于数据管理的特殊类型,不会保留在最终列表或 `dlc.dat` 中。
## 工作原理
整个 `data` 目录将被构建为 Project V 的外部 `geosite` 文件。目录中的每个文件代表生成文件中的一个部分。
**一般步骤:**
1. 读取数据路径中的文件(忽略所有注释和空行)。
2. 解析并处理源数据,将归属关系和包含转换为适当列表中的实际域名规则。
3. 对每个列表中的规则进行去重和排序。
4. 导出所需的纯文本列表。
5. 生成 `dlc.dat`:
- 将每个 `domain:` 行转换为[子域名路由规则](https://github.com/v2fly/v2ray-core/blob/master/app/router/routercommon/common.proto#L21)。
- 将每个 `full:` 行转换为[完整域名路由规则](https://github.com/v2fly/v2ray-core/blob/master/app/router/routercommon/common.proto#L23)。
- 将每个 `keyword:` 行转换为[普通域名路由规则](https://github.com/v2fly/v2ray-core/blob/master/app/router/routercommon/common.proto#L17)。
- 将每个 `regexp:` 行转换为[正则域名路由规则](https://github.com/v2fly/v2ray-core/blob/master/app/router/routercommon/common.proto#L19)。
阅读 [main.go](./main.go) 了解详情。
## 如何组织域名
### 文件名
理论上任何字符串都可以作为名称,只要它是有效的文件名。在实践中,我们更倾向于使用能明确界定域名组的名称,例如域名的所有者(通常是公司名称),如 "google"、"netflix"。一般不推荐使用范围不明确的名称,如 "evil" 或 "local"。
### 属性
属性对于域名的子分组非常有用,特别是用于过滤目的。例如,`google` 列表可能包含其主域名,以及提供广告服务的域名。广告域名可以用属性 `@ads` 标记,并在 V2Ray 路由中用作 `geosite:google@ads`。源自中国大陆以外但在中国大陆设有接入点的域名和服务,可以用属性 `@cn` 标记。
## 贡献指南
- Fork 本仓库,在你自己的仓库中进行修改,然后提交 PR。
- 请从小型 PR 开始,例如仅修改单个文件。
- PR 必须经过另一名成员的审查和批准。
- 每次更新 PR 时,脚本都会验证你的拉取请求是否正确。只有通过测试的 PR 才会被合并。如果未通过测试,请前往 Action 标签页获取详细信息。我们还提供已生成的文件供你测试。
- 在成功提交几次 PR 后,你可以申请本仓库的管理员权限。
标签:EVTX分析, GeoIP, Geosite, Go语言, Project V, SNI路由, V2Ray, 互联网自由, 域名分类, 域名列表, 安全合规, 日志审计, 流量转发, 科学上网, 程序破解, 网络代理, 网络分流, 网络安全, 网络安全研究, 网络审查, 网络工具, 翻墙, 规则订阅, 路由规则, 防火墙, 隐私保护