<rss version="2.0">
  <channel>
    <title>Lutpul.com</title>
    <link>https://lutpul.com</link>
    <description>Lutpul.com - Blog</description>
    <generator>Zine -- https://zine-ssg.io</generator>
    <language>zh-CN</language>
    <lastBuildDate>Fri, 04 Dec 2026 14:14:30 +0000</lastBuildDate>
    
      <item>
        <title>RFC 8484 阅读笔记</title>
        <description>&lt;h2&gt;RFC 8484 DNS over HTTPS (DoH)&lt;/h2&gt;&lt;p&gt;RFC 8484 定义了 DNS over HTTPS (DoH) 协议，核心思想是将传统的 DNS 查询与响应封装在加密的 HTTPS 流量中进行传输，从而提升隐私性和安全性。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;一些名词说明&lt;/strong&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;ol&gt;&lt;li&gt;DoH服务器：支持此协议的服务器称为“DoH服务器”，以区别于“DNS服务器”，支持此协议的客户端称为“DoH客户端”&lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;&lt;hr&gt;&lt;p&gt;DoH，通过名字可以看得出来，这个【客户端】请求 - 【服务器】响应 的过程，是通过HTTP进行的，自然地，这里就会有我们熟知的 &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt; 等请求响应方式。&lt;/p&gt;&lt;h3&gt;请求 (4.1. The HTTP Request)&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;GET&lt;/code&gt; 方式&lt;/li&gt;&lt;/ol&gt;&lt;blockquote&gt;&lt;p&gt;These examples use a DoH service with a URI Template of “&lt;code&gt;https://dnsserver.example.net/dns-query{?dns}&lt;/code&gt;” to resolve IN A records.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;可知,使用GET方式的时候,URI 模板为: &lt;code&gt;https://dnsserver.example.net/dns-query{?dns}&lt;/code&gt;.DNS 查询消息本身是二进制，不能直接塞进 URL，所以要先做 &lt;code&gt;base64url&lt;/code&gt; 编码，然后作为 URL 参数 dns 的值。&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;:method&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;GET&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;:scheme&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;https&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;:authority&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;dnsserver.example.net&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;:path&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;/dns-query?dns=AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;accept&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;值得注意的是: 请求的 Accept 必须为: &lt;code&gt;application/dns-message&lt;/code&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;POST&lt;/code&gt; 方式&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;POST 不把 DNS 查询放 URL，而是直接放在 HTTP 请求体里：&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;POST&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;/dns-query&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;HTTP/1.1&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;Host:&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;dns.example.net&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;Content-Type:&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;Accept:&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;

