@ -167,7 +167,7 @@ func newUserspaceEngineAdvanced(logf logger.Logf, tundev tun.Device, routerGen R
if ones , bits := allowedIPs [ 0 ] . Mask . Size ( ) ; ones == bits && ones != 0 {
if ones , bits := allowedIPs [ 0 ] . Mask . Size ( ) ; ones == bits && ones != 0 {
var ip wgcfg . IP
var ip wgcfg . IP
copy ( ip . Addr [ : ] , allowedIPs [ 0 ] . IP . To16 ( ) )
copy ( ip . Addr [ : ] , allowedIPs [ 0 ] . IP . To16 ( ) )
e . startP inger( peerKey , ip )
go e . p inger( peerKey , ip )
return
return
}
}
}
}
@ -226,11 +226,11 @@ func newUserspaceEngineAdvanced(logf logger.Logf, tundev tun.Device, routerGen R
return e , nil
return e , nil
}
}
// startPinger starts a goroutine that sends ping packets for a few seconds.
// pinger sends ping packets for a few seconds.
//
//
// These generated packets are used to ensure we trigger the spray logic in
// These generated packets are used to ensure we trigger the spray logic in
// the magicsock package for NAT traversal.
// the magicsock package for NAT traversal.
func ( e * userspaceEngine ) startP inger( peerKey wgcfg . Key , ip wgcfg . IP ) {
func ( e * userspaceEngine ) p inger( peerKey wgcfg . Key , ip wgcfg . IP ) {
e . logf ( "generating initial ping traffic to %s (%v)" , peerKey . ShortString ( ) , ip )
e . logf ( "generating initial ping traffic to %s (%v)" , peerKey . ShortString ( ) , ip )
var srcIP packet . IP
var srcIP packet . IP
@ -264,7 +264,6 @@ func (e *userspaceEngine) startPinger(peerKey wgcfg.Key, ip wgcfg.IP) {
payload := [ ] byte ( "magicsock_spray" ) // no meaning
payload := [ ] byte ( "magicsock_spray" ) // no meaning
go func ( ) {
defer func ( ) {
defer func ( ) {
e . mu . Lock ( )
e . mu . Lock ( )
defer e . mu . Unlock ( )
defer e . mu . Unlock ( )
@ -294,7 +293,6 @@ func (e *userspaceEngine) startPinger(peerKey wgcfg.Key, ip wgcfg.IP) {
ipid ++
ipid ++
e . wgdev . SendPacket ( b )
e . wgdev . SendPacket ( b )
}
}
} ( )
}
}
// TODO(apenwarr): dnsDomains really ought to be in wgcfg.Config.
// TODO(apenwarr): dnsDomains really ought to be in wgcfg.Config.