1 个不稳定版本

0.1.0 2020年11月7日

#1107命令行工具

5,388 星 & 34 关注者

EUPL-1.2

270KB
6K SLoC

dog

dog 是一个命令行 DNS 客户端。

Build status Say thanks!

A screenshot of dog making a DNS request


可以 查询!

dog 是一个命令行 DNS 客户端,类似于 dig。它具有彩色输出,理解常规命令行参数语法,支持 DNS-over-TLS 和 DNS-over-HTTPS 协议,并可以输出 JSON。

示例

dog example.net                          Query a domain using default settings
dog example.net MX                       ...looking up MX records instead
dog example.net MX @1.1.1.1              ...using a specific nameserver instead
dog example.net MX @1.1.1.1 -T           ...using TCP rather than UDP
dog -q example.net -t MX -n 1.1.1.1 -T   As above, but using explicit arguments

命令行选项

查询选项

<arguments>              Human-readable host names, nameservers, types, or classes
-q, --query=HOST         Host name or domain name to query
-t, --type=TYPE          Type of the DNS record being queried (A, MX, NS...)
-n, --nameserver=ADDR    Address of the nameserver to send packets to
--class=CLASS            Network class of the DNS record being queried (IN, CH, HS)

发送选项

--edns=SETTING           Whether to OPT in to EDNS (disable, hide, show)
--txid=NUMBER            Set the transaction ID to a specific value
-Z=TWEAKS                Set uncommon protocol-level tweaks

协议选项

-U, --udp                Use the DNS protocol over UDP
-T, --tcp                Use the DNS protocol over TCP
-S, --tls                Use the DNS-over-TLS protocol
-H, --https              Use the DNS-over-HTTPS protocol

输出选项

-1, --short              Short mode: display nothing but the first result
-J, --json               Display the output as JSON
--color, --colour=WHEN   When to colourise the output (always, automatic, never)
--seconds                Do not format durations, display them as seconds
--time                   Print how long the response took to arrive

安装

要安装 dog,您可以下载预编译的二进制文件,或者从源代码编译。根据您的平台,您可能可以使用操作系统的软件包管理器安装 dog。

软件包

  • 对于 Arch Linux,安装 dog 软件包。
  • 对于 macOS 的 Homebrew,安装 dog 公式。
  • 对于 NixOS,安装 dogdns 软件包。

下载

dog 的二进制下载可以从 GitHub 的发布部分 获取,适用于 64 位 Windows、macOS 和 Linux 目标。它们包含编译后的可执行文件、手册页和 shell 完整性。

编译

dog 使用 Rust 编写。您需要 rustc 版本 1.45.0 或更高版本。为开发安装 Rust 的推荐方式是从 官方下载页面 使用 rustup。

要构建,请下载源代码并运行

$ cargo build
$ cargo test
  • 可以使用just命令行工具运行一些有用的开发命令,其使用方式类似于make。运行just --list可以查看可用的概览。

  • 如果您正在为自己编译副本,请确保运行cargo build --releasejust build-release以利用发布模式的优化。将生成的二进制文件复制到您的target/release目录中,然后将其复制到您的$PATH文件夹中。/usr/local/bin通常是不错的选择。

  • 要编译和安装手册页,您需要pandoc。运行just man命令将Markdown编译成手册页,并将其放置在target/man目录中。要使用它们,将它们复制到man可以读取的目录中。/usr/local/share/man通常是不错的选择。

容器镜像

要构建dog的容器镜像,您可以使用Docker或Kaniko。以下是一个使用Docker的示例

$ docker build -t dog .

您可以使用以下命令运行它

$ docker run -it --rm dog

要直接运行dog,您可以定义以下别名

$ alias dog="docker run -it --rm dog"

端到端测试

dog有一个以Specsheet检查文档编写的集成测试套件。如果您已经安装了副本,可以运行

$ just xtests

Specsheet将通过网络中的DNS请求测试编译的二进制文件,检查dog返回正确的结果且不会崩溃。请注意,这将暴露您的IP地址。有关更多信息,请参阅xtests README

功能开关

dog有三个Cargo功能可以关闭以移除功能。虽然这样做会使dog变得不那么有用,但它会产生更小的二进制文件,构建时间也更短。

有三个功能开关可用,默认都处于激活状态

  • with_idna,它启用了IDNA处理
  • with_tls,它启用了DNS-over-TLS
  • with_https,它启用了DNS-over-HTTPS(需要with_tls

使用cargo构建使用功能开关的二进制文件。例如,要禁用TLS和HTTPS支持但保持IDNA支持启用,可以运行

$ cargo build --no-default-features --features=with_idna

可以通过运行--version字符串检查运行时已禁用的功能列表。


文档

有关如何使用dog的文档,请访问网站:https://dns.lookup.dog/

另请参阅

mutttailsleeproff

许可证

dog的源代码根据欧洲联盟公共许可证授权。

依赖项

~0.9–1.5MB
~19K SLoC