Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/setup-go@v6
if: ${{ env.NeedToSync }}
with:
go-version-file: ./go.mod
go-version: '1.23'

- name: Checkout v2fly/domain-list-community
if: ${{ env.NeedToSync }}
Expand All @@ -46,10 +46,60 @@ jobs:
echo "include:geolocation-!cn @cn" >> ./domain-list-community/data/cn
echo "include:geolocation-cn @!cn" >> ./domain-list-community/data/geolocation-\!cn

- name: Get dependencies and run
- name: Create config.json
if: ${{ env.NeedToSync }}
run: |
go run ./ --datapath=./domain-list-community/data
cat > config.json <<'EOF'
{
"input": [
{
"type": "domainlist",
"action": "add",
"args": {
"dataDir": "./domain-list-community/data"
}
}
],
"output": [
{
"type": "v2rayGeoSite",
"action": "output",
"args": {
"outputDir": "./publish",
"outputName": "geosite.dat",
"excludeAttrs": "cn@!cn@ads,geolocation-cn@!cn@ads,geolocation-!cn@cn@ads",
"gfwlistOutput": "geolocation-!cn"
}
},
{
"type": "text",
"action": "output",
"args": {
"outputDir": "./publish",
"wantedList": [
"category-ads-all",
"tld-cn",
"cn",
"geolocation-cn",
"tld-!cn",
"geolocation-!cn",
"private",
"apple",
"icloud",
"google",
"steam"
]
}
}
]
}
EOF

- name: Build and run
if: ${{ env.NeedToSync }}
run: |
go build -v -o domain-list-custom
./domain-list-custom convert -c config.json

- name: Generate sha256 hashsum
if: ${{ env.NeedToSync }}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
*.dll
*.so
*.dylib
domain-list-custom

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Output directories
/output
/publish

# Dependency directories (remove the comment below to include it)
# vendor/
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

基于 [v2fly/domain-list-community#256](https://github.com/v2fly/domain-list-community/issues/256) 的提议,重构 [v2fly/domain-list-community](https://github.com/v2fly/domain-list-community) 的构建流程,并添加新功能。

本项目采用插件化架构,参考 [Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip) 项目的设计模式,提供命令行界面(CLI)工具,支持灵活的配置文件,方便用户自定义域名列表的处理和输出。

## 与官方版 `dlc.dat` 不同之处

- 将 `dlc.dat` 重命名为 `geosite.dat`
Expand All @@ -13,6 +15,81 @@

[https://github.com/Loyalsoldier/domain-list-custom/releases/latest/download/geosite.dat](https://github.com/Loyalsoldier/domain-list-custom/releases/latest/download/geosite.dat)

## 使用方法

### 命令行工具

```bash
# 查看帮助
./domain-list-custom --help

# 使用配置文件进行转换
./domain-list-custom convert -c config.json

# 使用远程配置文件
./domain-list-custom convert -c https://example.com/config.json
```

### 配置文件

配置文件采用 JSON 格式,包含 `input` 和 `output` 两个部分:

```json
{
"input": [
{
"type": "domainlist",
"action": "add",
"args": {
"dataDir": "./data"
}
}
],
"output": [
{
"type": "v2rayGeoSite",
"action": "output",
"args": {
"outputDir": "./output",
"outputName": "geosite.dat",
"excludeAttrs": "cn@!cn@ads,geolocation-cn@!cn@ads,geolocation-!cn@cn@ads",
"gfwlistOutput": "geolocation-!cn"
}
},
{
"type": "text",
"action": "output",
"args": {
"outputDir": "./output",
"wantedList": ["cn", "google", "apple"]
}
}
]
}
```

更多配置示例请参考 `config.example.json`。

## 项目结构

```
.
├── lib/ # 核心库
│ ├── lib.go # 接口定义
│ ├── config.go # 配置解析
│ ├── container.go # 数据容器
│ ├── entry.go # 条目管理
│ ├── instance.go # 实例管理
│ └── common.go # 通用函数
├── plugin/ # 插件目录
│ ├── plaintext/ # 文本格式插件
│ └── v2ray/ # V2Ray 格式插件
├── main.go # 主程序入口
├── convert.go # 转换命令
├── init.go # 插件注册
└── config.json # 配置文件
```

## 使用本项目的项目

[@Loyalsoldier/v2ray-rules-dat](https://github.com/Loyalsoldier/v2ray-rules-dat)
113 changes: 0 additions & 113 deletions common.go

This file was deleted.

44 changes: 44 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"input": [
{
"type": "domainlist",
"action": "add",
"args": {
"dataDir": "./data",
"wantedList": []
}
}
],
"output": [
{
"type": "v2rayGeoSite",
"action": "output",
"args": {
"outputDir": "./output",
"outputName": "geosite.dat",
"excludeAttrs": "cn@!cn@ads,geolocation-cn@!cn@ads,geolocation-!cn@cn@ads",
"gfwlistOutput": "geolocation-!cn"
}
},
{
"type": "text",
"action": "output",
"args": {
"outputDir": "./output",
"wantedList": [
"category-ads-all",
"tld-cn",
"cn",
"geolocation-cn",
"tld-!cn",
"geolocation-!cn",
"private",
"apple",
"icloud",
"google",
"steam"
]
}
}
]
}
28 changes: 28 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"input": [
{
"type": "domainlist",
"action": "add",
"args": {
"dataDir": "./data"
}
}
],
"output": [
{
"type": "v2rayGeoSite",
"action": "output",
"args": {
"outputDir": "./output",
"outputName": "geosite.dat"
}
},
{
"type": "text",
"action": "output",
"args": {
"outputDir": "./output"
}
}
]
}
Loading