7
7
"strings"
8
8
"time"
9
9
10
- "github.com/golang/glog "
10
+ "github.com/jedisct1/dlog "
11
11
"github.com/jedisct1/xsecretbox"
12
12
"github.com/miekg/dns"
13
13
"golang.org/x/crypto/ed25519"
@@ -41,15 +41,15 @@ func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAd
41
41
for _ , answerRr := range in .Answer {
42
42
binCert , err := packTxtString (strings .Join (answerRr .(* dns.TXT ).Txt , "" ))
43
43
if err != nil {
44
- glog . Warningf ("[%v] Unable to unpack the certificate" , providerName )
44
+ dlog . Warnf ("[%v] Unable to unpack the certificate" , providerName )
45
45
continue
46
46
}
47
47
if len (binCert ) < 124 {
48
- glog . Warningf ("[%v] Certificate too short" , providerName )
48
+ dlog . Warnf ("[%v] Certificate too short" , providerName )
49
49
continue
50
50
}
51
51
if ! bytes .Equal (binCert [:4 ], CertMagic [:4 ]) {
52
- glog . Warningf ("[%v] Invalid cert magic" , providerName )
52
+ dlog . Warnf ("[%v] Invalid cert magic" , providerName )
53
53
continue
54
54
}
55
55
cryptoConstruction := CryptoConstruction (0 )
@@ -59,36 +59,36 @@ func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAd
59
59
case 0x0002 :
60
60
cryptoConstruction = XChacha20Poly1305
61
61
default :
62
- glog .Infof ("[%v] Unsupported crypto construction" , providerName )
62
+ dlog .Infof ("[%v] Unsupported crypto construction" , providerName )
63
63
continue
64
64
}
65
65
signature := binCert [8 :72 ]
66
66
signed := binCert [72 :]
67
67
if ! ed25519 .Verify (pk , signed , signature ) {
68
- glog . Warningf ("[%v] Incorrect signature" , providerName )
68
+ dlog . Warnf ("[%v] Incorrect signature" , providerName )
69
69
continue
70
70
}
71
71
serial := binary .BigEndian .Uint32 (binCert [112 :116 ])
72
72
tsBegin := binary .BigEndian .Uint32 (binCert [116 :120 ])
73
73
tsEnd := binary .BigEndian .Uint32 (binCert [120 :124 ])
74
74
if now > tsEnd || now < tsBegin {
75
- glog .Infof ("[%v] Certificate not valid at the current date" , providerName )
75
+ dlog .Infof ("[%v] Certificate not valid at the current date" , providerName )
76
76
continue
77
77
}
78
78
if serial < highestSerial {
79
- glog .Infof ("[%v] Superseded by a previous certificate" , providerName )
79
+ dlog .Infof ("[%v] Superseded by a previous certificate" , providerName )
80
80
continue
81
81
}
82
82
if serial == highestSerial {
83
83
if cryptoConstruction < certInfo .CryptoConstruction {
84
- glog .Infof ("[%v] Keeping the previous, preferred crypto construction" , providerName )
84
+ dlog .Infof ("[%v] Keeping the previous, preferred crypto construction" , providerName )
85
85
continue
86
86
} else {
87
- glog .Infof ("[%v] Upgrading the construction from %v to %v" , providerName , certInfo .CryptoConstruction , cryptoConstruction )
87
+ dlog .Infof ("[%v] Upgrading the construction from %v to %v" , providerName , certInfo .CryptoConstruction , cryptoConstruction )
88
88
}
89
89
}
90
90
if cryptoConstruction != XChacha20Poly1305 && cryptoConstruction != XSalsa20Poly1305 {
91
- glog . Warningf ("[%v] Cryptographic construction %v not supported" , providerName , cryptoConstruction )
91
+ dlog . Warnf ("[%v] Cryptographic construction %v not supported" , providerName , cryptoConstruction )
92
92
continue
93
93
}
94
94
var serverPk [32 ]byte
@@ -97,7 +97,7 @@ func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAd
97
97
if cryptoConstruction == XChacha20Poly1305 {
98
98
sharedKey , err = xsecretbox .SharedKey (proxy .proxySecretKey , serverPk )
99
99
if err != nil {
100
- glog . Warningf ("[%v] Weak public key" , providerName )
100
+ dlog . Errorf ("[%v] Weak public key" , providerName )
101
101
continue
102
102
}
103
103
} else {
@@ -108,7 +108,7 @@ func FetchCurrentCert(proxy *Proxy, proto string, pk ed25519.PublicKey, serverAd
108
108
certInfo .CryptoConstruction = cryptoConstruction
109
109
copy (certInfo .ServerPk [:], serverPk [:])
110
110
copy (certInfo .MagicQuery [:], binCert [104 :112 ])
111
- glog . Infof ("[%v] Valid cert found: [%x]" , providerName , certInfo .ServerPk )
111
+ dlog . Noticef ("[%v] Valid cert found: [%x]" , providerName , certInfo .ServerPk )
112
112
}
113
113
if certInfo .CryptoConstruction == UndefinedConstruction {
114
114
return certInfo , errors .New ("No useable certificate found" )
0 commit comments