|
|
@ -24,6 +24,7 @@ import (
|
|
|
|
"github.com/tailscale/wireguard-go/conn"
|
|
|
|
"github.com/tailscale/wireguard-go/conn"
|
|
|
|
"github.com/tailscale/wireguard-go/device"
|
|
|
|
"github.com/tailscale/wireguard-go/device"
|
|
|
|
"github.com/tailscale/wireguard-go/wgcfg"
|
|
|
|
"github.com/tailscale/wireguard-go/wgcfg"
|
|
|
|
|
|
|
|
"golang.org/x/time/rate"
|
|
|
|
"tailscale.com/derp"
|
|
|
|
"tailscale.com/derp"
|
|
|
|
"tailscale.com/derp/derphttp"
|
|
|
|
"tailscale.com/derp/derphttp"
|
|
|
|
"tailscale.com/stun"
|
|
|
|
"tailscale.com/stun"
|
|
|
@ -41,6 +42,7 @@ type Conn struct {
|
|
|
|
epFunc func(endpoints []string)
|
|
|
|
epFunc func(endpoints []string)
|
|
|
|
logf func(format string, args ...interface{})
|
|
|
|
logf func(format string, args ...interface{})
|
|
|
|
donec chan struct{} // closed on Conn.Close
|
|
|
|
donec chan struct{} // closed on Conn.Close
|
|
|
|
|
|
|
|
sendLogLimit *rate.Limiter
|
|
|
|
|
|
|
|
|
|
|
|
epUpdateCtx context.Context // endpoint updater context
|
|
|
|
epUpdateCtx context.Context // endpoint updater context
|
|
|
|
epUpdateCancel func() // the func to cancel epUpdateCtx
|
|
|
|
epUpdateCancel func() // the func to cancel epUpdateCtx
|
|
|
@ -138,6 +140,7 @@ func Listen(opts Options) (*Conn, error) {
|
|
|
|
pconn: new(RebindingUDPConn),
|
|
|
|
pconn: new(RebindingUDPConn),
|
|
|
|
pconnPort: opts.Port,
|
|
|
|
pconnPort: opts.Port,
|
|
|
|
donec: make(chan struct{}),
|
|
|
|
donec: make(chan struct{}),
|
|
|
|
|
|
|
|
sendLogLimit: rate.NewLimiter(rate.Every(1*time.Minute), 1),
|
|
|
|
stunServers: append([]string{}, opts.STUN...),
|
|
|
|
stunServers: append([]string{}, opts.STUN...),
|
|
|
|
startEpUpdate: make(chan struct{}, 1),
|
|
|
|
startEpUpdate: make(chan struct{}, 1),
|
|
|
|
epUpdateCtx: epUpdateCtx,
|
|
|
|
epUpdateCtx: epUpdateCtx,
|
|
|
@ -473,7 +476,7 @@ func (c *Conn) Send(b []byte, ep conn.Endpoint) error {
|
|
|
|
} else if ret == nil {
|
|
|
|
} else if ret == nil {
|
|
|
|
ret = err
|
|
|
|
ret = err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err != nil && addr != roamAddr {
|
|
|
|
if err != nil && addr != roamAddr && c.sendLogLimit.Allow() {
|
|
|
|
log.Printf("magicsock: Conn.Send(%v): %v", addr, err)
|
|
|
|
log.Printf("magicsock: Conn.Send(%v): %v", addr, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|