(node *tailcfg.Node, change tailcfg.PeerChange)
| 639 | } |
| 640 | |
| 641 | func applyPeerChange(node *tailcfg.Node, change tailcfg.PeerChange) { |
| 642 | if change.Key != nil { |
| 643 | node.Key = *change.Key |
| 644 | } |
| 645 | |
| 646 | if change.DiscoKey != nil { |
| 647 | node.DiscoKey = *change.DiscoKey |
| 648 | } |
| 649 | |
| 650 | if change.Online != nil { |
| 651 | node.Online = change.Online |
| 652 | } |
| 653 | |
| 654 | if change.Endpoints != nil { |
| 655 | node.Endpoints = change.Endpoints |
| 656 | } |
| 657 | |
| 658 | // This might technically not be useful as we replace |
| 659 | // the whole hostinfo blob when it has changed. |
| 660 | if change.DERPRegion != 0 { |
| 661 | if !node.Hostinfo.Valid() { |
| 662 | node.Hostinfo = (&tailcfg.Hostinfo{ |
| 663 | NetInfo: &tailcfg.NetInfo{ |
| 664 | PreferredDERP: change.DERPRegion, |
| 665 | }, |
| 666 | }).View() |
| 667 | } else if !node.Hostinfo.NetInfo().Valid() { |
| 668 | hf := node.Hostinfo.AsStruct() |
| 669 | hf.NetInfo = &tailcfg.NetInfo{ |
| 670 | PreferredDERP: change.DERPRegion, |
| 671 | } |
| 672 | node.Hostinfo = hf.View() |
| 673 | } else { |
| 674 | hf := node.Hostinfo.AsStruct() |
| 675 | hf.NetInfo.PreferredDERP = change.DERPRegion |
| 676 | node.Hostinfo = hf.View() |
| 677 | } |
| 678 | node.DERP = fmt.Sprintf("127.3.3.40:%d", change.DERPRegion) |
| 679 | } |
| 680 | |
| 681 | node.LastSeen = change.LastSeen |
| 682 | } |
| 683 | |
| 684 | func peerChangeEmpty(chng tailcfg.PeerChange) bool { |
| 685 | return chng.Key == nil && |
no outgoing calls
no test coverage detected