Skip to content

Commit 794abd7

Browse files
authored
edns0 cleanups (#1595)
Mostly trickered by: ~~~ - return &EDNS0_ESU{Code: EDNS0ESU} + return new(EDNS0_ESU) ~~~ dont see why this 'case' needs to be different than all the others. Some various textual changes for the test. Signed-off-by: Miek Gieben <[email protected]>
1 parent 6008929 commit 794abd7

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

edns.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@ func makeDataOpt(code uint16) EDNS0 {
5858
case EDNS0EDE:
5959
return new(EDNS0_EDE)
6060
case EDNS0ESU:
61-
return &EDNS0_ESU{Code: EDNS0ESU}
61+
return new(EDNS0_ESU)
6262
default:
6363
e := new(EDNS0_LOCAL)
6464
e.Code = code
6565
return e
6666
}
6767
}
6868

69-
// OPT is the EDNS0 RR appended to messages to convey extra (meta) information.
70-
// See RFC 6891.
69+
// OPT is the EDNS0 RR appended to messages to convey extra (meta) information. See RFC 6891.
7170
type OPT struct {
7271
Hdr RR_Header
7372
Option []EDNS0 `dns:"opt"`
@@ -144,8 +143,6 @@ func (*OPT) parse(c *zlexer, origin string) *ParseError {
144143

145144
func (rr *OPT) isDuplicate(r2 RR) bool { return false }
146145

147-
// return the old value -> delete SetVersion?
148-
149146
// Version returns the EDNS version used. Only zero is defined.
150147
func (rr *OPT) Version() uint8 {
151148
return uint8(rr.Hdr.Ttl & 0x00FF0000 >> 16)
@@ -236,8 +233,8 @@ type EDNS0 interface {
236233
// e.Nsid = "AA"
237234
// o.Option = append(o.Option, e)
238235
type EDNS0_NSID struct {
239-
Code uint16 // Always EDNS0NSID
240-
Nsid string // This string needs to be hex encoded
236+
Code uint16 // always EDNS0NSID
237+
Nsid string // string needs to be hex encoded
241238
}
242239

243240
func (e *EDNS0_NSID) pack() ([]byte, error) {
@@ -275,7 +272,7 @@ func (e *EDNS0_NSID) copy() EDNS0 { return &EDNS0_NSID{e.Code, e.Nsid}
275272
// When packing it will apply SourceNetmask. If you need more advanced logic,
276273
// patches welcome and good luck.
277274
type EDNS0_SUBNET struct {
278-
Code uint16 // Always EDNS0SUBNET
275+
Code uint16 // always EDNS0SUBNET
279276
Family uint16 // 1 for IP, 2 for IP6
280277
SourceNetmask uint8
281278
SourceScope uint8
@@ -399,8 +396,8 @@ func (e *EDNS0_SUBNET) copy() EDNS0 {
399396
//
400397
// There is no guarantee that the Cookie string has a specific length.
401398
type EDNS0_COOKIE struct {
402-
Code uint16 // Always EDNS0COOKIE
403-
Cookie string // Hex-encoded cookie data
399+
Code uint16 // always EDNS0COOKIE
400+
Cookie string // hex encoded cookie data
404401
}
405402

406403
func (e *EDNS0_COOKIE) pack() ([]byte, error) {
@@ -430,7 +427,7 @@ func (e *EDNS0_COOKIE) copy() EDNS0 { return &EDNS0_COOKIE{e.Code, e.C
430427
// e.Lease = 120 // in seconds
431428
// o.Option = append(o.Option, e)
432429
type EDNS0_UL struct {
433-
Code uint16 // Always EDNS0UL
430+
Code uint16 // always EDNS0UL
434431
Lease uint32
435432
KeyLease uint32
436433
}
@@ -469,7 +466,7 @@ func (e *EDNS0_UL) unpack(b []byte) error {
469466
// EDNS0_LLQ stands for Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01
470467
// Implemented for completeness, as the EDNS0 type code is assigned.
471468
type EDNS0_LLQ struct {
472-
Code uint16 // Always EDNS0LLQ
469+
Code uint16 // always EDNS0LLQ
473470
Version uint16
474471
Opcode uint16
475472
Error uint16
@@ -515,7 +512,7 @@ func (e *EDNS0_LLQ) copy() EDNS0 {
515512

516513
// EDNS0_DAU implements the EDNS0 "DNSSEC Algorithm Understood" option. See RFC 6975.
517514
type EDNS0_DAU struct {
518-
Code uint16 // Always EDNS0DAU
515+
Code uint16 // always EDNS0DAU
519516
AlgCode []uint8
520517
}
521518

@@ -539,7 +536,7 @@ func (e *EDNS0_DAU) copy() EDNS0 { return &EDNS0_DAU{e.Code, e.AlgCode} }
539536

540537
// EDNS0_DHU implements the EDNS0 "DS Hash Understood" option. See RFC 6975.
541538
type EDNS0_DHU struct {
542-
Code uint16 // Always EDNS0DHU
539+
Code uint16 // always EDNS0DHU
543540
AlgCode []uint8
544541
}
545542

@@ -563,7 +560,7 @@ func (e *EDNS0_DHU) copy() EDNS0 { return &EDNS0_DHU{e.Code, e.AlgCode} }
563560

564561
// EDNS0_N3U implements the EDNS0 "NSEC3 Hash Understood" option. See RFC 6975.
565562
type EDNS0_N3U struct {
566-
Code uint16 // Always EDNS0N3U
563+
Code uint16 // always EDNS0N3U
567564
AlgCode []uint8
568565
}
569566

@@ -588,7 +585,7 @@ func (e *EDNS0_N3U) copy() EDNS0 { return &EDNS0_N3U{e.Code, e.AlgCode} }
588585

589586
// EDNS0_EXPIRE implements the EDNS0 option as described in RFC 7314.
590587
type EDNS0_EXPIRE struct {
591-
Code uint16 // Always EDNS0EXPIRE
588+
Code uint16 // always EDNS0EXPIRE
592589
Expire uint32
593590
Empty bool // Empty is used to signal an empty Expire option in a backwards compatible way, it's not used on the wire.
594591
}
@@ -668,7 +665,7 @@ func (e *EDNS0_LOCAL) unpack(b []byte) error {
668665
// EDNS0_TCP_KEEPALIVE is an EDNS0 option that instructs the server to keep
669666
// the TCP connection alive. See RFC 7828.
670667
type EDNS0_TCP_KEEPALIVE struct {
671-
Code uint16 // Always EDNSTCPKEEPALIVE
668+
Code uint16 // always EDNSTCPKEEPALIVE
672669

673670
// Timeout is an idle timeout value for the TCP connection, specified in
674671
// units of 100 milliseconds, encoded in network byte order. If set to 0,
@@ -839,13 +836,12 @@ func (e *EDNS0_EDE) unpack(b []byte) error {
839836
return nil
840837
}
841838

842-
// The EDNS0_ESU option for ENUM Source-URI Extension
839+
// The EDNS0_ESU option for ENUM Source-URI Extension.
843840
type EDNS0_ESU struct {
844-
Code uint16
841+
Code uint16 // always EDNS0ESU
845842
Uri string
846843
}
847844

848-
// Option implements the EDNS0 interface.
849845
func (e *EDNS0_ESU) Option() uint16 { return EDNS0ESU }
850846
func (e *EDNS0_ESU) String() string { return e.Uri }
851847
func (e *EDNS0_ESU) copy() EDNS0 { return &EDNS0_ESU{e.Code, e.Uri} }

0 commit comments

Comments
 (0)