Skip to content

Shorts

Small traces of thought, written in the margins

Terminal window
# command 1
git log -1 --date=iso-strict --format=%cd --date=unix <commit-hash> | xargs -I{} date -u -d @{} +"%Y-%m-%dT%H:%M:%SZ"
# command 2
git log -1 --format=%ct <commit-hash> | xargs -I{} date -u -d @{} +"%Y-%m-%dT%H:%M:%SZ"

也可以封装为一个 bash 脚本:

check-git-commit-time.sh
#!/usr/bin/env bash
# Save as check-git-commit-time.sh
# Usage: ./check-git-commit-time.sh <commit-hash>
if [ -z "$1" ]; then
echo "Usage: $0 <commit-hash>"
exit 1
fi
commit="$1"
# Get the commit's Unix timestamp
timestamp=$(git log -1 --format=%ct "$commit")
# Convert to UTC ISO 8601 format
date -u -d @"$timestamp" +"%Y-%m-%dT%H:%M:%SZ"
Sep 25, 2025

#snippet

网络接口 NetworkManager 图形化修改 IPv4/IPv6 DNS 监听地址为 127.0.0.1 NetworkManager 配置 Dnsmasq 进行 DNS 缓存和条件转发时,不需要启动 Dnsmasq 服务,也不需要更改默认配置文件(/etc/dnsmasq.conf),因为 NetworkMannager 会对它进行管理。 一些常用的自定义 Dnsmasq 配置

dnsmasq.conf
/etc/NetworkManager/dnsmasq.d/cache.conf
cache-size=1000

启用 dnsmasq.d/的配置目录,不存在要新建 conf-dir=/etc/dnsmasq.d/ 使用一下命令检测配置文件语法:

Terminal window
dnsmasq --test --conf-file=/dev/null --conf-dir=/etc/NetworkManager/dnsmasq.d

另外,NetworkManager 使用 Dnsmasq 的话,会使 IPv6-only 模式无法正常工作,Dnsmasq 本身对 IPv6 的优先级也比 IPv4 低。 安装 dnscrypt-proxy,Dnsmasq Dnsmasq 是一个 DNS 存根解析器而不是递归解析器,所以必须将接收到的请求转发到外部 DNS 服务器。 Dnsmasq 可以对 DNS 请求进行分流,所以,为了加速国内域名的解析,我们可以使用多个服务器进行 DNS 解析,比较简单的方式就是直接硬编码常见的域名解析,例如:

server = /www.baidu.com/114.114.114.114

这样在接收到 baidu 的请求的时候就会使用 114.114.114.114 进行 DNS 查询。 我是用 GitHub 上的开源仓库,将常用国内域名硬编码成 conf 文件来使用国内 DNS 服务器进行查询,其他所有域名都使用默认的 DNS 服务器(国外的,DoH 协议)进行安全查询。这样可以一定程度上加速国内网站的访问。 但是,如果硬编码数量过多,也会降低查询速度(这个是 Dnsmasq 的原因,因为是一条条查询的,所以数量越多,性能越差),最后把最常用的一些硬编码,降低硬编码数量。 另外,使用 forwarding_rules 进行硬编码配置也可以实现 DNS 分流。不过不知道性能如何,之后研究一下。 已经开源的地址 https://raw.githubusercontent.com/CNMan/dnscrypt-proxy-config/master/dnscrypt-forwarding-rules.txt ,我看了一下,竟然是从 Dnsmasq-china-list 转换的。。。好吧,就是不知道哪个性能好一点,感觉应该是 dnscrypt-proxy 好一点吧。 好吧,所以我一开始为什么不直接使用 dnscrpyt-proxy 呢?我还以为不支持这个呢。。。 dnscrypt-proxy 的配置很简单,修改配置文件(/etc/dnscrypt-proxy/dnscrypt-proxy.toml)即可: 需要修改的有监听地址,这个写 127.0.0.1<1053> 就行,端口可以使任意的,但是不能是 53,因为这是默认的 DNS 端口,要留给 Dnsmasq 使用。 DNS 服务器,这个填写你想要使用的 DNS 服务器就行。 其他的保持默认就行,当然你也可以根据自己的需求进行更改,配置文件有详细的文档说明。 例如,你可以添加自己的 DNS 服务器,不过服务器链接要使用 DNSStamp 格式,官网有具体说明和格式化工具。

listen_addresses = ['127.0.0.1:1053']
server_names = ['scaleway-fr', 'cloudflare']

另外,使用 forwarding_rules 进行硬编码配置也可以实现 DNS 分流。