()
| 854 | } |
| 855 | |
| 856 | func (lh *LightHouse) SendUpdate() { |
| 857 | var v4 []*V4AddrPort |
| 858 | var v6 []*V6AddrPort |
| 859 | |
| 860 | for _, e := range lh.GetAdvertiseAddrs() { |
| 861 | if e.Addr().Is4() { |
| 862 | v4 = append(v4, netAddrToProtoV4AddrPort(e.Addr(), e.Port())) |
| 863 | } else { |
| 864 | v6 = append(v6, netAddrToProtoV6AddrPort(e.Addr(), e.Port())) |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | lal := lh.GetLocalAllowList() |
| 869 | for _, e := range localAddrs(lh.l, lal) { |
| 870 | if lh.myVpnNetworksTable.Contains(e) { |
| 871 | continue |
| 872 | } |
| 873 | |
| 874 | // Only add addrs that aren't my VPN/tun networks |
| 875 | if e.Is4() { |
| 876 | v4 = append(v4, netAddrToProtoV4AddrPort(e, uint16(lh.nebulaPort))) |
| 877 | } else { |
| 878 | v6 = append(v6, netAddrToProtoV6AddrPort(e, uint16(lh.nebulaPort))) |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | nb := make([]byte, 12, 12) |
| 883 | out := make([]byte, mtu) |
| 884 | |
| 885 | var v1Update, v2Update []byte |
| 886 | var err error |
| 887 | updated := 0 |
| 888 | lighthouses := lh.GetLighthouses() |
| 889 | |
| 890 | for _, lhVpnAddr := range lighthouses { |
| 891 | var v cert.Version |
| 892 | hi := lh.ifce.GetHostInfo(lhVpnAddr) |
| 893 | if hi != nil { |
| 894 | v = hi.ConnectionState.myCert.Version() |
| 895 | } else { |
| 896 | v = lh.ifce.GetCertState().initiatingVersion |
| 897 | } |
| 898 | if v == cert.Version1 { |
| 899 | if v1Update == nil { |
| 900 | if !lh.myVpnNetworks[0].Addr().Is4() { |
| 901 | lh.l.WithField("lighthouseAddr", lhVpnAddr). |
| 902 | Warn("cannot update lighthouse using v1 protocol without an IPv4 address") |
| 903 | continue |
| 904 | } |
| 905 | var relays []uint32 |
| 906 | for _, r := range lh.GetRelaysForMe() { |
| 907 | if !r.Is4() { |
| 908 | continue |
| 909 | } |
| 910 | b := r.As4() |
| 911 | relays = append(relays, binary.BigEndian.Uint32(b[:])) |
| 912 | } |
| 913 | b := lh.myVpnNetworks[0].Addr().As4() |
no test coverage detected