Skip to content

Commit 85f8aa1

Browse files
committed
Fix stamp proto initialization
1 parent eca7a07 commit 85f8aa1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

dnscrypt-proxy/stamps.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) {
5959
if len(bin) < 1 {
6060
return ServerStamp{}, errors.New("Stamp is too short")
6161
}
62-
if bin[0] != uint8(StampProtoTypeDNSCrypt) {
62+
if bin[0] == uint8(StampProtoTypeDNSCrypt) {
6363
return newDNSCryptServerStamp(bin)
64+
} else if bin[0] == uint8(StampProtoTypeDoH) {
65+
return newDoHServerStamp(bin)
6466
}
6567
return ServerStamp{}, errors.New("Unsupported stamp version or protocol")
6668
}
6769

6870
// id(u8)=0x02 props addrLen(1) serverAddr pkStrlen(1) pkStr providerNameLen(1) providerName
6971

7072
func newDNSCryptServerStamp(bin []byte) (ServerStamp, error) {
71-
stamp := ServerStamp{}
73+
stamp := ServerStamp{proto:StampProtoTypeDNSCrypt}
7274
if len(bin) < 24 {
7375
return stamp, errors.New("Stamp is too short")
7476
}
@@ -109,7 +111,7 @@ func newDNSCryptServerStamp(bin []byte) (ServerStamp, error) {
109111
// id(u8)=0x02 props addrLen(1) serverAddr hashLen(1) hash providerNameLen(1) providerName pathLen(1) path
110112

111113
func newDoHServerStamp(bin []byte) (ServerStamp, error) {
112-
stamp := ServerStamp{}
114+
stamp := ServerStamp{proto:StampProtoTypeDoH}
113115

114116
stamp.props = ServerInformalProperties(binary.LittleEndian.Uint64(bin[1:9]))
115117
binLen := len(bin)

0 commit comments

Comments
 (0)