connection_manager.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. package nebula
  2. import (
  3. "bytes"
  4. "context"
  5. "encoding/binary"
  6. "fmt"
  7. "log/slog"
  8. "net/netip"
  9. "sync"
  10. "sync/atomic"
  11. "time"
  12. "github.com/rcrowley/go-metrics"
  13. "github.com/slackhq/nebula/cert"
  14. "github.com/slackhq/nebula/config"
  15. "github.com/slackhq/nebula/header"
  16. )
  17. type trafficDecision int
  18. const (
  19. doNothing trafficDecision = 0
  20. deleteTunnel trafficDecision = 1 // delete the hostinfo on our side, do not notify the remote
  21. closeTunnel trafficDecision = 2 // delete the hostinfo and notify the remote
  22. swapPrimary trafficDecision = 3
  23. migrateRelays trafficDecision = 4
  24. tryRehandshake trafficDecision = 5
  25. sendTestPacket trafficDecision = 6
  26. )
  27. type connectionManager struct {
  28. // relayUsed holds which relay localIndexs are in use
  29. relayUsed map[uint32]struct{}
  30. relayUsedLock *sync.RWMutex
  31. hostMap *HostMap
  32. trafficTimer *LockingTimerWheel[uint32]
  33. intf *Interface
  34. punchy *Punchy
  35. // Configuration settings
  36. checkInterval time.Duration
  37. pendingDeletionInterval time.Duration
  38. inactivityTimeout atomic.Int64
  39. dropInactive atomic.Bool
  40. metricsTxPunchy metrics.Counter
  41. l *slog.Logger
  42. }
  43. func newConnectionManagerFromConfig(l *slog.Logger, c *config.C, hm *HostMap, p *Punchy) *connectionManager {
  44. cm := &connectionManager{
  45. hostMap: hm,
  46. l: l,
  47. punchy: p,
  48. relayUsed: make(map[uint32]struct{}),
  49. relayUsedLock: &sync.RWMutex{},
  50. metricsTxPunchy: metrics.GetOrRegisterCounter("messages.tx.punchy", nil),
  51. }
  52. cm.reload(c, true)
  53. c.RegisterReloadCallback(func(c *config.C) {
  54. cm.reload(c, false)
  55. })
  56. return cm
  57. }
  58. func (cm *connectionManager) reload(c *config.C, initial bool) {
  59. if initial {
  60. cm.checkInterval = time.Duration(c.GetInt("timers.connection_alive_interval", 5)) * time.Second
  61. cm.pendingDeletionInterval = time.Duration(c.GetInt("timers.pending_deletion_interval", 10)) * time.Second
  62. // We want at least a minimum resolution of 500ms per tick so that we can hit these intervals
  63. // pretty close to their configured duration.
  64. // The inactivity duration is checked each time a hostinfo ticks through so we don't need the wheel to contain it.
  65. minDuration := min(time.Millisecond*500, cm.checkInterval, cm.pendingDeletionInterval)
  66. maxDuration := max(cm.checkInterval, cm.pendingDeletionInterval)
  67. cm.trafficTimer = NewLockingTimerWheel[uint32](minDuration, maxDuration)
  68. }
  69. if initial || c.HasChanged("tunnels.inactivity_timeout") {
  70. old := cm.getInactivityTimeout()
  71. cm.inactivityTimeout.Store((int64)(c.GetDuration("tunnels.inactivity_timeout", 10*time.Minute)))
  72. if !initial {
  73. cm.l.Info("Inactivity timeout has changed",
  74. "oldDuration", old,
  75. "newDuration", cm.getInactivityTimeout(),
  76. )
  77. }
  78. }
  79. if initial || c.HasChanged("tunnels.drop_inactive") {
  80. old := cm.dropInactive.Load()
  81. cm.dropInactive.Store(c.GetBool("tunnels.drop_inactive", false))
  82. if !initial {
  83. cm.l.Info("Drop inactive setting has changed",
  84. "oldBool", old,
  85. "newBool", cm.dropInactive.Load(),
  86. )
  87. }
  88. }
  89. }
  90. func (cm *connectionManager) getInactivityTimeout() time.Duration {
  91. return (time.Duration)(cm.inactivityTimeout.Load())
  92. }
  93. func (cm *connectionManager) In(h *HostInfo) {
  94. h.in.Store(true)
  95. }
  96. func (cm *connectionManager) Out(h *HostInfo) {
  97. h.out.Store(true)
  98. }
  99. func (cm *connectionManager) RelayUsed(localIndex uint32) {
  100. cm.relayUsedLock.RLock()
  101. // If this already exists, return
  102. if _, ok := cm.relayUsed[localIndex]; ok {
  103. cm.relayUsedLock.RUnlock()
  104. return
  105. }
  106. cm.relayUsedLock.RUnlock()
  107. cm.relayUsedLock.Lock()
  108. cm.relayUsed[localIndex] = struct{}{}
  109. cm.relayUsedLock.Unlock()
  110. }
  111. // getAndResetTrafficCheck returns if there was any inbound or outbound traffic within the last tick and
  112. // resets the state for this local index
  113. func (cm *connectionManager) getAndResetTrafficCheck(h *HostInfo, now time.Time) (bool, bool) {
  114. in := h.in.Swap(false)
  115. out := h.out.Swap(false)
  116. if in || out {
  117. h.lastUsed = now
  118. }
  119. return in, out
  120. }
  121. // AddTrafficWatch must be called for every new HostInfo.
  122. // We will continue to monitor the HostInfo until the tunnel is dropped.
  123. func (cm *connectionManager) AddTrafficWatch(h *HostInfo) {
  124. if h.out.Swap(true) == false {
  125. cm.trafficTimer.Add(h.localIndexId, cm.checkInterval)
  126. }
  127. }
  128. func (cm *connectionManager) Start(ctx context.Context) {
  129. clockSource := time.NewTicker(cm.trafficTimer.t.tickDuration)
  130. defer clockSource.Stop()
  131. p := []byte("")
  132. // Long-lived buf for the traffic-check goroutine; never released.
  133. buf := cm.intf.bufAlloc.Acquire()
  134. for {
  135. select {
  136. case <-ctx.Done():
  137. return
  138. case now := <-clockSource.C:
  139. cm.trafficTimer.Advance(now)
  140. for {
  141. localIndex, has := cm.trafficTimer.Purge()
  142. if !has {
  143. break
  144. }
  145. cm.doTrafficCheck(localIndex, p, buf, now)
  146. }
  147. }
  148. }
  149. }
  150. func (cm *connectionManager) doTrafficCheck(localIndex uint32, p []byte, buf *WireBuffer, now time.Time) {
  151. decision, hostinfo, primary := cm.makeTrafficDecision(localIndex, now)
  152. switch decision {
  153. case deleteTunnel:
  154. if cm.hostMap.DeleteHostInfo(hostinfo) {
  155. // Only clearing the lighthouse cache if this is the last hostinfo for this vpn ip in the hostmap
  156. cm.intf.lightHouse.DeleteVpnAddrs(hostinfo.vpnAddrs)
  157. }
  158. case closeTunnel:
  159. cm.intf.sendCloseTunnel(hostinfo)
  160. cm.intf.closeTunnel(hostinfo)
  161. case swapPrimary:
  162. cm.swapPrimary(hostinfo, primary)
  163. case migrateRelays:
  164. cm.migrateRelayUsed(hostinfo, primary)
  165. case tryRehandshake:
  166. cm.tryRehandshake(hostinfo)
  167. case sendTestPacket:
  168. cm.intf.SendMessageToHostInfo(header.Test, header.TestRequest, hostinfo, p, buf)
  169. }
  170. cm.resetRelayTrafficCheck(hostinfo)
  171. }
  172. func (cm *connectionManager) resetRelayTrafficCheck(hostinfo *HostInfo) {
  173. if hostinfo != nil {
  174. cm.relayUsedLock.Lock()
  175. defer cm.relayUsedLock.Unlock()
  176. // No need to migrate any relays, delete usage info now.
  177. for _, idx := range hostinfo.relayState.CopyRelayForIdxs() {
  178. delete(cm.relayUsed, idx)
  179. }
  180. }
  181. }
  182. func (cm *connectionManager) migrateRelayUsed(oldhostinfo, newhostinfo *HostInfo) {
  183. relayFor := oldhostinfo.relayState.CopyAllRelayFor()
  184. for _, r := range relayFor {
  185. existing, ok := newhostinfo.relayState.QueryRelayForByIp(r.PeerAddr)
  186. var index uint32
  187. var relayFrom netip.Addr
  188. var relayTo netip.Addr
  189. switch {
  190. case ok:
  191. switch existing.State {
  192. case Established, PeerRequested, Disestablished:
  193. // This relay already exists in newhostinfo, then do nothing.
  194. continue
  195. case Requested:
  196. // The relay exists in a Requested state; re-send the request
  197. index = existing.LocalIndex
  198. switch r.Type {
  199. case TerminalType:
  200. relayFrom = cm.intf.myVpnAddrs[0]
  201. relayTo = existing.PeerAddr
  202. case ForwardingType:
  203. relayFrom = existing.PeerAddr
  204. relayTo = newhostinfo.vpnAddrs[0]
  205. default:
  206. // should never happen
  207. panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
  208. }
  209. }
  210. case !ok:
  211. cm.relayUsedLock.RLock()
  212. if _, relayUsed := cm.relayUsed[r.LocalIndex]; !relayUsed {
  213. // The relay hasn't been used; don't migrate it.
  214. cm.relayUsedLock.RUnlock()
  215. continue
  216. }
  217. cm.relayUsedLock.RUnlock()
  218. // The relay doesn't exist at all; create some relay state and send the request.
  219. var err error
  220. index, err = AddRelay(cm.l, newhostinfo, cm.hostMap, r.PeerAddr, nil, r.Type, Requested)
  221. if err != nil {
  222. cm.l.Error("failed to migrate relay to new hostinfo", "error", err)
  223. continue
  224. }
  225. switch r.Type {
  226. case TerminalType:
  227. relayFrom = cm.intf.myVpnAddrs[0]
  228. relayTo = r.PeerAddr
  229. case ForwardingType:
  230. relayFrom = r.PeerAddr
  231. relayTo = newhostinfo.vpnAddrs[0]
  232. default:
  233. // should never happen
  234. panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
  235. }
  236. }
  237. // Send a CreateRelayRequest to the peer.
  238. req := NebulaControl{
  239. Type: NebulaControl_CreateRelayRequest,
  240. InitiatorRelayIndex: index,
  241. }
  242. switch newhostinfo.GetCert().Certificate.Version() {
  243. case cert.Version1:
  244. if !relayFrom.Is4() {
  245. cm.l.Error("can not migrate v1 relay with a v6 network because the relay is not running a current nebula version")
  246. continue
  247. }
  248. if !relayTo.Is4() {
  249. cm.l.Error("can not migrate v1 relay with a v6 remote network because the relay is not running a current nebula version")
  250. continue
  251. }
  252. b := relayFrom.As4()
  253. req.OldRelayFromAddr = binary.BigEndian.Uint32(b[:])
  254. b = relayTo.As4()
  255. req.OldRelayToAddr = binary.BigEndian.Uint32(b[:])
  256. case cert.Version2:
  257. req.RelayFromAddr = netAddrToProtoAddr(relayFrom)
  258. req.RelayToAddr = netAddrToProtoAddr(relayTo)
  259. default:
  260. newhostinfo.logger(cm.l).Error("Unknown certificate version found while attempting to migrate relay")
  261. continue
  262. }
  263. msg, err := req.Marshal()
  264. if err != nil {
  265. cm.l.Error("failed to marshal Control message to migrate relay", "error", err)
  266. } else {
  267. migBuf := cm.intf.bufAlloc.Acquire()
  268. cm.intf.SendMessageToHostInfo(header.Control, 0, newhostinfo, msg, migBuf)
  269. cm.intf.bufAlloc.Release(migBuf)
  270. cm.l.Info("send CreateRelayRequest",
  271. "relayFrom", req.RelayFromAddr,
  272. "relayTo", req.RelayToAddr,
  273. "initiatorRelayIndex", req.InitiatorRelayIndex,
  274. "responderRelayIndex", req.ResponderRelayIndex,
  275. "vpnAddrs", newhostinfo.vpnAddrs,
  276. )
  277. }
  278. }
  279. }
  280. func (cm *connectionManager) makeTrafficDecision(localIndex uint32, now time.Time) (trafficDecision, *HostInfo, *HostInfo) {
  281. // Read lock the main hostmap to order decisions based on tunnels being the primary tunnel
  282. cm.hostMap.RLock()
  283. defer cm.hostMap.RUnlock()
  284. hostinfo := cm.hostMap.Indexes[localIndex]
  285. if hostinfo == nil {
  286. cm.l.Debug("Not found in hostmap", "localIndex", localIndex)
  287. return doNothing, nil, nil
  288. }
  289. if cm.isInvalidCertificate(now, hostinfo) {
  290. return closeTunnel, hostinfo, nil
  291. }
  292. primary := cm.hostMap.Hosts[hostinfo.vpnAddrs[0]]
  293. mainHostInfo := true
  294. if primary != nil && primary != hostinfo {
  295. mainHostInfo = false
  296. }
  297. // Check for traffic on this hostinfo
  298. inTraffic, outTraffic := cm.getAndResetTrafficCheck(hostinfo, now)
  299. // A hostinfo is determined alive if there is incoming traffic
  300. if inTraffic {
  301. decision := doNothing
  302. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  303. hostinfo.logger(cm.l).Debug("Tunnel status",
  304. "tunnelCheck", m{"state": "alive", "method": "passive"},
  305. )
  306. }
  307. hostinfo.pendingDeletion.Store(false)
  308. if mainHostInfo {
  309. decision = tryRehandshake
  310. } else {
  311. if cm.shouldSwapPrimary(hostinfo) {
  312. decision = swapPrimary
  313. } else {
  314. // migrate the relays to the primary, if in use.
  315. decision = migrateRelays
  316. }
  317. }
  318. cm.trafficTimer.Add(hostinfo.localIndexId, cm.checkInterval)
  319. if !outTraffic {
  320. // Send a punch packet to keep the NAT state alive
  321. cm.sendPunch(hostinfo)
  322. }
  323. return decision, hostinfo, primary
  324. }
  325. if hostinfo.pendingDeletion.Load() {
  326. // We have already sent a test packet and nothing was returned, this hostinfo is dead
  327. hostinfo.logger(cm.l).Info("Tunnel status",
  328. "tunnelCheck", m{"state": "dead", "method": "active"},
  329. )
  330. return deleteTunnel, hostinfo, nil
  331. }
  332. decision := doNothing
  333. if hostinfo != nil && hostinfo.ConnectionState != nil && mainHostInfo {
  334. if !outTraffic {
  335. inactiveFor, isInactive := cm.isInactive(hostinfo, now)
  336. if isInactive {
  337. // Tunnel is inactive, tear it down
  338. hostinfo.logger(cm.l).Info("Dropping tunnel due to inactivity",
  339. "inactiveDuration", inactiveFor,
  340. "primary", mainHostInfo,
  341. )
  342. return closeTunnel, hostinfo, primary
  343. }
  344. // If we aren't sending or receiving traffic then its an unused tunnel and we don't to test the tunnel.
  345. // Just maintain NAT state if configured to do so.
  346. cm.sendPunch(hostinfo)
  347. cm.trafficTimer.Add(hostinfo.localIndexId, cm.checkInterval)
  348. return doNothing, nil, nil
  349. }
  350. if cm.punchy.GetTargetEverything() {
  351. // This is similar to the old punchy behavior with a slight optimization.
  352. // We aren't receiving traffic but we are sending it, punch on all known
  353. // ips in case we need to re-prime NAT state
  354. cm.sendPunch(hostinfo)
  355. }
  356. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  357. hostinfo.logger(cm.l).Debug("Tunnel status",
  358. "tunnelCheck", m{"state": "testing", "method": "active"},
  359. )
  360. }
  361. // Send a test packet to trigger an authenticated tunnel test, this should suss out any lingering tunnel issues
  362. decision = sendTestPacket
  363. } else {
  364. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  365. hostinfo.logger(cm.l).Debug("Hostinfo sadness")
  366. }
  367. }
  368. hostinfo.pendingDeletion.Store(true)
  369. cm.trafficTimer.Add(hostinfo.localIndexId, cm.pendingDeletionInterval)
  370. return decision, hostinfo, nil
  371. }
  372. func (cm *connectionManager) isInactive(hostinfo *HostInfo, now time.Time) (time.Duration, bool) {
  373. if cm.dropInactive.Load() == false {
  374. // We aren't configured to drop inactive tunnels
  375. return 0, false
  376. }
  377. inactiveDuration := now.Sub(hostinfo.lastUsed)
  378. if inactiveDuration < cm.getInactivityTimeout() {
  379. // It's not considered inactive
  380. return inactiveDuration, false
  381. }
  382. // The tunnel is inactive
  383. return inactiveDuration, true
  384. }
  385. func (cm *connectionManager) shouldSwapPrimary(current *HostInfo) bool {
  386. // The primary tunnel is the most recent handshake to complete locally and should work entirely fine.
  387. // If we are here then we have multiple tunnels for a host pair and neither side believes the same tunnel is primary.
  388. // Let's sort this out.
  389. // Only one side should swap because if both swap then we may never resolve to a single tunnel.
  390. // vpn addr is static across all tunnels for this host pair so lets
  391. // use that to determine if we should consider swapping.
  392. if current.vpnAddrs[0].Compare(cm.intf.myVpnAddrs[0]) < 0 {
  393. // Their primary vpn addr is less than mine. Do not swap.
  394. return false
  395. }
  396. crt := cm.intf.pki.getCertState().getCertificate(current.ConnectionState.myCert.Version())
  397. if crt == nil {
  398. //my cert was reloaded away. We should definitely swap from this tunnel
  399. return true
  400. }
  401. // If this tunnel is using the latest certificate then we should swap it to primary for a bit and see if things
  402. // settle down.
  403. return bytes.Equal(current.ConnectionState.myCert.Signature(), crt.Signature())
  404. }
  405. func (cm *connectionManager) swapPrimary(current, primary *HostInfo) {
  406. cm.hostMap.Lock()
  407. // Make sure the primary is still the same after the write lock. This avoids a race with a rehandshake.
  408. if cm.hostMap.Hosts[current.vpnAddrs[0]] == primary {
  409. cm.hostMap.unlockedMakePrimary(current)
  410. }
  411. cm.hostMap.Unlock()
  412. }
  413. // isInvalidCertificate decides if we should destroy a tunnel.
  414. // returns true if pki.disconnect_invalid is true and the certificate is no longer valid.
  415. // Blocklisted certificates will skip the pki.disconnect_invalid check and return true.
  416. func (cm *connectionManager) isInvalidCertificate(now time.Time, hostinfo *HostInfo) bool {
  417. remoteCert := hostinfo.GetCert()
  418. if remoteCert == nil {
  419. return false //don't tear down tunnels for handshakes in progress
  420. }
  421. caPool := cm.intf.pki.GetCAPool()
  422. err := caPool.VerifyCachedCertificate(now, remoteCert)
  423. if err == nil {
  424. return false //cert is still valid! yay!
  425. } else if err == cert.ErrBlockListed { //avoiding errors.Is for speed
  426. // Block listed certificates should always be disconnected
  427. hostinfo.logger(cm.l).Info("Remote certificate is blocked, tearing down the tunnel",
  428. "error", err,
  429. "fingerprint", remoteCert.Fingerprint,
  430. )
  431. return true
  432. } else if cm.intf.disconnectInvalid.Load() {
  433. hostinfo.logger(cm.l).Info("Remote certificate is no longer valid, tearing down the tunnel",
  434. "error", err,
  435. "fingerprint", remoteCert.Fingerprint,
  436. )
  437. return true
  438. } else {
  439. //if we reach here, the cert is no longer valid, but we're configured to keep tunnels from now-invalid certs open
  440. return false
  441. }
  442. }
  443. func (cm *connectionManager) sendPunch(hostinfo *HostInfo) {
  444. if !cm.punchy.GetPunch() {
  445. // Punching is disabled
  446. return
  447. }
  448. if cm.intf.lightHouse.IsAnyLighthouseAddr(hostinfo.vpnAddrs) {
  449. // Do not punch to lighthouses, we assume our lighthouse update interval is good enough.
  450. // In the event the update interval is not sufficient to maintain NAT state then a publicly available lighthouse
  451. // would lose the ability to notify us and punchy.respond would become unreliable.
  452. return
  453. }
  454. if cm.punchy.GetTargetEverything() {
  455. hostinfo.remotes.ForEach(cm.hostMap.GetPreferredRanges(), func(addr netip.AddrPort, preferred bool) {
  456. cm.metricsTxPunchy.Inc(1)
  457. cm.intf.outside.WriteTo([]byte{1}, addr)
  458. })
  459. } else if hostinfo.remote.IsValid() {
  460. cm.metricsTxPunchy.Inc(1)
  461. cm.intf.outside.WriteTo([]byte{1}, hostinfo.remote)
  462. }
  463. }
  464. func (cm *connectionManager) tryRehandshake(hostinfo *HostInfo) {
  465. cs := cm.intf.pki.getCertState()
  466. curCrt := hostinfo.ConnectionState.myCert
  467. curCrtVersion := curCrt.Version()
  468. myCrt := cs.getCertificate(curCrtVersion)
  469. if myCrt == nil {
  470. cm.l.Info("Re-handshaking with remote",
  471. "vpnAddrs", hostinfo.vpnAddrs,
  472. "version", curCrtVersion,
  473. "reason", "local certificate removed",
  474. )
  475. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  476. return
  477. }
  478. peerCrt := hostinfo.ConnectionState.peerCert
  479. if peerCrt != nil && curCrtVersion < peerCrt.Certificate.Version() {
  480. // if our certificate version is less than theirs, and we have a matching version available, rehandshake?
  481. if cs.getCertificate(peerCrt.Certificate.Version()) != nil {
  482. cm.l.Info("Re-handshaking with remote",
  483. "vpnAddrs", hostinfo.vpnAddrs,
  484. "version", curCrtVersion,
  485. "peerVersion", peerCrt.Certificate.Version(),
  486. "reason", "local certificate version lower than peer, attempting to correct",
  487. )
  488. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], func(hh *HandshakeHostInfo) {
  489. hh.initiatingVersionOverride = peerCrt.Certificate.Version()
  490. })
  491. return
  492. }
  493. }
  494. if !bytes.Equal(curCrt.Signature(), myCrt.Signature()) {
  495. cm.l.Info("Re-handshaking with remote",
  496. "vpnAddrs", hostinfo.vpnAddrs,
  497. "reason", "local certificate is not current",
  498. )
  499. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  500. return
  501. }
  502. if curCrtVersion < cs.initiatingVersion {
  503. cm.l.Info("Re-handshaking with remote",
  504. "vpnAddrs", hostinfo.vpnAddrs,
  505. "reason", "current cert version < pki.initiatingVersion",
  506. )
  507. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  508. return
  509. }
  510. }