&lt;span class=&quot;constant operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;这里是原始&lt;/span&gt; &lt;span class=&quot;constant function&quot;&gt;DNS&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;查询二进制&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;constant operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;constant function&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;represented&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;following&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;hex&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;&amp;gt;&lt;/span&gt;
   00 00 01 00 00 01 00 00  00 00 00 00 03 77 77 77
   &lt;span class=&quot;constant function&quot;&gt;07&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;65&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;78&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;61&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;70&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6c&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;65&lt;/span&gt;  &lt;span class=&quot;constant&quot;&gt;03&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;63&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6f&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt;
   &lt;span class=&quot;constant function&quot;&gt;01&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;Content-Type: application/dns-message&lt;/code&gt; 告诉服务器：请求体里装的是 DNS 消息。&lt;/p&gt;&lt;p&gt;用一下文档中的例子:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;基于GET的查询“a.62characterlabel-makes-base64url-distinct-from-standard-base64.example.com”为例，强调base64url的编码字母表不同于常规base64，并且省略了填充: DNS查询以DNS wire格式表示，为94字节，由以下内容表示：&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;00 00 01 00 00 01 00 00 00 00 00 00 01 61 3e 36 32 63 68 61 72 61 63 74 65 72 6c 61 62 65 6c 2d 6d 61 6b 65 73 2d 62 61 73 65 36 34 75 72 6c 2d 64 69 73 74 69 6e 63 74 2d 66 72 6f 6d 2d 73 74 61 6e 64 61 72 64 2d 62 61 73 65 36 34 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;那么请求就长这样:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;:method&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;GET&lt;/span&gt;
  &lt;span class=&quot;constant function&quot;&gt;:scheme&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;https&lt;/span&gt;
  &lt;span class=&quot;constant function&quot;&gt;:authority&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;dnsserver.example.net&lt;/span&gt;
  &lt;span class=&quot;constant function&quot;&gt;:path&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;/dns-query? (no&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;space&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Carriage&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Return&lt;/span&gt; (&lt;span class=&quot;constant function&quot;&gt;CR&lt;/span&gt;))
         &lt;span class=&quot;property&quot;&gt;dns&lt;/span&gt;=AAABAAABAAAAAAAAAWE-NjJjaGFyYWN0ZXJsYWJl (&lt;span class=&quot;constant function&quot;&gt;no&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;space&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;CR&lt;/span&gt;)
          &lt;span class=&quot;constant function&quot;&gt;bC1tYWtlcy1iYXNlNjR1cmwtZGlzdGluY3QtZnJvbS1z&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt;no&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;space&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;CR&lt;/span&gt;)
          &lt;span class=&quot;constant function&quot;&gt;dGFuZGFyZC1iYXNlNjQHZXhhbXBsZQNjb20AAAEAAQ&lt;/span&gt;
 &lt;span class=&quot;constant function&quot;&gt;accept&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;&lt;h3&gt;响应 (4.2 The HTTP Response)&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;客户端有了请求,服务器必有响应&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The only response type defined in this document is application/dns-message&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;响应类型：目前只定义 &lt;code&gt;application/dns-message&lt;/code&gt;&lt;/p&gt;&lt;p&gt;也就是:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;content-type:&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;响应体里装的是 DNS wire format 的 DNS 响应报文。&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Each DNS request-response pair is mapped to one HTTP exchange. The responses may be processed and transported in any order using HTTP’s multi-streaming functionality (see Section 5 of [RFC7540]).&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;也就是 一个DNS查询请求+响应 = 一次完整的HTTP交换&lt;/p&gt;&lt;h4&gt;DNS和HTTP错误处理&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;DNS 查询失败，HTTP 仍然可以是 2xx&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;DNS response codes indicate either success or failure for the DNS query. A successful HTTP response with a 2xx status code (see Section 6.3 of [RFC7231]) is used for any valid DNS response, regardless of the DNS response code. For example, a successful 2xx HTTP status code is used even with a DNS message whose DNS response code indicates failure, such as SERVFAIL or NXDOMAIN.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;也就是说：&lt;/p&gt;&lt;ul&gt;&lt;li&gt;DNS 返回 NOERROR：HTTP 用 200；&lt;/li&gt;&lt;li&gt;DNS 返回 NXDOMAIN：HTTP 仍然可以用 200；&lt;/li&gt;&lt;li&gt;DNS 返回 SERVFAIL：HTTP 仍然可以用 200。&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;因为从 HTTP 角度看，DoH 服务器成功处理了这个 HTTP 请求，并且返回了一个合法的 DNS 响应报文。DNS 层面的失败信息在 DNS 响应报文的 RCODE 里，不在 HTTP 状态码里。&lt;/p&gt;&lt;p&gt;所以不能看到 HTTP 200 就以为域名一定解析成功；还要看 DNS 响应里的 RCODE。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;非 2xx HTTP 响应不包含 DNS 答复&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;HTTP responses with non-successful HTTP status codes do not contain replies to the original DNS question.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;意思是：&lt;/p&gt;&lt;p&gt;如果 HTTP 状态码不是 2xx，比如 401、415、406；&lt;/p&gt;&lt;p&gt;那么这个 HTTP 响应体里不包含对原 DNS 查询的 DNS 答复。&lt;/p&gt;&lt;p&gt;这时 DoH 客户端要像普通 HTTP 客户端一样处理 HTTP 错误。&lt;/p&gt;&lt;p&gt;原文举的例子：&lt;/p&gt;&lt;ul&gt;&lt;li&gt;401 授权失败：可能用同一个 DoH 服务器重试；&lt;/li&gt;&lt;li&gt;415 不支持的媒体类型：可能换一个 DoH 服务器重试；&lt;/li&gt;&lt;li&gt;406 服务器无法生成适合客户端的表示：也可能换服务器或调整请求。&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;注意：这里说的是“可能”，不是强制重试策略。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;响应示例&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This is an example response for a query for the IN AAAA records for “www.example.com” with recursion turned on. The response bears one answer record with an address of 2001:db8:abcd:12:1:2:3:4 and a TTL of 3709 seconds.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;HTTP/2 响应头是：&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;:status&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;200&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;content-type&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;content-length&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;61&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;cache-control&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;max-age=3709&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;含义：&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;:status&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;200：HTTP&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;成功；&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;content-type&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;application/dns-message：响应体是&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;DNS&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;wire&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;格式；&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;content-length&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;61：DNS&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;响应报文&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;61&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;字节；&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;cache-control&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;max-age=3709：HTTP&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;缓存最多存&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;3709&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;秒，对应&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;DNS&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;记录&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;TTL。&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;响应体十六进制：&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;关于DNS报文&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;我想后面再看看&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;不然容易混的感觉&lt;/span&gt;

