|
|
|
@ -8,6 +8,7 @@ package magicsock
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"crypto/tls"
|
|
|
|
"encoding/binary"
|
|
|
|
"encoding/binary"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
@ -84,6 +85,7 @@ type Conn struct {
|
|
|
|
derpConn map[int]*derphttp.Client // magic derp port (see derpmap.go) to its client
|
|
|
|
derpConn map[int]*derphttp.Client // magic derp port (see derpmap.go) to its client
|
|
|
|
derpCancel map[int]context.CancelFunc // to close derp goroutines
|
|
|
|
derpCancel map[int]context.CancelFunc // to close derp goroutines
|
|
|
|
derpWriteCh map[int]chan<- derpWriteRequest
|
|
|
|
derpWriteCh map[int]chan<- derpWriteRequest
|
|
|
|
|
|
|
|
derpTLSConfig *tls.Config // normally nil; used by tests
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// udpAddr is the key in the addrsByUDP map.
|
|
|
|
// udpAddr is the key in the addrsByUDP map.
|
|
|
|
@ -612,6 +614,7 @@ func (c *Conn) derpWriteChanOfAddr(addr *net.UDPAddr) chan<- derpWriteRequest {
|
|
|
|
c.logf("derphttp.NewClient: port %d, host %q invalid? err: %v", addr.Port, host, err)
|
|
|
|
c.logf("derphttp.NewClient: port %d, host %q invalid? err: %v", addr.Port, host, err)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dc.TLSConfig = c.derpTLSConfig
|
|
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
// TODO: close derp channels (if addr.Port != myDerp) on inactivity timer
|
|
|
|
// TODO: close derp channels (if addr.Port != myDerp) on inactivity timer
|
|
|
|
|