From 8118f95cbbc91c43c786ac239303d42cbb0b3769 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 3 Apr 2024 02:12:07 +0700 Subject: [PATCH] lib/dns: fix unpacking ipv4hint on SVCB record Somehow the test passed on my main machine, but failed on my laptop. Weird. --- lib/dns/message_test.go | 2 +- lib/dns/rdata_svcb.go | 1 + lib/dns/testdata/message/UnpackMessage_SVCB_test.txt | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/dns/message_test.go b/lib/dns/message_test.go index 5c6fc451..bd8ead34 100644 --- a/lib/dns/message_test.go +++ b/lib/dns/message_test.go @@ -2116,7 +2116,7 @@ func TestUnpackMessage_SVCB(t *testing.T) { msg, err = UnpackMessage(stream) if err != nil { - t.Fatal(logp, err) + t.Fatal(logp, name, err) } stream, err = json.MarshalIndent(&msg, ``, ` `) diff --git a/lib/dns/rdata_svcb.go b/lib/dns/rdata_svcb.go index e97eb078..474c7185 100644 --- a/lib/dns/rdata_svcb.go +++ b/lib/dns/rdata_svcb.go @@ -735,6 +735,7 @@ func (svcb *RDataSVCB) unpackParamIpv4hint(packet []byte) ([]byte, error) { var ip = net.IP(packet[0:4]) packet = packet[4:] listValue = append(listValue, ip.String()) + n-- } svcb.Params[svcbKeyIDIpv4hint] = listValue diff --git a/lib/dns/testdata/message/UnpackMessage_SVCB_test.txt b/lib/dns/testdata/message/UnpackMessage_SVCB_test.txt index e3237f7a..8454905f 100644 --- a/lib/dns/testdata/message/UnpackMessage_SVCB_test.txt +++ b/lib/dns/testdata/message/UnpackMessage_SVCB_test.txt @@ -356,6 +356,9 @@ The test input taken from output of parsing SVCB record from zone file. "1": [ "h2", "h3-19" + ], + "4": [ + "192.0.2.1" ] }, "TargetName": "foo.example.org",