&lt;span class=&quot;constant function&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;81&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;80&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;03&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;77&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;77&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;77&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;07&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;65&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;78&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;61&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;70&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6c&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;65&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;03&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;63&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6f&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;6d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;1c&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;c0&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;0c&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;1c&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;0e&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;7d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;0d&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;b8&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;ab&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;12&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;01&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;02&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;03&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;04&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;总结的来说&lt;/strong&gt; :&lt;/p&gt;&lt;ol&gt;&lt;li&gt;DoH 响应目前标准格式是 application/dns-message，响应体是 DNS wire 报文。&lt;/li&gt;&lt;li&gt;一个 DNS 查询-响应对应一次 HTTP 交换。&lt;/li&gt;&lt;li&gt;DNS 的失败不通过 HTTP 状态码表达：&lt;ul&gt;&lt;li&gt;NXDOMAIN、SERVFAIL 等仍然可以返回 HTTP 200；&lt;/li&gt;&lt;li&gt;客户端必须解析 DNS 响应里的 RCODE。&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;HTTP 非 2xx 响应不包含 DNS 答复，客户端按 HTTP 语义处理，可能重试或换服务器。&lt;/li&gt;&lt;li&gt;示例中 cache-control: max-age=3709 和 DNS 答案 TTL 3709 对应，说明 HTTP 缓存生命周期要和 DNS TTL 保持一致。&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;必须使用https,纯http 不行&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;HTTP/2[RFC7540]是用于DoH的HTTP的最低推荐版本。&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The messages in classic UDP-based DNS [RFC1035] are inherently unordered and have low overhead. A competitive HTTP transport needs to support reordering, parallelism, priority, and header compression to achieve similar performance. Those features were introduced to HTTP in HTTP/2 [RFC7540]. Earlier versions of HTTP are capable of conveying the semantic requirements of DoH but may result in very poor performance.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;经典的基于UDP的DNS[RFC1035]中的消息本质上是无序的，开销很低。有竞争力的HTTP传输需要支持重新排序、并行性、优先级和头压缩，以实现类似的性能。这些特性是在HTTP/2[RFC7540]中引入HTTP的。早期版本的HTTP能够传达DoH的语义需求，但可能会导致非常差的性能。&lt;/p&gt;&lt;hr&gt;&lt;p&gt;至此，我对于DoH协议的实现有了基本的认识。&lt;/p&gt;&lt;p&gt;链接:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;https://datatracker.ietf.org/doc/html/rfc8484&quot;&gt;DNS Queries over HTTPS (DoH)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://rfc2cn.com/rfc8484.html&quot;&gt;RFC 8484: DNS Queries over HTTPS (DoH) &lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;注：本文未使用Ai生成。&lt;/p&gt;</description>
        <link>https://lutpul.com/blog/RFC-8484/</link>
        <pubDate>Tue, 17 Nov 2026 11:10:00 +0000</pubDate>
        <guid>https://lutpul.com/blog/RFC-8484/</guid>
      </item>
    
      <item>
        <title>国际象棋备忘</title>
        <description>&lt;p&gt;最近在研究&lt;strong&gt;国际象棋&lt;/strong&gt;，起因是、我平时不太会玩那些手机网游(王者荣耀、和平精英……)和端游(因为我晕3D,&lt;del&gt;悲哀啊&lt;/del&gt;)，因此有时候也会显得有些力有不逮。再者，发现自己无聊的时候习惯性做的事情就是刷短视频，最近在这件事上也有了一些思考，感觉到刷短视频这件事，对我的负面影响是实打实的，有时候甚至脑子里面想着不刷了，手指反而还在那习惯性的滑动……，最近也在对此做了一下措施，严格限制了自己耗费在短视频App的时间，现在还在适应期。综上，我想学习一些棋类游戏，和那些无意义耗费的时间做置换，实践出真理，开始吧。&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;1.先说棋盘：&lt;/h2&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/chess-1.png&quot;&gt;
