Reserve identifiers for traditional nonencrypted DNS and for DoH
This commit is contained in:
parent
f6a9229e2f
commit
054461e240
|
@ -12,6 +12,14 @@ import (
|
||||||
"golang.org/x/crypto/ed25519"
|
"golang.org/x/crypto/ed25519"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type StampProtoType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
StampProtoTypePlain = StampProtoType(0x00)
|
||||||
|
StampProtoTypeDNSCrypt = StampProtoType(0x01)
|
||||||
|
StampProtoTypeDoH = StampProtoType(0x02)
|
||||||
|
)
|
||||||
|
|
||||||
type ServerStamp struct {
|
type ServerStamp struct {
|
||||||
serverAddrStr string
|
serverAddrStr string
|
||||||
serverPk []uint8
|
serverPk []uint8
|
||||||
|
@ -49,7 +57,7 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) {
|
||||||
if len(bin) < 24 {
|
if len(bin) < 24 {
|
||||||
return stamp, errors.New("Stamp is too short")
|
return stamp, errors.New("Stamp is too short")
|
||||||
}
|
}
|
||||||
if bin[0] != 0x01 {
|
if bin[0] != uint8(StampProtoTypeDNSCrypt) {
|
||||||
return stamp, errors.New("Unsupported stamp version")
|
return stamp, errors.New("Unsupported stamp version")
|
||||||
}
|
}
|
||||||
stamp.props = ServerInformalProperties(binary.LittleEndian.Uint64(bin[1:9]))
|
stamp.props = ServerInformalProperties(binary.LittleEndian.Uint64(bin[1:9]))
|
||||||
|
@ -88,7 +96,7 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) {
|
||||||
|
|
||||||
func (stamp *ServerStamp) String() string {
|
func (stamp *ServerStamp) String() string {
|
||||||
bin := make([]uint8, 9)
|
bin := make([]uint8, 9)
|
||||||
bin[0] = 0x01
|
bin[0] = uint8(StampProtoTypeDNSCrypt)
|
||||||
binary.LittleEndian.PutUint64(bin[1:9], uint64(stamp.props))
|
binary.LittleEndian.PutUint64(bin[1:9], uint64(stamp.props))
|
||||||
|
|
||||||
bin = append(bin, uint8(len(stamp.serverAddrStr)))
|
bin = append(bin, uint8(len(stamp.serverAddrStr)))
|
||||||
|
|
Loading…
Reference in New Issue