Crab-Hole 项目启动与配置教程

Crab-Hole 项目启动与配置教程

crab-hole 🦀 Pi-Hole clone written in rust using hickory-dns/trust-dns crab-hole 项目地址: https://gitcode.com/gh_mirrors/cr/crab-hole

1. 项目目录结构及介绍

Crab-Hole 是一个用 Rust 编写的跨平台 Pi-Hole 克隆项目。以下是项目的目录结构及各部分的简要介绍:

crab-hole/
├── .github/              # GitHub 工作流和配置文件
├── src/                 # 源代码目录
├── .dockerignore        # Docker 忽略文件
├── .gitattributes        # Git 属性文件
├── .gitignore           # Git 忽略文件
├── Cargo.lock           # Rust 依赖锁文件
├── Cargo.toml           # Rust 项目配置文件
├── LICENSE              # 项目许可证文件
├── README.md            # 项目说明文件
├── build.rs             # Rust 构建脚本
├── config.toml          # 默认配置文件
├── dockerfile           # Dockerfile 文件
├── example-config.toml  # 配置文件示例
└── rustfmt.toml         # Rust 格式化配置文件
  • .github/: 包含 GitHub Actions 工作流,用于自动化项目的某些任务。
  • src/: 包含项目的所有 Rust 源代码。
  • .dockerignore: 指定在创建 Docker 镜像时应忽略的文件和目录。
  • .gitattributes: 配置 Git 如何处理特定的文件和目录。
  • .gitignore: 指定在版本控制中应忽略的文件和目录。
  • Cargo.lock: 记录项目的依赖关系和版本,确保构建的一致性。
  • Cargo.toml: Rust 项目的配置文件,包括项目元数据和依赖项。
  • LICENSE: 项目使用的 AGPL-3.0 许可证。
  • README.md: 提供项目的详细说明和基本信息。
  • build.rs: 自定义的 Rust 构建脚本,可以在编译前执行一些任务。
  • config.toml: 默认的配置文件,用于设置项目的运行参数。
  • dockerfile: 用于构建 Docker 容器的 Dockerfile 文件。
  • example-config.toml: 提供一个配置文件的示例,帮助用户了解如何配置项目。

2. 项目的启动文件介绍

项目的启动非常直接,只需执行编译后的二进制文件即可。以下是启动项目的步骤:

  1. 确保已经安装了 Rust 和 Cargo。
  2. 使用以下命令安装 Crab-Hole:
cargo install crab-hole --locked
  1. 确保 ~/.cargo/bin 路径已经添加到系统的 PATH 环境变量中。
  2. 运行以下命令启动服务:
crab-hole

3. 项目的配置文件介绍

项目的配置文件是 config.toml,它包含了项目运行时所需的所有配置信息。以下是一些重要的配置选项:

  • blocklist: 定义要阻止的域名列表。
  • allow_list: 定义要允许的域名列表。
  • api: 配置 API 服务,如端口和监听地址。
  • downstream: 定义下游服务的配置,包括协议、监听地址、端口等。
  • upstream: 定义上游 DNS 服务器,包括地址、协议等。

以下是一个配置文件示例:

[blocklist]
include_subdomains = true
lists = [
    "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts",
    "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt",
    "file:///blocked.txt"
]

[allow_list]
lists = [
    "file:///allowed.txt"
]

[api]
port = 8080
listen = "127.0.0.1"
show_doc = true
admin_key = "1234"

[[downstream]]
protocol = "udp"
listen = "localhost"
port = 8080

[[downstream]]
protocol = "udp"
listen = "[::]"
port = 8053

[[downstream]]
protocol = "tls"
listen = "[::]"
port = 8054
certificate = "dns.example.com.crt"
key = "dns.example.com.key"

[[downstream]]
protocol = "https"
listen = "[::]"
port = 8055
certificate = "dns.example.com.crt"
key = "dns.example.com.key"
dns_hostname = "dns.example.com"

[[downstream]]
protocol = "quic"
listen = "127.0.0.1"
port = 8055
certificate = "dns.example.com.crt"
key = "dns.example.com.key"
dns_hostname = "dns.example.com"

[upstream]
validate = true

[[upstream.name_servers]]
socket_addr = "[2606:4700:4700::1111]:853"
protocol = "tls"
tls_dns_name = "example-dns-service.com"
trust_nx_responses = false

[[upstream.name_servers]]
socket_addr = "1.1.1.1:853"
protocol = "tls"
tls_dns_name = "example-dns-service.com"
trust_nx_responses = false

确保根据您的网络环境和需求调整配置文件。

crab-hole 🦀 Pi-Hole clone written in rust using hickory-dns/trust-dns crab-hole 项目地址: https://gitcode.com/gh_mirrors/cr/crab-hole

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贾彩知Maura

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值