New Upstream Snapshot - golang-github-jedisct1-go-dnsstamps

Ready changes

Summary

Merged new upstream version: 0.1.4+ds (was: 0.1.3).

Resulting package

Built on 2022-11-18T11:36 (took 5m33s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-jedisct1-go-dnsstamps-dev

Lintian Result

Diff

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index a1338d6..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-# Binaries for programs and plugins
-*.exe
-*.dll
-*.so
-*.dylib
-
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
-.glide/
diff --git a/LICENSE b/LICENSE
index 23ba07f..010ad6e 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2018-2020 Frank Denis
+Copyright (c) 2018-2021 Frank Denis
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/debian/changelog b/debian/changelog
index 74d6769..e80c882 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-jedisct1-go-dnsstamps (0.1.4+ds-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 18 Nov 2022 11:32:42 -0000
+
 golang-github-jedisct1-go-dnsstamps (0.1.3-1) unstable; urgency=medium
 
   [ Eric Dorland ]
diff --git a/dnsstamps.go b/dnsstamps.go
index 9fd6974..64995b0 100644
--- a/dnsstamps.go
+++ b/dnsstamps.go
@@ -111,6 +111,32 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) {
 	return ServerStamp{}, errors.New("Unsupported stamp version or protocol")
 }
 
+func NewRelayAndServerStampFromString(stampStr string) (ServerStamp, ServerStamp, error) {
+	if !strings.HasPrefix(stampStr, "sdns://") {
+		return ServerStamp{}, ServerStamp{}, errors.New("Stamps are expected to start with \"sdns://\"")
+	}
+	stampStr = stampStr[7:]
+	parts := strings.Split(stampStr, "/")
+	if len(parts) != 2 {
+		return ServerStamp{}, ServerStamp{}, errors.New("This is not a relay+server stamp")
+	}
+	relayStamp, err := NewServerStampFromString("sdns://" + parts[0])
+	if err != nil {
+		return ServerStamp{}, ServerStamp{}, err
+	}
+	serverStamp, err := NewServerStampFromString("sdns://" + parts[1])
+	if err != nil {
+		return ServerStamp{}, ServerStamp{}, err
+	}
+	if relayStamp.Proto != StampProtoTypeDNSCryptRelay && relayStamp.Proto != StampProtoTypeODoHRelay {
+		return ServerStamp{}, ServerStamp{}, errors.New("First stamp is not a relay")
+	}
+	if !(serverStamp.Proto != StampProtoTypeDNSCryptRelay && serverStamp.Proto != StampProtoTypeODoHRelay) {
+		return ServerStamp{}, ServerStamp{}, errors.New("Second stamp is a relay")
+	}
+	return relayStamp, serverStamp, nil
+}
+
 // id(u8)=0x01 props addrLen(1) serverAddr pkStrlen(1) pkStr providerNameLen(1) providerName
 
 func newDNSCryptServerStamp(bin []byte) (ServerStamp, error) {
@@ -177,7 +203,7 @@ func newDNSCryptServerStamp(bin []byte) (ServerStamp, error) {
 
 func newDoHServerStamp(bin []byte) (ServerStamp, error) {
 	stamp := ServerStamp{Proto: StampProtoTypeDoH}
-	if len(bin) < 22 {
+	if len(bin) < 15 {
 		return stamp, errors.New("Stamp is too short")
 	}
 	stamp.Props = ServerInformalProperties(binary.LittleEndian.Uint64(bin[1:9]))
@@ -292,7 +318,7 @@ func newODoHTargetStamp(bin []byte) (ServerStamp, error) {
 
 func newDNSCryptRelayStamp(bin []byte) (ServerStamp, error) {
 	stamp := ServerStamp{Proto: StampProtoTypeDNSCryptRelay}
-	if len(bin) < 13 {
+	if len(bin) < 9 {
 		return stamp, errors.New("Stamp is too short")
 	}
 	binLen := len(bin)
diff --git a/dnsstamps_test.go b/dnsstamps_test.go
index c9aaf4f..2396d9b 100644
--- a/dnsstamps_test.go
+++ b/dnsstamps_test.go
@@ -120,3 +120,11 @@ func TestODoHRelay(t *testing.T) {
 		t.Errorf("re-parsed stamp string is %q, but %q expected", ps, stamp)
 	}
 }
+
+func TestRelayServerPair(t *testing.T) {
+	const stamp = `sdns://hQcAAAAAAAAAB1s6OjFdOjGCq80CASMPZG9oLmV4YW1wbGUuY29tBi9yZWxheQ/BQcAAAAAAAAAEG9kb2guZXhhbXBsZS5jb20HL3RhcmdldA`
+	_, _, err := NewRelayAndServerStampFromString(stamp)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
diff --git a/go.mod b/go.mod
index 828c882..ab8c494 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
 module github.com/jedisct1/go-dnsstamps
 
-go 1.15
+go 1.18

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details