@ -288,6 +288,7 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
e := sys . Engine . Get ( )
e := sys . Engine . Get ( )
store := sys . StateStore . Get ( )
store := sys . StateStore . Get ( )
dialer := sys . Dialer . Get ( )
dialer := sys . Dialer . Get ( )
_ = sys . MagicSock . Get ( ) // or panic
pm , err := newProfileManager ( store , logf )
pm , err := newProfileManager ( store , logf )
if err != nil {
if err != nil {
@ -404,11 +405,7 @@ func (b *LocalBackend) SetComponentDebugLogging(component string, until time.Tim
var setEnabled func ( bool )
var setEnabled func ( bool )
switch component {
switch component {
case "magicsock" :
case "magicsock" :
mc , err := b . magicConn ( )
setEnabled = b . magicConn ( ) . SetDebugLoggingEnabled
if err != nil {
return err
}
setEnabled = mc . SetDebugLoggingEnabled
case "sockstats" :
case "sockstats" :
if b . sockstatLogger != nil {
if b . sockstatLogger != nil {
setEnabled = func ( v bool ) {
setEnabled = func ( v bool ) {
@ -1124,11 +1121,7 @@ var _ controlclient.NetmapDeltaUpdater = (*LocalBackend)(nil)
// UpdateNetmapDelta implements controlclient.NetmapDeltaUpdater.
// UpdateNetmapDelta implements controlclient.NetmapDeltaUpdater.
func ( b * LocalBackend ) UpdateNetmapDelta ( muts [ ] netmap . NodeMutation ) ( handled bool ) {
func ( b * LocalBackend ) UpdateNetmapDelta ( muts [ ] netmap . NodeMutation ) ( handled bool ) {
mc , err := b . magicConn ( )
if ! b . magicConn ( ) . UpdateNetmapDelta ( muts ) {
if err != nil {
panic ( err ) // shouldn't happen
}
if ! mc . UpdateNetmapDelta ( muts ) {
return false
return false
}
}
@ -1552,11 +1545,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
}
}
cc . SetTKAHead ( tkaHead )
cc . SetTKAHead ( tkaHead )
if mc , err := b . magicConn ( ) ; err != nil {
b . magicConn ( ) . SetNetInfoCallback ( b . setNetInfo )
return fmt . Errorf ( "looking up magicsock: %w" , err )
} else {
mc . SetNetInfoCallback ( b . setNetInfo )
}
blid := b . backendLogID . String ( )
blid := b . backendLogID . String ( )
b . logf ( "Backend: logs: be:%v fe:%v" , blid , opts . FrontendLogID )
b . logf ( "Backend: logs: be:%v fe:%v" , blid , opts . FrontendLogID )
@ -4706,20 +4695,12 @@ func peerCanProxyDNS(p tailcfg.NodeView) bool {
}
}
func ( b * LocalBackend ) DebugRebind ( ) error {
func ( b * LocalBackend ) DebugRebind ( ) error {
mc , err := b . magicConn ( )
b . magicConn ( ) . Rebind ( )
if err != nil {
return err
}
mc . Rebind ( )
return nil
return nil
}
}
func ( b * LocalBackend ) DebugReSTUN ( ) error {
func ( b * LocalBackend ) DebugReSTUN ( ) error {
mc , err := b . magicConn ( )
b . magicConn ( ) . ReSTUN ( "explicit-debug" )
if err != nil {
return err
}
mc . ReSTUN ( "explicit-debug" )
return nil
return nil
}
}
@ -4728,12 +4709,8 @@ func (b *LocalBackend) ControlKnobs() *controlknobs.Knobs {
return b . sys . ControlKnobs ( )
return b . sys . ControlKnobs ( )
}
}
func ( b * LocalBackend ) magicConn ( ) ( * magicsock . Conn , error ) {
func ( b * LocalBackend ) magicConn ( ) * magicsock . Conn {
mc , ok := b . sys . MagicSock . GetOK ( )
return b . sys . MagicSock . Get ( )
if ! ok {
return nil , errors . New ( "failed to get magicsock from sys" )
}
return mc , nil
}
}
type keyProvingNoiseRoundTripper struct {
type keyProvingNoiseRoundTripper struct {
@ -5176,12 +5153,7 @@ func (b *LocalBackend) GetPeerEndpointChanges(ctx context.Context, ip netip.Addr
}
}
peer := pip . Node
peer := pip . Node
mc , err := b . magicConn ( )
chs , err := b . magicConn ( ) . GetEndpointChanges ( peer )
if err != nil {
return nil , fmt . Errorf ( "getting magicsock conn: %w" , err )
}
chs , err := mc . GetEndpointChanges ( peer )
if err != nil {
if err != nil {
return nil , fmt . Errorf ( "getting endpoint changes: %w" , err )
return nil , fmt . Errorf ( "getting endpoint changes: %w" , err )
}
}
@ -5198,9 +5170,5 @@ func (b *LocalBackend) DebugBreakTCPConns() error {
}
}
func ( b * LocalBackend ) DebugBreakDERPConns ( ) error {
func ( b * LocalBackend ) DebugBreakDERPConns ( ) error {
mc , err := b . magicConn ( )
return b . magicConn ( ) . DebugBreakDERPConns ( )
if err != nil {
return err
}
return mc . DebugBreakDERPConns ( )
}
}