A place to cache linked articles (think custom and personal wayback machine)
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. title: 0005 DNS
  2. url: https://github.com/datprotocol/DEPs/blob/master/proposals/0005-dns.md
  3. hash_url: 0507da7e382a02e3c8b490913eb29e60
  4. <article class="markdown-body entry-content" itemprop="text"><p>Title: <strong>DEP-0005: DNS</strong></p>
  5. <p>Short Name: <code>0005-dns</code></p>
  6. <p>Type: Informative</p>
  7. <p>Status: Draft (as of 2018-04-27)</p>
  8. <p>Github PR: <a href="https://github.com/datprotocol/DEPs/pull/25">PR#25</a></p>
  9. <p>Authors: Paul Frazee</p>
  10. <h1><a id="user-content-summary" class="anchor" aria-hidden="true" href="#summary"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Summary</h1>
  11. <p>Dat's data structures (HyperCore, HyperDB, and HyperDrive) are addressed using
  12. cryptographic keys. In the context of Web browsers, a URL scheme is used which
  13. is structured as <code>'dat://' {key} '/' {path...}</code>.</p>
  14. <p>This DEP describes an additional protocol for addressing Dats using DNS short names.</p>
  15. <h1><a id="user-content-motivation" class="anchor" aria-hidden="true" href="#motivation"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Motivation</h1>
  16. <p>The cryptographic keys which address Dats are secure and global, but not human-readable. This creates a usability problem.</p>
  17. <p>The goal of this DEP is to leverage DNS to provide human-readable shortnames which map to Dat's cryptographic addresses. The solution...</p>
  18. <ul>
  19. <li>Must provide a single canonical Dat URL for the domain. It should not be possible for a name to have multiple valid mappings. (No conflict.)</li>
  20. <li>Must not be controllable by non-owners of the domain. It should not be possible for third parties to modify the mapping. (Secure.)</li>
  21. <li>Should be accessible to as many users as possible. (Convenient.)</li>
  22. </ul>
  23. <p>An initial proposal (the <a href="https://web.archive.org/web/20171013151452/https://github.com/beakerbrowser/beaker/wiki/Authenticated-Dat-URLs-and-HTTPS-to-Dat-Discovery" rel="nofollow">".well-known solution"</a>) has had prior usage in the Beaker Browser and Dat CLI. A followup proposal (the <a href="https://web.archive.org/web/20180427202745/https://github.com/beakerbrowser/beaker/wiki/Dat-DNS-TXT-records-with-optional-DNS-over-HTTPS" rel="nofollow">"DNS TXT solution"</a>) was made recently, but has not yet been deployed. This DEP intends to unify these proposals formally.</p>
  24. <h1><a id="user-content-usage-documentation" class="anchor" aria-hidden="true" href="#usage-documentation"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Usage Documentation</h1>
  25. <p>Users may provide a Dat URL to clients with the following structure: <code>'dat://' {name} '/'</code>.</p>
  26. <p>If the <code>name</code> is a 64-character hex string, it should be considered a "key" and no DNS-resolution should occur. If <code>name</code> matches the following RegExp, it is considered a "key":</p>
  27. <pre><code>^[0-9a-f]{64}$
  28. </code></pre>
  29. <p>If the <code>name</code> does not match this RegExp, it is a "domain name" and requires resolution. A Dat client should follow the <a href="#resolution-process">resolution process</a> to do this.</p>
  30. <pre><code>domain: dat://beakerbrowser.com/
  31. key: dat://87ed2e3b160f261a032af03921a3bd09227d0a4cde73466c17114816cae43336/
  32. </code></pre>
  33. <p>Users have multiple options for creating a domain-name mapping.</p>
  34. <h2><a id="user-content-dns-txt-record" class="anchor" aria-hidden="true" href="#dns-txt-record"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>DNS TXT record</h2>
  35. <p>The first option is to set a DNS TXT record at the domain which maps to a "key"-addressed Dat URL. The client will lookup this TXT record first and load the resulting Dat. That record should fit the following schema:</p>
  36. <pre><code>datkey={key}
  37. </code></pre>
  38. <h2><a id="user-content-well-knowndat" class="anchor" aria-hidden="true" href="#well-knowndat"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>.well-known/dat</h2>
  39. <p>The second option is to run an HTTPS server at the domain name which includes a <code>/.well-known/dat</code> resource. That resource should provide a text file with the following schema:</p>
  40. <pre><code>dat://{key}
  41. TTL={time in seconds}
  42. </code></pre>
  43. <p><code>TTL</code> is optional and will default to <code>3600</code> (one hour). If set to <code>0</code>, the entry is not cached.</p>
  44. <h1><a id="user-content-resolution-process" class="anchor" aria-hidden="true" href="#resolution-process"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Resolution process</h1>
  45. <p>Resolution of a Dat at <code>dat://{name}</code> should follow this process:</p>
  46. <ul>
  47. <li>Client checks its names cache. If a non-expired entry is found, return with the entry.</li>
  48. <li>Client issues a DNS TXT request for <code>name</code>. This request should be issued via a secure transport (see <a href="#dns-over-https">"DNS-over-HTTPS"</a>).</li>
  49. <li>Client iterates all TXT records given (skip if none). If a record's value matches the TXT record schema (see below):
  50. <ul>
  51. <li>If the record includes a non-zero TTL, store the record value in the names cache.</li>
  52. <li>Return the record value.</li>
  53. </ul>
  54. </li>
  55. <li>Client issues an HTTPS GET request to <code>https://{name}/.well-known/dat</code>.
  56. <ul>
  57. <li>If the server responds with a <code>404 Not Found</code> status, client stores a <code>null</code> entry in the names cache with a TTL of 3600 and returns a failed lookup.</li>
  58. <li>If the server responds with anything other than a <code>200 OK</code> status, return a failed lookup.</li>
  59. <li>If the server responds with a malformed file (see below), return a failed lookup.</li>
  60. <li>If the server responds with a well-formed file, store the record value in the names cache (default TTL to <code>3600</code> if not provided) and return the record value.</li>
  61. </ul>
  62. </li>
  63. </ul>
  64. <p>The DNS TXT record must match this schema:</p>
  65. <pre><code>'datkey=' [0-9a-f]{64}
  66. </code></pre>
  67. <p>The <code>/.well-known/dat</code> file must match this schema:</p>
  68. <pre><code>'dat://' [0-9a-f]{64} '/'?
  69. ( 'TTL=' [0-9]* )?
  70. </code></pre>
  71. <p>Note that DNS-record responses may not follow a pre-defined order. Therefore the results of a lookup may be undefined if multiple TXT records exist.</p>
  72. <h1><a id="user-content-security-and-privacy" class="anchor" aria-hidden="true" href="#security-and-privacy"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Security and Privacy</h1>
  73. <p>Two issues to consider:</p>
  74. <ul>
  75. <li><strong>Security</strong>: Can we trust the lookup results for a name?</li>
  76. <li><strong>Privacy</strong>: Who sees the DNS lookups?</li>
  77. </ul>
  78. <p>Traditional DNS provides neither security or privacy. All looks occur over plaintext UDP. To provide security, a separate system must authenticate the record. (In the case of HTTPS records, the SSL Certificate provides authentication.)</p>
  79. <p>Dat does not currently have a DNS authentication record (no equivalent to the SSL certificate). Therefore a lookup using UDP can not be secured.</p>
  80. <p>To solve this, this DEP recommends using <a href="#dns-over-https">DNS-over-HTTPS</a>.</p>
  81. <h2><a id="user-content-dns-over-https" class="anchor" aria-hidden="true" href="#dns-over-https"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>DNS-over-HTTPS</h2>
  82. <p>Until PKI can authenticate the DNS lookups (ie via SSL certificates or equivalent) there is a risk that the DNS lookup will be intercepted by an adversary. To protect against this, the client should use DNS-over-HTTPS to lookup the DNS TXT records.</p>
  83. <p>Current providers:</p>
  84. <p>This solution improves on both the security and privacy of DNS lookup:</p>
  85. <ul>
  86. <li><strong>Security</strong>. Requests to the DNS provider are authenticated using the provider's SSL certificate.</li>
  87. <li><strong>Privacy</strong>. DNS lookups are encrypted on the wire and only made visible to the DNS provider.</li>
  88. </ul>
  89. <p>DNS-over-HTTPS still requires trust in the provider to give correct responses, but this is an improvement to UDP DNS lookups, which can be trivially MITMed by malicious actors on the network.</p>
  90. <p>Whereas traditional DNS leaks name lookups to everyone on the network, DNS-over-HTTPS only reveals them to the DNS provider. This still provides some opportunity for tracking, but the opportunity is reduced to the provider alone.</p>
  91. <h1><a id="user-content-drawbacks" class="anchor" aria-hidden="true" href="#drawbacks"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Drawbacks</h1>
  92. <ul>
  93. <li>The use of the <code>.well-known/dat</code> resource over HTTPS creates a dependency on a service.</li>
  94. <li>DNS-over-HTTPS exposes all lookups to the provider and relies on the provider to be honest. However, because this method offsets the risk of MITM attacks, this is a worthwhile trade. Future DEPs should find alternative ways to authenticate domain-name records.</li>
  95. </ul>
  96. <h1><a id="user-content-rationale-and-alternatives" class="anchor" aria-hidden="true" href="#rationale-and-alternatives"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Rationale and alternatives</h1>
  97. <ul>
  98. <li>User-defined names registries could be used instead of DNS, but they would likely suffer from name conflicts without a top-down control.</li>
  99. <li>A blockchain (such as Namecoin) could be used instead of DNS, but blockchains currently have poor throughput and require users to sync large amounts of data.</li>
  100. <li>DNSSEC could be used instead of DNS-over-HTTPS, but it does not have the same level of support among gTLDs that DNS-over-HTTPS has.</li>
  101. </ul>
  102. <h1><a id="user-content-changelog" class="anchor" aria-hidden="true" href="#changelog"><svg class="octicon octicon-link" viewbox="0 0 16 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>Changelog</h1>
  103. <ul>
  104. <li>2018-04-27: First complete draft submitted for review</li>
  105. <li>2018-05-07: Add "Security and Privacy" section and rewrite DNS TXT record schema.</li>
  106. <li>2018-05-16: Merged as Draft after WG approval.</li>
  107. </ul>
  108. </article>