Try to retrieve the certificates using UDP before TCP
This commit is contained in:
parent
841bf65d61
commit
ce5e0c8031
|
@ -20,7 +20,7 @@ type CertInfo struct {
|
||||||
CryptoConstruction CryptoConstruction
|
CryptoConstruction CryptoConstruction
|
||||||
}
|
}
|
||||||
|
|
||||||
func FetchCurrentCert(proxy *Proxy, pk ed25519.PublicKey, serverAddress string, providerName string) (CertInfo, error) {
|
func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAddress string, providerName string) (CertInfo, error) {
|
||||||
if len(pk) != ed25519.PublicKeySize {
|
if len(pk) != ed25519.PublicKeySize {
|
||||||
return CertInfo{}, errors.New("Invalid public key length")
|
return CertInfo{}, errors.New("Invalid public key length")
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ func FetchCurrentCert(proxy *Proxy, pk ed25519.PublicKey, serverAddress string,
|
||||||
}
|
}
|
||||||
query := new(dns.Msg)
|
query := new(dns.Msg)
|
||||||
query.SetQuestion(providerName, dns.TypeTXT)
|
query.SetQuestion(providerName, dns.TypeTXT)
|
||||||
client := dns.Client{Net: "tcp", UDPSize: 1252}
|
client := dns.Client{Net: proto, UDPSize: uint16(MaxDNSUDPPacketSize)}
|
||||||
in, _, err := client.Exchange(query, serverAddress)
|
in, _, err := client.Exchange(query, serverAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -89,10 +89,13 @@ func (serversInfo *ServersInfo) fetchServerInfo(proxy *Proxy, name string, stamp
|
||||||
if err != nil || len(serverPk) != ed25519.PublicKeySize {
|
if err != nil || len(serverPk) != ed25519.PublicKeySize {
|
||||||
log.Fatal("Invalid public key")
|
log.Fatal("Invalid public key")
|
||||||
}
|
}
|
||||||
certInfo, err := FetchCurrentCert(proxy, serverPk, stamp.serverAddrStr, stamp.providerName)
|
certInfo, err := FetchCurrentCert(proxy, "udp", serverPk, stamp.serverAddrStr, stamp.providerName)
|
||||||
|
if err != nil {
|
||||||
|
certInfo, err = FetchCurrentCert(proxy, "tcp", serverPk, stamp.serverAddrStr, stamp.providerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ServerInfo{}, err
|
return ServerInfo{}, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
remoteUDPAddr, err := net.ResolveUDPAddr("udp", stamp.serverAddrStr)
|
remoteUDPAddr, err := net.ResolveUDPAddr("udp", stamp.serverAddrStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ServerInfo{}, err
|
return ServerInfo{}, err
|
||||||
|
|
Loading…
Reference in New Issue