|
|
@ -2715,6 +2715,33 @@ func (c *Conn) getPinger() *ping.Pinger {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DebugPickNewDERP picks a new DERP random home temporarily (even if just for
|
|
|
|
|
|
|
|
// seconds) and reports it to control. It exists to test DERP home changes and
|
|
|
|
|
|
|
|
// netmap deltas, etc. It serves no useful user purpose.
|
|
|
|
|
|
|
|
func (c *Conn) DebugPickNewDERP() error {
|
|
|
|
|
|
|
|
c.mu.Lock()
|
|
|
|
|
|
|
|
defer c.mu.Unlock()
|
|
|
|
|
|
|
|
dm := c.derpMap
|
|
|
|
|
|
|
|
if dm == nil {
|
|
|
|
|
|
|
|
return errors.New("no derpmap")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.netInfoLast == nil {
|
|
|
|
|
|
|
|
return errors.New("no netinfo")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, r := range dm.Regions {
|
|
|
|
|
|
|
|
if r.RegionID == c.myDerp {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.logf("magicsock: [debug] switching derp home to random %v (%v)", r.RegionID, r.RegionCode)
|
|
|
|
|
|
|
|
go c.setNearestDERP(r.RegionID)
|
|
|
|
|
|
|
|
ni2 := c.netInfoLast.Clone()
|
|
|
|
|
|
|
|
ni2.PreferredDERP = r.RegionID
|
|
|
|
|
|
|
|
c.callNetInfoCallbackLocked(ni2)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return errors.New("too few regions")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// portableTrySetSocketBuffer sets SO_SNDBUF and SO_RECVBUF on pconn to socketBufferSize,
|
|
|
|
// portableTrySetSocketBuffer sets SO_SNDBUF and SO_RECVBUF on pconn to socketBufferSize,
|
|
|
|
// logging an error if it occurs.
|
|
|
|
// logging an error if it occurs.
|
|
|
|
func portableTrySetSocketBuffer(pconn nettype.PacketConn, logf logger.Logf) {
|
|
|
|
func portableTrySetSocketBuffer(pconn nettype.PacketConn, logf logger.Logf) {
|
|
|
|