Skip to content

Commit 8ad6d5b

Browse files
authored
Add ISDN record (#1515)
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]>
1 parent 4c06a1b commit 8ad6d5b

File tree

7 files changed

+110
-0
lines changed

7 files changed

+110
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
126126
*all of them*
127127

128128
* 103{4,5} - DNS standard
129+
* 1183 - ISDN, X25 and other deprecated records
129130
* 1348 - NSAP record (removed the record)
130131
* 1982 - Serial Arithmetic
131132
* 1876 - LOC record

parse_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,23 @@ func TestParseHINFO(t *testing.T) {
14501450
}
14511451
}
14521452

1453+
func TestParseISDN(t *testing.T) {
1454+
dt := map[string]string{
1455+
"example.net. ISDN A B": "example.net. 3600 IN ISDN \"A\" \"B\"",
1456+
"example.net. ISDN \"A\" \"B\"": "example.net. 3600 IN ISDN \"A\" \"B\"",
1457+
}
1458+
for i, o := range dt {
1459+
rr, err := NewRR(i)
1460+
if err != nil {
1461+
t.Error("failed to parse RR: ", err)
1462+
continue
1463+
}
1464+
if rr.String() != o {
1465+
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
1466+
}
1467+
}
1468+
}
1469+
14531470
func TestParseCAA(t *testing.T) {
14541471
lt := map[string]string{
14551472
"example.net. CAA 0 issue \"symantec.com\"": "example.net.\t3600\tIN\tCAA\t0 issue \"symantec.com\"",

scan_rr.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,29 @@ func (rr *HINFO) parse(c *zlexer, o string) *ParseError {
220220

221221
rr.Cpu = chunks[0]
222222
rr.Os = strings.Join(chunks[1:], " ")
223+
return nil
224+
}
225+
226+
// according to RFC 1183 the parsing is identical to HINFO, so just use that code.
227+
func (rr *ISDN) parse(c *zlexer, o string) *ParseError {
228+
chunks, e := endingToTxtSlice(c, "bad ISDN Fields")
229+
if e != nil {
230+
return e
231+
}
232+
233+
if ln := len(chunks); ln == 0 {
234+
return nil
235+
} else if ln == 1 {
236+
// Can we split it?
237+
if out := strings.Fields(chunks[0]); len(out) > 1 {
238+
chunks = out
239+
} else {
240+
chunks = append(chunks, "")
241+
}
242+
}
243+
244+
rr.Address = chunks[0]
245+
rr.SubAddress = strings.Join(chunks[1:], " ")
223246

224247
return nil
225248
}

types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,17 @@ func (rr *X25) String() string {
402402
return rr.Hdr.String() + rr.PSDNAddress
403403
}
404404

405+
// ISDN RR. See RFC 1183, Section 3.2.
406+
type ISDN struct {
407+
Hdr RR_Header
408+
Address string
409+
SubAddress string
410+
}
411+
412+
func (rr *ISDN) String() string {
413+
return rr.Hdr.String() + sprintTxt([]string{rr.Address, rr.SubAddress})
414+
}
415+
405416
// RT RR. See RFC 1183, Section 3.3.
406417
type RT struct {
407418
Hdr RR_Header

zduplicate.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zmsg.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ztypes.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)