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

Add ISDN record #1515

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
*all of them*

* 103{4,5} - DNS standard
* 1183 - ISDN, X25 and other deprecated records
* 1348 - NSAP record (removed the record)
* 1982 - Serial Arithmetic
* 1876 - LOC record
Expand Down
17 changes: 17 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,23 @@ func TestParseHINFO(t *testing.T) {
}
}

func TestParseISDN(t *testing.T) {
dt := map[string]string{
"example.net. ISDN A B": "example.net. 3600 IN ISDN \"A\" \"B\"",
"example.net. ISDN \"A\" \"B\"": "example.net. 3600 IN ISDN \"A\" \"B\"",
}
for i, o := range dt {
rr, err := NewRR(i)
if err != nil {
t.Error("failed to parse RR: ", err)
continue
}
if rr.String() != o {
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
}
}
}

func TestParseCAA(t *testing.T) {
lt := map[string]string{
"example.net. CAA 0 issue \"symantec.com\"": "example.net.\t3600\tIN\tCAA\t0 issue \"symantec.com\"",
Expand Down
23 changes: 23 additions & 0 deletions scan_rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ func (rr *HINFO) parse(c *zlexer, o string) *ParseError {

rr.Cpu = chunks[0]
rr.Os = strings.Join(chunks[1:], " ")
return nil
}

// according to RFC 1183 the parsing is identical to HINFO, so just use that code.
func (rr *ISDN) parse(c *zlexer, o string) *ParseError {
chunks, e := endingToTxtSlice(c, "bad ISDN Fields")
if e != nil {
return e
}

if ln := len(chunks); ln == 0 {
return nil
} else if ln == 1 {
// Can we split it?
if out := strings.Fields(chunks[0]); len(out) > 1 {
chunks = out
} else {
chunks = append(chunks, "")
}
}

rr.Address = chunks[0]
rr.SubAddress = strings.Join(chunks[1:], " ")

return nil
}
Expand Down
11 changes: 11 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,17 @@ func (rr *X25) String() string {
return rr.Hdr.String() + rr.PSDNAddress
}

// ISDN RR. See RFC 1183, Section 3.2.
type ISDN struct {
Hdr RR_Header
Address string
SubAddress string
}

func (rr *ISDN) String() string {
return rr.Hdr.String() + sprintTxt([]string{rr.Address, rr.SubAddress})
}

// RT RR. See RFC 1183, Section 3.3.
type RT struct {
Hdr RR_Header
Expand Down
15 changes: 15 additions & 0 deletions zduplicate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions zmsg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions ztypes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.