From 054461e2405893bb9c2de59310d4600817db80d4 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 25 Jan 2018 14:31:18 +0100 Subject: [PATCH] Reserve identifiers for traditional nonencrypted DNS and for DoH --- dnscrypt-proxy/stamps.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dnscrypt-proxy/stamps.go b/dnscrypt-proxy/stamps.go index 58bfe083..1bbfb107 100644 --- a/dnscrypt-proxy/stamps.go +++ b/dnscrypt-proxy/stamps.go @@ -12,6 +12,14 @@ import ( "golang.org/x/crypto/ed25519" ) +type StampProtoType uint8 + +const ( + StampProtoTypePlain = StampProtoType(0x00) + StampProtoTypeDNSCrypt = StampProtoType(0x01) + StampProtoTypeDoH = StampProtoType(0x02) +) + type ServerStamp struct { serverAddrStr string serverPk []uint8 @@ -49,7 +57,7 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) { if len(bin) < 24 { return stamp, errors.New("Stamp is too short") } - if bin[0] != 0x01 { + if bin[0] != uint8(StampProtoTypeDNSCrypt) { return stamp, errors.New("Unsupported stamp version") } stamp.props = ServerInformalProperties(binary.LittleEndian.Uint64(bin[1:9])) @@ -88,7 +96,7 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) { func (stamp *ServerStamp) String() string { bin := make([]uint8, 9) - bin[0] = 0x01 + bin[0] = uint8(StampProtoTypeDNSCrypt) binary.LittleEndian.PutUint64(bin[1:9], uint64(stamp.props)) bin = append(bin, uint8(len(stamp.serverAddrStr)))