Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper Encoding/Decoding for Email Name Representation for SOA and RP Records #93

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

M4t7e
Copy link
Contributor

@M4t7e M4t7e commented Aug 25, 2023

According to RFC 1035 (but initially defined in RFC 883), email addresses can be represented as domain names in SOA (RNAME) and RP (MBOX) Records. An email address consists of two parts, a local part and the domain (<local part>@<domain>). Currently, dns-packet does not support proper processing of email addresses if the local part contains dots (.). E-mail DNS labels in the local part are allowed to contain a dot, which must be escaped by \. in the representation format. With wire format, the label size is simply set to span the entire label, including all dots.

SOA (RFC 1035):

The DNS encodes the <local-part> as a single label, and encodes the <mail-domain> as a domain name. The single label from the <local-part> is prefaced to the domain name from <mail-domain> to form the domain name corresponding to the mailbox. Thus the mailbox HOSTMASTER@SRI-NIC.ARPA is mapped into the domain name HOSTMASTER.SRI-NIC.ARPA. If the <local-part> contains dots or other special characters, its representation in a master file will require the use of backslash quoting to ensure that the domain name is properly encoded. For example, the mailbox Action.domains@ISI.EDU would be represented as Action\.domains.ISI.EDU.

RP (RFC 1183):

The first field, <mbox-dname>, is a domain name that specifies the mailbox for the responsible person. Its format in master files uses the DNS convention for mailbox encoding, identical to that used for the RNAME mailbox field in the SOA RR.

dig example:

# dig soa powerdns.com
; <<>> DiG 9.18.12-0ubuntu0.22.04.2-Ubuntu <<>> soa powerdns.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59258
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;powerdns.com.			IN	SOA

;; ANSWER SECTION:
powerdns.com.		2023	IN	SOA	pdns-public-ns1.powerdns.com. peter\.van\.dijk.powerdns.com. 2023082401 10800 3600 604800 3600

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Aug 25 11:30:41 CEST 2023
;; MSG SIZE  rcvd: 108

dns-packet example after this change:
image

peter\.van\.dijk.powerdns.com -> peter.van.dijk@powerdns.com

This PR should also fix #90

index.js Outdated Show resolved Hide resolved
test.js Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

Merging #93 (2741e95) into master (519f55d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
+ Coverage   97.97%   97.99%   +0.01%     
==========================================
  Files           6        6              
  Lines        2026     2046      +20     
==========================================
+ Hits         1985     2005      +20     
  Misses         41       41              
Files Changed Coverage Δ
index.js 98.06% <100.00%> (+0.02%) ⬆️

index.js Outdated Show resolved Hide resolved
@silverwind silverwind merged commit 13f19d9 into mafintosh:master Aug 25, 2023
10 checks passed
silverwind added a commit that referenced this pull request Aug 25, 2023
* Proper Encoding/Decoding for Email Name Representation for SOA and RP Records (#93) (M4t7e)
* test node 20 (silverwind)
silverwind added a commit that referenced this pull request Aug 25, 2023
* Proper Encoding/Decoding for Email Name Representation for SOA and RP Records (#93) (M4t7e)
* test node 20 (silverwind)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Escaped dot in rname handled as normal dot
3 participants