Skip to content

Commit

Permalink
Add ISDN record (#1515)
Browse files Browse the repository at this point in the history
We had the type code, this add the rest. Other RRs from 1183 are also
fully impl. don't know why this one wasn't.

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg authored Jan 18, 2024
1 parent 4c06a1b commit 8ad6d5b
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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 @@ -220,6 +220,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.

0 comments on commit 8ad6d5b

Please sign in to comment.