diff --git a/aurp/zone_info_test.go b/aurp/zone_info_test.go new file mode 100644 index 0000000..b9b52c3 --- /dev/null +++ b/aurp/zone_info_test.go @@ -0,0 +1,30 @@ +package aurp + +import ( + "bytes" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestZoneTuplesEncoding(t *testing.T) { + zones := ZoneTuples{ + { + Network: 0x64, + Name: "The Twilight Zone", + }, + } + + b := bytes.NewBuffer(nil) + zones.WriteTo(b) + + got := b.Bytes() + want := append([]byte{ + 0x00, 0x01, // Number of zone tuples + 0x00, 0x64, // Network number + 0x11, // Length of string + }, zones[0].Name...) + if diff := cmp.Diff(got, want); diff != "" { + t.Errorf("encoded zone tuples diff (-got +want):\n%s", diff) + } +} diff --git a/go.mod b/go.mod index 16aa3c1..52b4ad9 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module gitea.drjosh.dev/josh/jrouter go 1.22.0 -require gopkg.in/yaml.v3 v3.0.1 +require ( + github.com/google/go-cmp v0.6.0 + gopkg.in/yaml.v3 v3.0.1 +) diff --git a/go.sum b/go.sum index 4bc0337..9d8a8fa 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/jrouter.yaml b/jrouter.yaml index 540e521..a2dde95 100644 --- a/jrouter.yaml +++ b/jrouter.yaml @@ -1,7 +1,7 @@ ethertalk: zone: The Twilight Zone net_start: 100 - net_end: 109 + net_end: 100 open_peering: true peers: diff --git a/main.go b/main.go index c387739..3b9582b 100644 --- a/main.go +++ b/main.go @@ -55,6 +55,8 @@ func main() { log.Printf("Using %v as local domain identifier", localIP) + log.Printf("EtherTalk configuration: %+v", cfg.EtherTalk) + peers := make(map[udpAddr]*peer) var nextConnID uint16