{"id":13928860,"url":"https://github.com/compassd/dcompass","last_synced_at":"2025-07-19T10:32:12.110Z","repository":{"id":37710809,"uuid":"308510705","full_name":"compassd/dcompass","owner":"compassd","description":"A high-performance programmable DNS component aiming at robustness, speed, and flexibility","archived":false,"fork":false,"pushed_at":"2024-11-02T17:59:58.000Z","size":25423,"stargazers_count":283,"open_issues_count":6,"forks_count":23,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-11-02T19:16:37.347Z","etag":null,"topics":["counter-censorship","dns","dns-over-https","dns-server","routing","script"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compassd.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-30T03:03:54.000Z","updated_at":"2024-11-02T18:00:02.000Z","dependencies_parsed_at":"2024-01-14T18:06:14.820Z","dependency_job_id":null,"html_url":"https://github.com/compassd/dcompass","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compassd%2Fdcompass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compassd%2Fdcompass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compassd%2Fdcompass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compassd%2Fdcompass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compassd","download_url":"https://codeload.github.com/compassd/dcompass/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226588855,"owners_count":17655797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["counter-censorship","dns","dns-over-https","dns-server","routing","script"],"created_at":"2024-08-07T18:01:57.286Z","updated_at":"2024-11-26T17:31:05.018Z","avatar_url":"https://github.com/compassd.png","language":"Rust","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"# dcompass\n![自动构建](https://github.com/LEXUGE/dcompass/workflows/Build%20dcompass%20on%20various%20targets/badge.svg)  \n一个高性能的 DNS 服务器，支持插件式路由规则，DoT 以及 DoH  \n[中文版](README-CN.md)\n\n# Why Do You Ever Need It\n如果你对 [SmartDNS](https://github.com/pymumu/smartdns) 或 [Overture](https://github.com/shawn1m/overture) 的逻辑或速度不满，不妨尝试一下 `dcompass`\n\n# 特色\n- 高速 (实测约 2500 qps, 接近上游当前环境下的性能上限）\n- 无需畏惧网络环境的切换（如 4G 切换到 Wi-Fi ）\n- 自由路由规则编写，简洁易维护的规则语法\n- 丰富的匹配器，作用器插件来实现大部分的需求\n- DoH/DoT/UDP 协议支持\n- 惰性 Cache 实现，在尽可能遵守 TTL 的前提下提高返回速度，保障恶劣网络环境下的使用体验\n- 可选不发送 SNI 来防止连接被切断\n- 原生跨平台实现，支持 Linux (ARM/x86)/Windows/macOS\n- 纯 Rust 实现，占用低且内存安全\n\n# 注意\n目前程序处于活跃开发阶段，时刻可能发生不向后兼容的变动，请以 [example.yaml](configs/example.yaml) 为准。\n\n# 用法\n```\ndcompass -c path/to/config.json # 或 YAML 配置文件\n```\n你也可以直接在配置文件 (config.yml) 相同的文件夹下直接运行 `dcompass`\n\n# 软件包\n1. Github Action 会自动每天按照 main branch 和最新的 maxmind GeoIP 数据库对一些平台进行编译并上传到 [release page](https://github.com/LEXUGE/dcompass/releases)。如果是 Raspberry Pi 用户，建议尝试 `armv7-unknown-linux-musleabihf`, `armv5te-unknown-linux-musleabi`, `aarch64-unknown-linux-musl`。每个 target 都带有 `full`, `cn`, `min` 三个版本， `full` 包含 maxmind GeoIP2 database, `cn` 包含 GeoIP2-CN databse （只含有中国 IP）， `min` 不内置数据库。\n2. NixOS 打包文件在[这里](https://github.com/icebox-nix/netkit.nix). 同时，对于 NixOS 用户，我们提供了一个包含 systemd 服务的 NixOS module 来方便用户配置。\n\n# 配置（待翻译）\n**Please refer to the latest English version for up-to-date information.**\n配置文件包含不同的 fields\n- `cache_size`: DNS Cache 的大小. Larger size implies higher cache capacity (use LRU algorithm as the backend).\n- `verbosity`: Log 等级. Possible values are `trace`, `debug`, `info`, `warn`, `error`, `off`.\n- `address`: 监听的地址。\n- `table`: A routing table composed of `rule` blocks. The table cannot be empty and should contains a single rule named with `start`. Each rule contains `tag`, `if`, `then`, and `else`. Latter two of which are tuples of the form `(action, next)`, which means take the action first and goto the next rule with the tag specified.\n- `upstreams`: A set of upstreams. `timeout` is the time in seconds to timeout, which takes no effect on method `Hybrid` (default to 5). `tag` is the name of the upstream. `methods` is the method for each upstream.\n\nDifferent actions:\n- `skip`: Do nothing.\n- `disable`: Set response with a SOA message to curb further query. It is often used accompanied with `qtype` matcher to disable certain types of queries.\n- `query(tag)`: Send query via upstream with specified tag.\n\nDifferent matchers: (More matchers to come, including `cidr`)\n- `any`: Matches anything.\n- `domain(list of file paths)`: Matches domain in specified domain lists\n- `qtype(list of record types)`: Matches record type specified.\n- `geoip(on: resp or src, codes: list of country codes, path: optional path to the mmdb database file)`: If there is one or more `A` or `AAAA` records at the current state and the first of which has got a country code in the list specified, then it matches, otherwise it always doesn't match.\n\nDifferent querying methods:\n- `https`: DNS over HTTPS querying methods. `no_sni` means don't send SNI (useful to counter censorship). `name` is the TLS certification name of the remote server. `addr` is the remote server address.\n- `tls`: DNS over TLS querying methods. `no_sni` means don't send SNI (useful to counter censorship). `name` is the TLS certification name of the remote server. `addr` is the remote server address.\n- `udp`: Typical UDP querying method. `addr` is the remote server address.\n- `hybrid`: Race multiple upstreams together. the value of which is a set of tags of upstreams. Note, you can include another `hybrid` inside the set as long as they don't form chain dependencies, which is prohibited and would be detected by `dcompass` in advance.\n\n一个无需任何外部文件的防污染分流且开箱及用的配置文件 [example.yaml](configs/example.yaml)（只支持 `full` 和 `cn`， `min` 如需使用此配置需要自带 GeoIP database）。  \n\n使用 GeoIP 来防污染的路由表（table）样例\n\n```yaml\ntable:\n- tag: start\n  if: any\n  then:\n  - query: domestic\n  - check_secure\n- tag: check_secure\n  if:\n    geoip:\n      on: resp\n      codes:\n        - CN\n  else:\n  - query: secure\n  - end\n```\n\n# 值得说明的细节\n- 如果一个数据包包含有多个 DNS 请求（实际几乎不可能），匹配器只会对多个 DNS 请求的第一个进行匹配。\n- Cache record 一旦存在，只有在 LRU 算法将其丢弃时才会被丢弃，否则即使过期，还是会被返回，并且后台会并发一个任务来尝试更新这个 cache。\n\n# Benchmark\n模拟测试（忽略网络请求的时间）:\n```\nnon_cache_resolve       time:   [10.624 us 10.650 us 10.679 us]\n                        change: [-0.9733% -0.0478% +0.8159%] (p = 0.93 \u003e 0.05)\n                        No change in performance detected.\nFound 12 outliers among 100 measurements (12.00%)\n  1 (1.00%) low mild\n  6 (6.00%) high mild\n  5 (5.00%) high severe\n\ncached_resolve          time:   [10.712 us 10.748 us 10.785 us]\n                        change: [-5.2060% -4.1827% -3.1967%] (p = 0.00 \u003c 0.05)\n                        Performance has improved.\nFound 10 outliers among 100 measurements (10.00%)\n  2 (2.00%) low mild\n  7 (7.00%) high mild\n  1 (1.00%) high severe\n```\n\n下面是实测，不具有统计学意义\n- On `i7-10710U`, dnsperf gets out `~760 qps` with `0.12s avg latency` and `0.27% ServFail` rate for a test of `15004` queries.\n- As a reference SmartDNS gets `~640 qps` for the same test on the same hardware.\n\n# 计划\n- [ ] 支持自由配置的 inbound server 选项，包括 `DoH`, `DoT`, `TCP`, 和 `UDP`。\n- [ ] IP-CIDR 匹配器，可用于 source IP 或 response IP\n- [x] GeoIP 匹配器，可用于 source IP 或 response IP\n- [ ] 支持自由返回结果的上游（upstream）\n\n# License\nAll three components `dmatcher`, `droute`, `dcompass` are licensed under GPLv3+.\n`dcompass` and `droute` with `geoip` feature gate enabled include GeoLite2 data created by MaxMind, available from \u003ca href=\"https://www.maxmind.com\"\u003ehttps://www.maxmind.com\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompassd%2Fdcompass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompassd%2Fdcompass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompassd%2Fdcompass/lists"}