@@ -21,19 +21,19 @@ type CertInfo struct {
2121 CryptoConstruction CryptoConstruction
2222}
2323
24- func FetchCurrentCert (proxy * Proxy , proto string , pk ed25519.PublicKey , serverAddress string , providerName string ) (CertInfo , error ) {
24+ func FetchCurrentCert (proxy * Proxy , proto string , pk ed25519.PublicKey , serverAddress string , providerName string ) (CertInfo , int , error ) {
2525 if len (pk ) != ed25519 .PublicKeySize {
26- return CertInfo {}, errors .New ("Invalid public key length" )
26+ return CertInfo {}, 0 , errors .New ("Invalid public key length" )
2727 }
2828 if ! strings .HasSuffix (providerName , "." ) {
2929 providerName = providerName + "."
3030 }
3131 query := new (dns.Msg )
3232 query .SetQuestion (providerName , dns .TypeTXT )
3333 client := dns.Client {Net : proto , UDPSize : uint16 (MaxDNSUDPPacketSize )}
34- in , _ , err := client .Exchange (query , serverAddress )
34+ in , rtt , err := client .Exchange (query , serverAddress )
3535 if err != nil {
36- return CertInfo {}, err
36+ return CertInfo {}, 0 , err
3737 }
3838 now := uint32 (time .Now ().Unix ())
3939 certInfo := CertInfo {CryptoConstruction : UndefinedConstruction }
@@ -108,12 +108,12 @@ func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAd
108108 certInfo .CryptoConstruction = cryptoConstruction
109109 copy (certInfo .ServerPk [:], serverPk [:])
110110 copy (certInfo .MagicQuery [:], binCert [104 :112 ])
111- dlog .Noticef ("[%v] Valid cert (crypto version %d) found" , providerName , cryptoConstruction )
111+ dlog .Noticef ("[%v] Valid cert (crypto version %d) found - rtt: %dms " , providerName , cryptoConstruction , rtt . Nanoseconds () / 1000000 )
112112 }
113113 if certInfo .CryptoConstruction == UndefinedConstruction {
114- return certInfo , errors .New ("No useable certificate found" )
114+ return certInfo , 0 , errors .New ("No useable certificate found" )
115115 }
116- return certInfo , nil
116+ return certInfo , int ( rtt . Nanoseconds () / 1000000 ), nil
117117}
118118
119119func isDigit (b byte ) bool { return b >= '0' && b <= '9' }
0 commit comments