|
|
@ -792,7 +792,7 @@ func (b *LocalBackend) UpdateStatus(sb *ipnstate.StatusBuilder) {
|
|
|
|
var tailscaleIPs []netip.Addr
|
|
|
|
var tailscaleIPs []netip.Addr
|
|
|
|
if b.netMap != nil {
|
|
|
|
if b.netMap != nil {
|
|
|
|
addrs := b.netMap.GetAddresses()
|
|
|
|
addrs := b.netMap.GetAddresses()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
if addr := addrs.At(i); addr.IsSingleIP() {
|
|
|
|
if addr := addrs.At(i); addr.IsSingleIP() {
|
|
|
|
sb.AddTailscaleIP(addr.Addr())
|
|
|
|
sb.AddTailscaleIP(addr.Addr())
|
|
|
|
tailscaleIPs = append(tailscaleIPs, addr.Addr())
|
|
|
|
tailscaleIPs = append(tailscaleIPs, addr.Addr())
|
|
|
@ -856,7 +856,7 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
|
|
|
|
lastSeen = *p.LastSeen()
|
|
|
|
lastSeen = *p.LastSeen()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tailscaleIPs := make([]netip.Addr, 0, p.Addresses().Len())
|
|
|
|
tailscaleIPs := make([]netip.Addr, 0, p.Addresses().Len())
|
|
|
|
for i := range p.Addresses().LenIter() {
|
|
|
|
for i := range p.Addresses().Len() {
|
|
|
|
addr := p.Addresses().At(i)
|
|
|
|
addr := p.Addresses().At(i)
|
|
|
|
if addr.IsSingleIP() && tsaddr.IsTailscaleIP(addr.Addr()) {
|
|
|
|
if addr.IsSingleIP() && tsaddr.IsTailscaleIP(addr.Addr()) {
|
|
|
|
tailscaleIPs = append(tailscaleIPs, addr.Addr())
|
|
|
|
tailscaleIPs = append(tailscaleIPs, addr.Addr())
|
|
|
@ -977,7 +977,7 @@ func (b *LocalBackend) peerCapsLocked(src netip.Addr) tailcfg.PeerCapMap {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addrs := b.netMap.GetAddresses()
|
|
|
|
addrs := b.netMap.GetAddresses()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
a := addrs.At(i)
|
|
|
|
a := addrs.At(i)
|
|
|
|
if !a.IsSingleIP() {
|
|
|
|
if !a.IsSingleIP() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -1433,7 +1433,7 @@ func setExitNodeID(prefs *ipn.Prefs, nm *netmap.NetworkMap) (prefsChanged bool)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, peer := range nm.Peers {
|
|
|
|
for _, peer := range nm.Peers {
|
|
|
|
for i := range peer.Addresses().LenIter() {
|
|
|
|
for i := range peer.Addresses().Len() {
|
|
|
|
addr := peer.Addresses().At(i)
|
|
|
|
addr := peer.Addresses().At(i)
|
|
|
|
if !addr.IsSingleIP() || addr.Addr() != prefs.ExitNodeIP {
|
|
|
|
if !addr.IsSingleIP() || addr.Addr() != prefs.ExitNodeIP {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -1877,7 +1877,7 @@ func (b *LocalBackend) updateFilterLocked(netMap *netmap.NetworkMap, prefs ipn.P
|
|
|
|
logNetsB.RemovePrefix(tsaddr.ChromeOSVMRange())
|
|
|
|
logNetsB.RemovePrefix(tsaddr.ChromeOSVMRange())
|
|
|
|
if haveNetmap {
|
|
|
|
if haveNetmap {
|
|
|
|
addrs = netMap.GetAddresses()
|
|
|
|
addrs = netMap.GetAddresses()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
localNetsB.AddPrefix(addrs.At(i))
|
|
|
|
localNetsB.AddPrefix(addrs.At(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
packetFilter = netMap.PacketFilter
|
|
|
|
packetFilter = netMap.PacketFilter
|
|
|
@ -1987,7 +1987,7 @@ func packetFilterPermitsUnlockedNodes(peers map[tailcfg.NodeID]tailcfg.NodeView,
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numUnlocked++
|
|
|
|
numUnlocked++
|
|
|
|
for i := range p.AllowedIPs().LenIter() { // not only addresses!
|
|
|
|
for i := range p.AllowedIPs().Len() { // not only addresses!
|
|
|
|
b.AddPrefix(p.AllowedIPs().At(i))
|
|
|
|
b.AddPrefix(p.AllowedIPs().At(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3640,14 +3640,14 @@ func dnsConfigForNetmap(nm *netmap.NetworkMap, peers map[tailcfg.NodeID]tailcfg.
|
|
|
|
return // TODO: propagate error?
|
|
|
|
return // TODO: propagate error?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var have4 bool
|
|
|
|
var have4 bool
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
if addrs.At(i).Addr().Is4() {
|
|
|
|
if addrs.At(i).Addr().Is4() {
|
|
|
|
have4 = true
|
|
|
|
have4 = true
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var ips []netip.Addr
|
|
|
|
var ips []netip.Addr
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
addr := addrs.At(i)
|
|
|
|
addr := addrs.At(i)
|
|
|
|
if selfV6Only {
|
|
|
|
if selfV6Only {
|
|
|
|
if addr.Addr().Is6() {
|
|
|
|
if addr.Addr().Is6() {
|
|
|
@ -3936,7 +3936,7 @@ func (b *LocalBackend) initPeerAPIListener() {
|
|
|
|
b.peerAPIServer = ps
|
|
|
|
b.peerAPIServer = ps
|
|
|
|
|
|
|
|
|
|
|
|
isNetstack := b.sys.IsNetstack()
|
|
|
|
isNetstack := b.sys.IsNetstack()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
a := addrs.At(i)
|
|
|
|
a := addrs.At(i)
|
|
|
|
var ln net.Listener
|
|
|
|
var ln net.Listener
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
@ -4250,7 +4250,7 @@ func (b *LocalBackend) enterStateLockedOnEntry(newState ipn.State) {
|
|
|
|
case ipn.Running:
|
|
|
|
case ipn.Running:
|
|
|
|
var addrStrs []string
|
|
|
|
var addrStrs []string
|
|
|
|
addrs := netMap.GetAddresses()
|
|
|
|
addrs := netMap.GetAddresses()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
addrStrs = append(addrStrs, addrs.At(i).Addr().String())
|
|
|
|
addrStrs = append(addrStrs, addrs.At(i).Addr().String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
systemd.Status("Connected; %s; %s", activeLogin, strings.Join(addrStrs, " "))
|
|
|
|
systemd.Status("Connected; %s; %s", activeLogin, strings.Join(addrStrs, " "))
|
|
|
@ -4626,7 +4626,7 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
|
|
|
b.nodeByAddr[k] = 0
|
|
|
|
b.nodeByAddr[k] = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addNode := func(n tailcfg.NodeView) {
|
|
|
|
addNode := func(n tailcfg.NodeView) {
|
|
|
|
for i := range n.Addresses().LenIter() {
|
|
|
|
for i := range n.Addresses().Len() {
|
|
|
|
if ipp := n.Addresses().At(i); ipp.IsSingleIP() {
|
|
|
|
if ipp := n.Addresses().At(i); ipp.IsSingleIP() {
|
|
|
|
b.nodeByAddr[ipp.Addr()] = n.ID()
|
|
|
|
b.nodeByAddr[ipp.Addr()] = n.ID()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5062,7 +5062,7 @@ func (b *LocalBackend) SetDNS(ctx context.Context, name, value string) error {
|
|
|
|
|
|
|
|
|
|
|
|
func peerAPIPorts(peer tailcfg.NodeView) (p4, p6 uint16) {
|
|
|
|
func peerAPIPorts(peer tailcfg.NodeView) (p4, p6 uint16) {
|
|
|
|
svcs := peer.Hostinfo().Services()
|
|
|
|
svcs := peer.Hostinfo().Services()
|
|
|
|
for i := range svcs.LenIter() {
|
|
|
|
for i := range svcs.Len() {
|
|
|
|
s := svcs.At(i)
|
|
|
|
s := svcs.At(i)
|
|
|
|
switch s.Proto {
|
|
|
|
switch s.Proto {
|
|
|
|
case tailcfg.PeerAPI4:
|
|
|
|
case tailcfg.PeerAPI4:
|
|
|
@ -5095,7 +5095,7 @@ func peerAPIBase(nm *netmap.NetworkMap, peer tailcfg.NodeView) string {
|
|
|
|
|
|
|
|
|
|
|
|
var have4, have6 bool
|
|
|
|
var have4, have6 bool
|
|
|
|
addrs := nm.GetAddresses()
|
|
|
|
addrs := nm.GetAddresses()
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
a := addrs.At(i)
|
|
|
|
a := addrs.At(i)
|
|
|
|
if !a.IsSingleIP() {
|
|
|
|
if !a.IsSingleIP() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -5118,7 +5118,7 @@ func peerAPIBase(nm *netmap.NetworkMap, peer tailcfg.NodeView) string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func nodeIP(n tailcfg.NodeView, pred func(netip.Addr) bool) netip.Addr {
|
|
|
|
func nodeIP(n tailcfg.NodeView, pred func(netip.Addr) bool) netip.Addr {
|
|
|
|
for i := range n.Addresses().LenIter() {
|
|
|
|
for i := range n.Addresses().Len() {
|
|
|
|
a := n.Addresses().At(i)
|
|
|
|
a := n.Addresses().At(i)
|
|
|
|
if a.IsSingleIP() && pred(a.Addr()) {
|
|
|
|
if a.IsSingleIP() && pred(a.Addr()) {
|
|
|
|
return a.Addr()
|
|
|
|
return a.Addr()
|
|
|
@ -5296,7 +5296,7 @@ func wireguardExitNodeDNSResolvers(nm *netmap.NetworkMap, peers map[tailcfg.Node
|
|
|
|
resolvers := p.ExitNodeDNSResolvers()
|
|
|
|
resolvers := p.ExitNodeDNSResolvers()
|
|
|
|
if !resolvers.IsNil() && resolvers.Len() > 0 {
|
|
|
|
if !resolvers.IsNil() && resolvers.Len() > 0 {
|
|
|
|
copies := make([]*dnstype.Resolver, resolvers.Len())
|
|
|
|
copies := make([]*dnstype.Resolver, resolvers.Len())
|
|
|
|
for i := range resolvers.LenIter() {
|
|
|
|
for i := range resolvers.Len() {
|
|
|
|
copies[i] = resolvers.At(i).AsStruct()
|
|
|
|
copies[i] = resolvers.At(i).AsStruct()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return copies, true
|
|
|
|
return copies, true
|
|
|
@ -5319,7 +5319,7 @@ func peerCanProxyDNS(p tailcfg.NodeView) bool {
|
|
|
|
// If p.Cap is not populated (e.g. older control server), then do the old
|
|
|
|
// If p.Cap is not populated (e.g. older control server), then do the old
|
|
|
|
// thing of searching through services.
|
|
|
|
// thing of searching through services.
|
|
|
|
services := p.Hostinfo().Services()
|
|
|
|
services := p.Hostinfo().Services()
|
|
|
|
for i := range services.LenIter() {
|
|
|
|
for i := range services.Len() {
|
|
|
|
if s := services.At(i); s.Proto == tailcfg.PeerAPIDNS && s.Port >= 1 {
|
|
|
|
if s := services.At(i); s.Proto == tailcfg.PeerAPIDNS && s.Port >= 1 {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5495,7 +5495,7 @@ func (b *LocalBackend) handleQuad100Port80Conn(w http.ResponseWriter, r *http.Re
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
io.WriteString(w, "<p>Local addresses:</p><ul>\n")
|
|
|
|
io.WriteString(w, "<p>Local addresses:</p><ul>\n")
|
|
|
|
for i := range addrs.LenIter() {
|
|
|
|
for i := range addrs.Len() {
|
|
|
|
fmt.Fprintf(w, "<li>%v</li>\n", addrs.At(i).Addr())
|
|
|
|
fmt.Fprintf(w, "<li>%v</li>\n", addrs.At(i).Addr())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
io.WriteString(w, "</ul>\n")
|
|
|
|
io.WriteString(w, "</ul>\n")
|
|
|
|