@@ -518,8 +518,9 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
518
518
// https://blog.gypsyengineer.com/en/security/how-does-tls-1-3-protect-against-downgrade-attacks.html
519
519
cs := tlsConn .ConnectionState ()
520
520
tlsState = & cs
521
+ c .logf ("%s: TLS version 0x%x" , caller , cs .Version )
521
522
if cs .Version >= tls .VersionTLS13 {
522
- serverPub , serverProtoVersion = parseMetaCert (cs .PeerCertificates )
523
+ serverPub , serverProtoVersion = parseMetaCert (c . logf , cs .PeerCertificates )
523
524
}
524
525
} else {
525
526
httpConn = tcpConn
@@ -556,13 +557,15 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
556
557
// just to get routed into the server's HTTP Handler so it
557
558
// can Hijack the request, but we signal with a special header
558
559
// that we don't want to deal with its HTTP response.
560
+ c .logf ("%s: using fast start" , caller )
559
561
req .Header .Set (fastStartHeader , "1" ) // suppresses the server's HTTP response
560
562
if err := req .Write (brw ); err != nil {
561
563
return nil , 0 , err
562
564
}
563
565
// No need to flush the HTTP request. the derp.Client's initial
564
566
// client auth frame will flush it.
565
567
} else {
568
+ c .logf ("%s: not using fast start" , caller )
566
569
if err := req .Write (brw ); err != nil {
567
570
return nil , 0 , err
568
571
}
@@ -574,6 +577,7 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
574
577
if err != nil {
575
578
return nil , 0 , err
576
579
}
580
+ c .logf ("%s: DERP server returned status %d" , caller , resp .StatusCode )
577
581
if resp .StatusCode != http .StatusSwitchingProtocols {
578
582
b , _ := io .ReadAll (resp .Body )
579
583
resp .Body .Close ()
@@ -1206,8 +1210,9 @@ func (c *Client) closeForReconnect(brokenClient *derp.Client) {
1206
1210
1207
1211
var ErrClientClosed = errors .New ("derphttp.Client closed" )
1208
1212
1209
- func parseMetaCert (certs []* x509.Certificate ) (serverPub key.NodePublic , serverProtoVersion int ) {
1213
+ func parseMetaCert (logf logger. Logf , certs []* x509.Certificate ) (serverPub key.NodePublic , serverProtoVersion int ) {
1210
1214
for _ , cert := range certs {
1215
+ logf ("derpclient: got cert %s" , cert .Subject .CommonName )
1211
1216
// Look for derpkey prefix added by initMetacert() on the server side.
1212
1217
if pubHex , ok := strings .CutPrefix (cert .Subject .CommonName , "derpkey" ); ok {
1213
1218
var err error
0 commit comments