Skip to content

Commit

Permalink
Tweaks (#1425)
Browse files Browse the repository at this point in the history
* fix typo

* more IPSECKEY/AMTRELAY tests

* avoid bytes.Equal for IP comparison

* *_generate: convert fprintf with no argument to fprint, add newlines to ztypes so gofumpt doesn't try to fix it
  • Loading branch information
monoidic committed Mar 2, 2023
1 parent 8f21ecc commit 85afa11
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 8 deletions.
2 changes: 1 addition & 1 deletion duplicate_generate.go

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

2 changes: 1 addition & 1 deletion msg_generate.go

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

9 changes: 7 additions & 2 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,10 @@ func TestParseZONEMD(t *testing.T) {

func TestParseIPSECKEY(t *testing.T) {
dt := map[string]string{
"ipseckey. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==": "ipseckey.\t3600\tIN\tIPSECKEY\t10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==",
"ipseckey. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==": "ipseckey.\t3600\tIN\tIPSECKEY\t10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==",
"ipseckey. 3600 IN IPSECKEY 10 1 2 1.2.3.4 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==": "ipseckey.\t3600\tIN\tIPSECKEY\t10 1 2 1.2.3.4 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==",
"ipseckey. 3600 IN IPSECKEY 10 2 2 2001:470:30:84:e276:63ff:fe72:3900 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==": "ipseckey.\t3600\tIN\tIPSECKEY\t10 2 2 2001:470:30:84:e276:63ff:fe72:3900 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==",
"ipseckey. 3600 IN IPSECKEY 10 3 2 ipseckey2. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==": "ipseckey.\t3600\tIN\tIPSECKEY\t10 3 2 ipseckey2. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==",
}

for i, o := range dt {
Expand All @@ -2031,8 +2034,10 @@ func TestParseIPSECKEY(t *testing.T) {

func TestParseAMTRELAY(t *testing.T) {
dt := map[string]string{
"amtrelay. 3600 IN AMTRELAY 10 0 2 2001:470:30:84:e276:63ff:fe72:3900": "amtrelay.\t3600\tIN\tAMTRELAY\t10 0 2 2001:470:30:84:e276:63ff:fe72:3900",
"amtrelay. 3600 IN AMTRELAY 10 0 0 .": "amtrelay.\t3600\tIN\tAMTRELAY\t10 0 0 .",
"amtrelay. 3600 IN AMTRELAY 10 0 1 1.2.3.4": "amtrelay.\t3600\tIN\tAMTRELAY\t10 0 1 1.2.3.4",
"amtrelay. 3600 IN AMTRELAY 10 1 2 2001:470:30:84:e276:63ff:fe72:3900": "amtrelay.\t3600\tIN\tAMTRELAY\t10 1 2 2001:470:30:84:e276:63ff:fe72:3900",
"amtrelay. 3600 IN AMTRELAY 10 1 3 amtrelay2.": "amtrelay.\t3600\tIN\tAMTRELAY\t10 1 3 amtrelay2.",
}

for i, o := range dt {
Expand Down
2 changes: 1 addition & 1 deletion scan_rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ func (rr *IPSECKEY) parse(c *zlexer, o string) *ParseError {

rr.GatewayAddr, rr.GatewayHost, err = parseAddrHostUnion(l.token, o, rr.GatewayType)
if err != nil {
return &ParseError{"", "AMTRELAY " + err.Error(), l}
return &ParseError{"", "IPSECKEY " + err.Error(), l}
}

c.Next() // zBlank
Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ func (a *APLPrefix) str() string {
// equals reports whether two APL prefixes are identical.
func (a *APLPrefix) equals(b *APLPrefix) bool {
return a.Negation == b.Negation &&
bytes.Equal(a.Network.IP, b.Network.IP) &&
a.Network.IP.Equal(b.Network.IP) &&
bytes.Equal(a.Network.Mask, b.Network.Mask)
}

Expand Down
4 changes: 2 additions & 2 deletions types_generate.go

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

Loading

0 comments on commit 85afa11

Please sign in to comment.