&lt;figcaption&gt;棋盘&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;国际象棋的棋盘为正方形，总共64格，每行和每列8格，深色和浅色的格子各占32格。常见的颜色是黑色和白色的，但也可以是其他颜色的，规则也描述为浅色和深色（light-coloured, dark-coloured）。&lt;/p&gt;&lt;p&gt;棋局由白方先下，对弈双方轮流移动棋盘上既有的己方棋子，一步棋只能移动一个棋子&lt;/p&gt;&lt;h2&gt;2.再说棋子：&lt;/h2&gt;&lt;p&gt;黑白双方有6类棋子：&lt;/p&gt;&lt;h3&gt;1. ♔ 王 King&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/king.png&quot;&gt;
&lt;figcaption&gt;王&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;王是整个棋局中最为重要的棋子，不能被吃。横、直、斜走均可，但每次只能走一格，所走到的位置不可有对方棋子的威胁，吃子与走法相同。王与中国象棋中的 &lt;strong&gt;将&lt;/strong&gt; 同等地位。&lt;/p&gt;&lt;h3&gt;2. ♕ 后 Queen&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/queen.png&quot;&gt;
&lt;figcaption&gt;后&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;后最强大的棋子，横、直、斜走均可，格数不限，但不可越过其他棋子。&lt;/p&gt;&lt;h3&gt;3. ♖ 车	Rook&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/rook.png&quot;&gt;
&lt;figcaption&gt;车&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;车的走法是横走或直走，格数不限，但不可斜走，也不可越过其他棋子。車与中国象棋中的 &lt;strong&gt;車&lt;/strong&gt; 同等。&lt;/p&gt;&lt;h3&gt;4. ♗ 象	Bishop&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/bishop.png&quot;&gt;
&lt;figcaption&gt;象&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;象只可斜走，格数不限，但不可转向，也不可越过其他棋子。象与中国象棋中的 &lt;strong&gt;象&lt;/strong&gt; 同等。&lt;/p&gt;&lt;h3&gt;5. ♘ 马 Knight&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/knight.png&quot;&gt;
&lt;figcaption&gt;马&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;马走法和中国象棋的馬相同，同样是走“日”字，或英文字母大写的“L”形：即先向左（或右）走1格，再向上（或下）走2格；或先向左（或右）走2格，再向上（或下）走1格。国际象棋的马没有“绊马脚”的限制，故马可越过其他棋子。&lt;/p&gt;&lt;h3&gt;6. ♙	兵	Pawn&lt;/h3&gt;&lt;p&gt;&lt;figure&gt;&lt;img src=&quot;https://lutpul.com/blog/chess/pawn.png&quot;&gt;
&lt;figcaption&gt;兵&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;兵在第一步（在2或7行）可前进一格或两格。其后，兵每次只能前进一格，且不可向后退，是唯一有方向限制的棋子。在前方斜线的左侧和右侧吃子，不能是直线。&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;3. 棋谱咋读&lt;/h2&gt;&lt;p&gt;知到了走法，还得能看懂棋谱，不然就是“茶壶里煮饺子——有货倒不出”。现在通用的是&lt;strong&gt;代数记谱法&lt;/strong&gt;（Algebraic Notation），棋书、App、比赛记录用的都是它。(老看不懂，所以写的啰嗦点……)&lt;/p&gt;&lt;h3&gt;1. 先认坐标&lt;/h3&gt;&lt;p&gt;棋盘横着 8 行、竖着 8 列，每格都有唯一的“门牌号”：&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;列（竖线）&lt;/strong&gt;：从白方左手边起是 a 到 h 共 8 列&lt;/li&gt;&lt;li&gt;&lt;strong&gt;行（横线）&lt;/strong&gt;：从白方底线起是 1 到 8 共 8 行&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;列号在前、行号在后&lt;/strong&gt;，比如 &lt;strong&gt;e4&lt;/strong&gt; 就是 e 列第 4 行的格子。坐标是全棋盘固定的，双方看到的是同一套：白方左下角是 a1，黑方那边的左下角（也就是白方的右上角）是 h8。&lt;/p&gt;&lt;h3&gt;2. 棋子的字母代号&lt;/h3&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;棋子&lt;/th&gt;&lt;th&gt;字母&lt;/th&gt;&lt;th&gt;记谱示例&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;王 King&lt;/td&gt;&lt;td&gt;K&lt;/td&gt;&lt;td&gt;Ke2（王走到 e2）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;后 Queen&lt;/td&gt;&lt;td&gt;Q&lt;/td&gt;&lt;td&gt;Qd5&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;车 Rook&lt;/td&gt;&lt;td&gt;R&lt;/td&gt;&lt;td&gt;Ra1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;象 Bishop&lt;/td&gt;&lt;td&gt;B&lt;/td&gt;&lt;td&gt;Bg5&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;马 Knight&lt;/td&gt;&lt;td&gt;N&lt;/td&gt;&lt;td&gt;Nf3&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;兵 Pawn&lt;/td&gt;&lt;td&gt;（不写）&lt;/td&gt;&lt;td&gt;e4&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&lt;strong&gt;兵不写字母&lt;/strong&gt;是新手最容易忘的点：&lt;code&gt;e4&lt;/code&gt; 不是什么代号，就是“e 列的兵走到第 4 行”。&lt;/p&gt;&lt;h3&gt;3. 一步棋怎么写&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;格式：棋子字母 + 目标格&lt;/strong&gt;。比如 &lt;code&gt;Nf3&lt;/code&gt; = 马跳到 f3，&lt;code&gt;Qh5&lt;/code&gt; = 后走到 h5。&lt;/p&gt;&lt;p&gt;吃子用 &lt;strong&gt;x&lt;/strong&gt;：&lt;code&gt;exd5&lt;/code&gt; = 兵吃掉 d5 上的子（兵吃子必须写它出发的列），&lt;code&gt;Nxe5&lt;/code&gt; = 马吃掉 e5 的子。&lt;/p&gt;&lt;p&gt;两个同类棋子都能走到同一格时，加上出发位置区分：&lt;code&gt;Rad1&lt;/code&gt;（a 列的车走到 d1）、&lt;code&gt;Nbd2&lt;/code&gt;（b 列的马走到 d2）。&lt;/p&gt;&lt;h3&gt;4. 特殊走法的写法&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;王车易位&lt;/strong&gt;：&lt;code&gt;O-O&lt;/code&gt;（短易位，王翼）、&lt;code&gt;O-O-O&lt;/code&gt;（长易位，后翼）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;升变&lt;/strong&gt;：&lt;code&gt;e8=Q&lt;/code&gt;（兵到底线升变为后），升变成其他棋子同理&lt;/li&gt;&lt;li&gt;&lt;strong&gt;吃过路兵&lt;/strong&gt;：照常写吃子，有的棋谱会加 &lt;code&gt;e.p.&lt;/code&gt; 标注&lt;/li&gt;&lt;li&gt;&lt;strong&gt;将军&lt;/strong&gt;：末尾加 &lt;code&gt;+&lt;/code&gt;，比如 &lt;code&gt;Qh5+&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;将死&lt;/strong&gt;：末尾加 &lt;code&gt;#&lt;/code&gt;（或 &lt;code&gt;++&lt;/code&gt;），比如 &lt;code&gt;Qxf7#&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;5. 一局棋的记录&lt;/h3&gt;&lt;p&gt;双方各走一步算一个回合，白方在前、黑方在后，开头带回合数。比如西班牙开局的前几回合：&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant function&quot;&gt;1.&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;e4&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;e5&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;2.&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Nf3&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Nc6&lt;/span&gt;
&lt;span class=&quot;constant function&quot;&gt;3.&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Bb5&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;a6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;结尾标注结果：白胜 &lt;strong&gt;1-0&lt;/strong&gt;，黑胜 &lt;strong&gt;0-1&lt;/strong&gt;，和棋 &lt;strong&gt;½-½&lt;/strong&gt;（也写作 1/2-1/2）。&lt;/p&gt;&lt;hr&gt;&lt;p&gt;注：本文未使用Ai生成。&lt;/p&gt;</description>
        <link>https://lutpul.com/blog/chess/</link>
        <pubDate>Sun, 15 Nov 2026 20:30:00 +0000</pubDate>
        <guid>https://lutpul.com/blog/chess/</guid>
      </item>
    
  </channel>
</rss>
