diff --git a/dnscrypt-proxy/dnscrypt-proxy.toml b/dnscrypt-proxy/dnscrypt-proxy.toml index e674662d..eb07a473 100644 --- a/dnscrypt-proxy/dnscrypt-proxy.toml +++ b/dnscrypt-proxy/dnscrypt-proxy.toml @@ -254,4 +254,4 @@ format = 'tsv' [servers] [servers.'scaleway-fr'] - stamp = 'sdns://AQMAAAAAAAAAEjIxMi40Ny4yMjguMTM2OjQ0M09FODAxOkI4NEU6QTYwNjpCRkIwOkJBQzA6Q0U0Mzo0NDVCOkIxNUU6QkE2NDpCMDJGOkEzQzQ6QUEzMTpBRTEwOjYzNkE6MDc5MDozMjREHzIuZG5zY3J5cHQtY2VydC5mci5kbnNjcnlwdC5vcmc' + stamp = 'dnsc://AQMAAAAAAAAAEjIxMi40Ny4yMjguMTM2OjQ0MyDoAbhOpga_sLrAzkNEW7FeumSwL6PEqjGuEGNqB5AyTR8yLmRuc2NyeXB0LWNlcnQuZnIuZG5zY3J5cHQub3Jn' diff --git a/dnscrypt-proxy/serversInfo.go b/dnscrypt-proxy/serversInfo.go index 09e10cd3..1acdbb95 100644 --- a/dnscrypt-proxy/serversInfo.go +++ b/dnscrypt-proxy/serversInfo.go @@ -144,7 +144,7 @@ func (serversInfo *ServersInfo) getOne() *ServerInfo { func (serversInfo *ServersInfo) fetchServerInfo(proxy *Proxy, name string, stamp ServerStamp) (ServerInfo, error) { serverPk, err := hex.DecodeString(strings.Replace(stamp.serverPkStr, ":", "", -1)) if err != nil || len(serverPk) != ed25519.PublicKeySize { - dlog.Fatalf("Unsupported public key: [%v]", serverPk) + dlog.Fatalf("Unsupported public key: [%v]", stamp.serverPkStr) } certInfo, rtt, err := FetchCurrentCert(proxy, &name, proxy.mainProto, serverPk, stamp.serverAddrStr, stamp.providerName) if err != nil { diff --git a/dnscrypt-proxy/stamps.go b/dnscrypt-proxy/stamps.go index 7eb4afb0..df8f4d54 100644 --- a/dnscrypt-proxy/stamps.go +++ b/dnscrypt-proxy/stamps.go @@ -3,10 +3,14 @@ package main import ( "encoding/base64" "encoding/binary" + "encoding/hex" "errors" "fmt" "net" "strings" + + "github.com/jedisct1/dlog" + "golang.org/x/crypto/ed25519" ) type ServerStamp struct { @@ -62,7 +66,11 @@ func NewServerStampFromString(stampStr string) (ServerStamp, error) { return stamp, errors.New("Invalid stamp") } pos++ - stamp.serverPkStr = string(bin[pos : pos+len]) + if len == ed25519.PublicKeySize { + stamp.serverPkStr = hex.EncodeToString(bin[pos : pos+len]) + } else { + stamp.serverPkStr = string(bin[pos : pos+len]) + } pos += len len = int(bin[pos]) @@ -87,8 +95,12 @@ func (stamp *ServerStamp) String() string { bin = append(bin, uint8(len(stamp.serverAddrStr))) bin = append(bin, []uint8(stamp.serverAddrStr)...) - bin = append(bin, uint8(len(stamp.serverPkStr))) - bin = append(bin, []uint8(stamp.serverPkStr)...) + serverPk, err := hex.DecodeString(strings.Replace(stamp.serverPkStr, ":", "", -1)) + if err != nil || len(serverPk) != ed25519.PublicKeySize { + dlog.Fatalf("Unsupported public key: [%s]", stamp.serverPkStr) + } + bin = append(bin, uint8(len(serverPk))) + bin = append(bin, serverPk...) bin = append(bin, uint8(len(stamp.providerName))) bin = append(bin, []uint8(stamp.providerName)...)