The preferred protocol will be a global (for Tor users)

This commit is contained in:
Frank Denis 2018-01-09 18:42:24 +01:00
parent ce5e0c8031
commit 888db6a8fb
2 changed files with 6 additions and 8 deletions

View File

@ -17,16 +17,17 @@ type Proxy struct {
questionSizeEstimator QuestionSizeEstimator
serversInfo ServersInfo
timeout time.Duration
mainProto string
}
func main() {
log.SetFlags(0)
stamp, _ := NewServerStampFromLegacy("212.47.228.136:443", "E801:B84E:A606:BFB0:BAC0:CE43:445B:B15E:BA64:B02F:A3C4:AA31:AE10:636A:0790:324D", "2.dnscrypt-cert.fr.dnscrypt.org")
NewProxy("127.0.0.1:5399", "dnscrypt.org-fr", stamp)
NewProxy("127.0.0.1:5399", "dnscrypt.org-fr", stamp, "udp")
}
func NewProxy(listenAddrStr string, serverName string, stamp ServerStamp) {
proxy := Proxy{questionSizeEstimator: NewQuestionSizeEstimator(), timeout: TimeoutMax}
func NewProxy(listenAddrStr string, serverName string, stamp ServerStamp, mainProto string) {
proxy := Proxy{questionSizeEstimator: NewQuestionSizeEstimator(), timeout: TimeoutMax, mainProto: mainProto}
if _, err := rand.Read(proxy.proxySecretKey[:]); err != nil {
log.Fatal(err)
}

View File

@ -89,13 +89,10 @@ func (serversInfo *ServersInfo) fetchServerInfo(proxy *Proxy, name string, stamp
if err != nil || len(serverPk) != ed25519.PublicKeySize {
log.Fatal("Invalid public key")
}
certInfo, err := FetchCurrentCert(proxy, "udp", serverPk, stamp.serverAddrStr, stamp.providerName)
if err != nil {
certInfo, err = FetchCurrentCert(proxy, "tcp", serverPk, stamp.serverAddrStr, stamp.providerName)
certInfo, err := FetchCurrentCert(proxy, proxy.mainProto, serverPk, stamp.serverAddrStr, stamp.providerName)
if err != nil {
return ServerInfo{}, err
}
}
remoteUDPAddr, err := net.ResolveUDPAddr("udp", stamp.serverAddrStr)
if err != nil {
return ServerInfo{}, err