types/netmap: split controlclient.NetworkMap off into its own leaf package
Updates #1278 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
ddfcc4326c
commit
1e7a35b225
@ -4,60 +4,56 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
W 💣 github.com/alexbrainman/sspi/negotiate from tailscale.com/net/tshttpproxy
|
W 💣 github.com/alexbrainman/sspi/negotiate from tailscale.com/net/tshttpproxy
|
||||||
github.com/apenwarr/fixconsole from tailscale.com/cmd/tailscale
|
github.com/apenwarr/fixconsole from tailscale.com/cmd/tailscale
|
||||||
W 💣 github.com/apenwarr/w32 from github.com/apenwarr/fixconsole
|
W 💣 github.com/apenwarr/w32 from github.com/apenwarr/fixconsole
|
||||||
L github.com/mdlayher/sdnotify from tailscale.com/util/systemd
|
|
||||||
github.com/peterbourgon/ff/v2 from github.com/peterbourgon/ff/v2/ffcli
|
github.com/peterbourgon/ff/v2 from github.com/peterbourgon/ff/v2/ffcli
|
||||||
github.com/peterbourgon/ff/v2/ffcli from tailscale.com/cmd/tailscale/cli
|
github.com/peterbourgon/ff/v2/ffcli from tailscale.com/cmd/tailscale/cli
|
||||||
github.com/tcnksm/go-httpstat from tailscale.com/net/netcheck
|
github.com/tcnksm/go-httpstat from tailscale.com/net/netcheck
|
||||||
github.com/toqueteos/webbrowser from tailscale.com/cmd/tailscale/cli
|
github.com/toqueteos/webbrowser from tailscale.com/cmd/tailscale/cli
|
||||||
💣 go4.org/intern from inet.af/netaddr
|
💣 go4.org/intern from inet.af/netaddr
|
||||||
💣 go4.org/mem from tailscale.com/control/controlclient+
|
💣 go4.org/mem from tailscale.com/derp+
|
||||||
go4.org/unsafe/assume-no-moving-gc from go4.org/intern
|
go4.org/unsafe/assume-no-moving-gc from go4.org/intern
|
||||||
W 💣 golang.zx2c4.com/wireguard/windows/tunnel/winipcfg from tailscale.com/net/interfaces+
|
W 💣 golang.zx2c4.com/wireguard/windows/tunnel/winipcfg from tailscale.com/net/interfaces+
|
||||||
inet.af/netaddr from tailscale.com/cmd/tailscale/cli+
|
inet.af/netaddr from tailscale.com/cmd/tailscale/cli+
|
||||||
rsc.io/goversion/version from tailscale.com/version
|
rsc.io/goversion/version from tailscale.com/version
|
||||||
tailscale.com/atomicfile from tailscale.com/ipn
|
tailscale.com/atomicfile from tailscale.com/ipn
|
||||||
tailscale.com/cmd/tailscale/cli from tailscale.com/cmd/tailscale
|
tailscale.com/cmd/tailscale/cli from tailscale.com/cmd/tailscale
|
||||||
tailscale.com/control/controlclient from tailscale.com/ipn
|
|
||||||
tailscale.com/derp from tailscale.com/derp/derphttp
|
tailscale.com/derp from tailscale.com/derp/derphttp
|
||||||
tailscale.com/derp/derphttp from tailscale.com/net/netcheck
|
tailscale.com/derp/derphttp from tailscale.com/net/netcheck
|
||||||
tailscale.com/derp/derpmap from tailscale.com/cmd/tailscale/cli
|
tailscale.com/derp/derpmap from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/disco from tailscale.com/derp
|
tailscale.com/disco from tailscale.com/derp
|
||||||
tailscale.com/ipn from tailscale.com/cmd/tailscale/cli
|
tailscale.com/ipn from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/ipn/ipnstate from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/ipn/ipnstate from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/log/logheap from tailscale.com/control/controlclient
|
|
||||||
tailscale.com/logtail/backoff from tailscale.com/control/controlclient
|
|
||||||
tailscale.com/metrics from tailscale.com/derp
|
tailscale.com/metrics from tailscale.com/derp
|
||||||
tailscale.com/net/dnscache from tailscale.com/control/controlclient+
|
tailscale.com/net/dnscache from tailscale.com/derp/derphttp
|
||||||
tailscale.com/net/flowtrack from tailscale.com/wgengine/filter+
|
tailscale.com/net/flowtrack from tailscale.com/wgengine/filter+
|
||||||
💣 tailscale.com/net/interfaces from tailscale.com/cmd/tailscale/cli+
|
💣 tailscale.com/net/interfaces from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/net/netcheck from tailscale.com/cmd/tailscale/cli
|
tailscale.com/net/netcheck from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/net/netns from tailscale.com/control/controlclient+
|
tailscale.com/net/netns from tailscale.com/derp/derphttp+
|
||||||
tailscale.com/net/packet from tailscale.com/wgengine/filter
|
tailscale.com/net/packet from tailscale.com/wgengine/filter
|
||||||
tailscale.com/net/stun from tailscale.com/net/netcheck
|
tailscale.com/net/stun from tailscale.com/net/netcheck
|
||||||
tailscale.com/net/tlsdial from tailscale.com/control/controlclient+
|
tailscale.com/net/tlsdial from tailscale.com/derp/derphttp
|
||||||
tailscale.com/net/tsaddr from tailscale.com/net/interfaces
|
tailscale.com/net/tsaddr from tailscale.com/net/interfaces
|
||||||
💣 tailscale.com/net/tshttpproxy from tailscale.com/control/controlclient+
|
💣 tailscale.com/net/tshttpproxy from tailscale.com/derp/derphttp+
|
||||||
tailscale.com/paths from tailscale.com/cmd/tailscale/cli
|
tailscale.com/paths from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/safesocket from tailscale.com/cmd/tailscale/cli
|
tailscale.com/safesocket from tailscale.com/cmd/tailscale/cli
|
||||||
💣 tailscale.com/syncs from tailscale.com/net/interfaces+
|
💣 tailscale.com/syncs from tailscale.com/net/interfaces+
|
||||||
tailscale.com/tailcfg from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/tailcfg from tailscale.com/cmd/tailscale/cli+
|
||||||
W tailscale.com/tsconst from tailscale.com/net/interfaces
|
W tailscale.com/tsconst from tailscale.com/net/interfaces
|
||||||
tailscale.com/types/empty from tailscale.com/control/controlclient+
|
tailscale.com/types/empty from tailscale.com/ipn
|
||||||
tailscale.com/types/key from tailscale.com/derp+
|
tailscale.com/types/key from tailscale.com/derp+
|
||||||
tailscale.com/types/logger from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/types/logger from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/types/opt from tailscale.com/control/controlclient+
|
tailscale.com/types/netmap from tailscale.com/ipn
|
||||||
tailscale.com/types/persist from tailscale.com/control/controlclient+
|
tailscale.com/types/opt from tailscale.com/net/netcheck+
|
||||||
|
tailscale.com/types/persist from tailscale.com/ipn
|
||||||
tailscale.com/types/preftype from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/types/preftype from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/types/strbuilder from tailscale.com/net/packet
|
tailscale.com/types/strbuilder from tailscale.com/net/packet
|
||||||
tailscale.com/types/structs from tailscale.com/control/controlclient+
|
tailscale.com/types/structs from tailscale.com/ipn+
|
||||||
tailscale.com/types/wgkey from tailscale.com/control/controlclient+
|
tailscale.com/types/wgkey from tailscale.com/types/netmap+
|
||||||
tailscale.com/util/dnsname from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/util/dnsname from tailscale.com/cmd/tailscale/cli+
|
||||||
W tailscale.com/util/endian from tailscale.com/net/netns
|
W tailscale.com/util/endian from tailscale.com/net/netns
|
||||||
tailscale.com/util/lineread from tailscale.com/control/controlclient+
|
tailscale.com/util/lineread from tailscale.com/net/interfaces
|
||||||
tailscale.com/util/systemd from tailscale.com/control/controlclient
|
|
||||||
tailscale.com/version from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/version from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/version/distro from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/version/distro from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/wgengine/filter from tailscale.com/control/controlclient
|
tailscale.com/wgengine/filter from tailscale.com/types/netmap
|
||||||
golang.org/x/crypto/blake2b from golang.org/x/crypto/nacl/box
|
golang.org/x/crypto/blake2b from golang.org/x/crypto/nacl/box
|
||||||
golang.org/x/crypto/chacha20 from golang.org/x/crypto/chacha20poly1305
|
golang.org/x/crypto/chacha20 from golang.org/x/crypto/chacha20poly1305
|
||||||
golang.org/x/crypto/chacha20poly1305 from crypto/tls+
|
golang.org/x/crypto/chacha20poly1305 from crypto/tls+
|
||||||
@ -65,7 +61,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
golang.org/x/crypto/cryptobyte/asn1 from crypto/ecdsa+
|
golang.org/x/crypto/cryptobyte/asn1 from crypto/ecdsa+
|
||||||
golang.org/x/crypto/curve25519 from crypto/tls+
|
golang.org/x/crypto/curve25519 from crypto/tls+
|
||||||
golang.org/x/crypto/hkdf from crypto/tls
|
golang.org/x/crypto/hkdf from crypto/tls
|
||||||
golang.org/x/crypto/nacl/box from tailscale.com/control/controlclient+
|
golang.org/x/crypto/nacl/box from tailscale.com/derp
|
||||||
golang.org/x/crypto/nacl/secretbox from golang.org/x/crypto/nacl/box
|
golang.org/x/crypto/nacl/secretbox from golang.org/x/crypto/nacl/box
|
||||||
golang.org/x/crypto/poly1305 from golang.org/x/crypto/chacha20poly1305+
|
golang.org/x/crypto/poly1305 from golang.org/x/crypto/chacha20poly1305+
|
||||||
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
|
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
|
||||||
@ -77,7 +73,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
golang.org/x/net/idna from golang.org/x/net/http/httpguts+
|
golang.org/x/net/idna from golang.org/x/net/http/httpguts+
|
||||||
golang.org/x/net/proxy from tailscale.com/net/netns
|
golang.org/x/net/proxy from tailscale.com/net/netns
|
||||||
D golang.org/x/net/route from net
|
D golang.org/x/net/route from net
|
||||||
golang.org/x/oauth2 from tailscale.com/control/controlclient+
|
golang.org/x/oauth2 from tailscale.com/ipn+
|
||||||
golang.org/x/oauth2/internal from golang.org/x/oauth2
|
golang.org/x/oauth2/internal from golang.org/x/oauth2
|
||||||
golang.org/x/sync/errgroup from tailscale.com/derp
|
golang.org/x/sync/errgroup from tailscale.com/derp
|
||||||
golang.org/x/sync/singleflight from tailscale.com/net/dnscache
|
golang.org/x/sync/singleflight from tailscale.com/net/dnscache
|
||||||
@ -93,7 +89,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
bufio from compress/flate+
|
bufio from compress/flate+
|
||||||
bytes from bufio+
|
bytes from bufio+
|
||||||
compress/flate from compress/gzip+
|
compress/flate from compress/gzip+
|
||||||
compress/gzip from net/http+
|
compress/gzip from net/http
|
||||||
compress/zlib from debug/elf+
|
compress/zlib from debug/elf+
|
||||||
container/list from crypto/tls+
|
container/list from crypto/tls+
|
||||||
context from crypto/tls+
|
context from crypto/tls+
|
||||||
@ -162,14 +158,13 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
regexp from rsc.io/goversion/version
|
regexp from rsc.io/goversion/version
|
||||||
regexp/syntax from regexp
|
regexp/syntax from regexp
|
||||||
runtime/debug from golang.org/x/sync/singleflight
|
runtime/debug from golang.org/x/sync/singleflight
|
||||||
runtime/pprof from tailscale.com/log/logheap
|
|
||||||
sort from compress/flate+
|
sort from compress/flate+
|
||||||
strconv from compress/flate+
|
strconv from compress/flate+
|
||||||
strings from bufio+
|
strings from bufio+
|
||||||
sync from compress/flate+
|
sync from compress/flate+
|
||||||
sync/atomic from context+
|
sync/atomic from context+
|
||||||
syscall from crypto/rand+
|
syscall from crypto/rand+
|
||||||
text/tabwriter from github.com/peterbourgon/ff/v2/ffcli+
|
text/tabwriter from github.com/peterbourgon/ff/v2/ffcli
|
||||||
time from compress/gzip+
|
time from compress/gzip+
|
||||||
unicode from bytes+
|
unicode from bytes+
|
||||||
unicode/utf16 from encoding/asn1+
|
unicode/utf16 from encoding/asn1+
|
||||||
|
@ -65,7 +65,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
|||||||
inet.af/netaddr from tailscale.com/control/controlclient+
|
inet.af/netaddr from tailscale.com/control/controlclient+
|
||||||
rsc.io/goversion/version from tailscale.com/version
|
rsc.io/goversion/version from tailscale.com/version
|
||||||
tailscale.com/atomicfile from tailscale.com/ipn+
|
tailscale.com/atomicfile from tailscale.com/ipn+
|
||||||
tailscale.com/control/controlclient from tailscale.com/ipn+
|
tailscale.com/control/controlclient from tailscale.com/ipn/ipnlocal+
|
||||||
tailscale.com/derp from tailscale.com/derp/derphttp+
|
tailscale.com/derp from tailscale.com/derp/derphttp+
|
||||||
tailscale.com/derp/derphttp from tailscale.com/net/netcheck+
|
tailscale.com/derp/derphttp from tailscale.com/net/netcheck+
|
||||||
tailscale.com/derp/derpmap from tailscale.com/cmd/tailscaled
|
tailscale.com/derp/derpmap from tailscale.com/cmd/tailscaled
|
||||||
@ -106,6 +106,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
|||||||
tailscale.com/types/flagtype from tailscale.com/cmd/tailscaled
|
tailscale.com/types/flagtype from tailscale.com/cmd/tailscaled
|
||||||
tailscale.com/types/key from tailscale.com/derp+
|
tailscale.com/types/key from tailscale.com/derp+
|
||||||
tailscale.com/types/logger from tailscale.com/cmd/tailscaled+
|
tailscale.com/types/logger from tailscale.com/cmd/tailscaled+
|
||||||
|
tailscale.com/types/netmap from tailscale.com/control/controlclient+
|
||||||
tailscale.com/types/nettype from tailscale.com/wgengine/magicsock
|
tailscale.com/types/nettype from tailscale.com/wgengine/magicsock
|
||||||
tailscale.com/types/opt from tailscale.com/control/controlclient+
|
tailscale.com/types/opt from tailscale.com/control/controlclient+
|
||||||
tailscale.com/types/persist from tailscale.com/control/controlclient+
|
tailscale.com/types/persist from tailscale.com/control/controlclient+
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/empty"
|
"tailscale.com/types/empty"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/persist"
|
"tailscale.com/types/persist"
|
||||||
"tailscale.com/types/structs"
|
"tailscale.com/types/structs"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
@ -69,9 +70,9 @@ type Status struct {
|
|||||||
LoginFinished *empty.Message
|
LoginFinished *empty.Message
|
||||||
Err string
|
Err string
|
||||||
URL string
|
URL string
|
||||||
Persist *persist.Persist // locally persisted configuration
|
Persist *persist.Persist // locally persisted configuration
|
||||||
NetMap *NetworkMap // server-pushed configuration
|
NetMap *netmap.NetworkMap // server-pushed configuration
|
||||||
Hostinfo *tailcfg.Hostinfo // current Hostinfo data
|
Hostinfo *tailcfg.Hostinfo // current Hostinfo data
|
||||||
State State
|
State State
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,7 +511,7 @@ func (c *Client) mapRoutine() {
|
|||||||
c.inPollNetMap = false
|
c.inPollNetMap = false
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
err := c.direct.PollNetMap(ctx, -1, func(nm *NetworkMap) {
|
err := c.direct.PollNetMap(ctx, -1, func(nm *netmap.NetworkMap) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@ -607,7 +608,7 @@ func (c *Client) SetNetInfo(ni *tailcfg.NetInfo) {
|
|||||||
c.sendNewMapRequest()
|
c.sendNewMapRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) sendStatus(who string, err error, url string, nm *NetworkMap) {
|
func (c *Client) sendStatus(who string, err error, url string, nm *netmap.NetworkMap) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
state := c.state
|
state := c.state
|
||||||
loggedIn := c.loggedIn
|
loggedIn := c.loggedIn
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
"tailscale.com/net/tshttpproxy"
|
"tailscale.com/net/tshttpproxy"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/opt"
|
"tailscale.com/types/opt"
|
||||||
"tailscale.com/types/persist"
|
"tailscale.com/types/persist"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
@ -468,7 +469,7 @@ func inTest() bool { return flag.Lookup("test.v") != nil }
|
|||||||
//
|
//
|
||||||
// maxPolls is how many network maps to download; common values are 1
|
// maxPolls is how many network maps to download; common values are 1
|
||||||
// or -1 (to keep a long-poll query open to the server).
|
// or -1 (to keep a long-poll query open to the server).
|
||||||
func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkMap)) error {
|
func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*netmap.NetworkMap)) error {
|
||||||
return c.sendMapRequest(ctx, maxPolls, cb)
|
return c.sendMapRequest(ctx, maxPolls, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +481,7 @@ func (c *Direct) SendLiteMapUpdate(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cb nil means to omit peers.
|
// cb nil means to omit peers.
|
||||||
func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*NetworkMap)) error {
|
func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netmap.NetworkMap)) error {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
persist := c.persist
|
persist := c.persist
|
||||||
serverURL := c.serverURL
|
serverURL := c.serverURL
|
||||||
@ -714,7 +715,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*Netw
|
|||||||
localPort = c.localPort
|
localPort = c.localPort
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
nm := &NetworkMap{
|
nm := &netmap.NetworkMap{
|
||||||
SelfNode: resp.Node,
|
SelfNode: resp.Node,
|
||||||
NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()),
|
NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()),
|
||||||
PrivateKey: persist.PrivateNodeKey,
|
PrivateKey: persist.PrivateNodeKey,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package controlclient
|
package controlclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@ -156,3 +157,15 @@ func TestNewDirect(t *testing.T) {
|
|||||||
t.Errorf("c.newEndpoints(13) want true got %v", changed)
|
t.Errorf("c.newEndpoints(13) want true got %v", changed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewHostinfo(t *testing.T) {
|
||||||
|
hi := NewHostinfo()
|
||||||
|
if hi == nil {
|
||||||
|
t.Fatal("no Hostinfo")
|
||||||
|
}
|
||||||
|
j, err := json.MarshalIndent(hi, " ", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Logf("Got: %s", j)
|
||||||
|
}
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/empty"
|
"tailscale.com/types/empty"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/structs"
|
"tailscale.com/types/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ type EngineStatus struct {
|
|||||||
// They are JSON-encoded on the wire, despite the lack of struct tags.
|
// They are JSON-encoded on the wire, despite the lack of struct tags.
|
||||||
type Notify struct {
|
type Notify struct {
|
||||||
_ structs.Incomparable
|
_ structs.Incomparable
|
||||||
Version string // version number of IPN backend
|
Version string // version number of IPN backend
|
||||||
ErrMessage *string // critical error message, if any; for InUseOtherUser, the details
|
ErrMessage *string // critical error message, if any; for InUseOtherUser, the details
|
||||||
LoginFinished *empty.Message // event: non-nil when login process succeeded
|
LoginFinished *empty.Message // event: non-nil when login process succeeded
|
||||||
State *State // current IPN state has changed
|
State *State // current IPN state has changed
|
||||||
Prefs *Prefs // preferences were changed
|
Prefs *Prefs // preferences were changed
|
||||||
NetMap *controlclient.NetworkMap // new netmap received
|
NetMap *netmap.NetworkMap // new netmap received
|
||||||
Engine *EngineStatus // wireguard engine stats
|
Engine *EngineStatus // wireguard engine stats
|
||||||
Status *ipnstate.Status // full status
|
Status *ipnstate.Status // full status
|
||||||
BrowseToURL *string // UI should open a browser right now
|
BrowseToURL *string // UI should open a browser right now
|
||||||
BackendLogID *string // public logtail id used by backend
|
BackendLogID *string // public logtail id used by backend
|
||||||
PingResult *ipnstate.PingResult
|
PingResult *ipnstate.PingResult
|
||||||
|
|
||||||
// LocalTCPPort, if non-nil, informs the UI frontend which
|
// LocalTCPPort, if non-nil, informs the UI frontend which
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeBackend struct {
|
type FakeBackend struct {
|
||||||
@ -54,7 +54,7 @@ func (b *FakeBackend) login() {
|
|||||||
b.newState(NeedsMachineAuth)
|
b.newState(NeedsMachineAuth)
|
||||||
b.newState(Stopped)
|
b.newState(Stopped)
|
||||||
// TODO(apenwarr): Fill in a more interesting netmap here.
|
// TODO(apenwarr): Fill in a more interesting netmap here.
|
||||||
b.notify(Notify{NetMap: &controlclient.NetworkMap{}})
|
b.notify(Notify{NetMap: &netmap.NetworkMap{}})
|
||||||
b.newState(Starting)
|
b.newState(Starting)
|
||||||
// TODO(apenwarr): Fill in a more interesting status.
|
// TODO(apenwarr): Fill in a more interesting status.
|
||||||
b.notify(Notify{Engine: &EngineStatus{}})
|
b.notify(Notify{Engine: &EngineStatus{}})
|
||||||
@ -92,7 +92,7 @@ func (b *FakeBackend) RequestStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *FakeBackend) FakeExpireAfter(x time.Duration) {
|
func (b *FakeBackend) FakeExpireAfter(x time.Duration) {
|
||||||
b.notify(Notify{NetMap: &controlclient.NetworkMap{}})
|
b.notify(Notify{NetMap: &netmap.NetworkMap{}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *FakeBackend) Ping(ip string) {
|
func (b *FakeBackend) Ping(ip string) {
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handle struct {
|
type Handle struct {
|
||||||
@ -22,7 +22,7 @@ type Handle struct {
|
|||||||
|
|
||||||
// Mutex protects everything below
|
// Mutex protects everything below
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
netmapCache *controlclient.NetworkMap
|
netmapCache *netmap.NetworkMap
|
||||||
engineStatusCache EngineStatus
|
engineStatusCache EngineStatus
|
||||||
stateCache State
|
stateCache State
|
||||||
prefsCache *Prefs
|
prefsCache *Prefs
|
||||||
@ -129,7 +129,7 @@ func (h *Handle) LocalAddrs() []netaddr.IPPrefix {
|
|||||||
return []netaddr.IPPrefix{}
|
return []netaddr.IPPrefix{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) NetMap() *controlclient.NetworkMap {
|
func (h *Handle) NetMap() *netmap.NetworkMap {
|
||||||
h.mu.Lock()
|
h.mu.Lock()
|
||||||
defer h.mu.Unlock()
|
defer h.mu.Unlock()
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"tailscale.com/types/empty"
|
"tailscale.com/types/empty"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/persist"
|
"tailscale.com/types/persist"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
"tailscale.com/util/systemd"
|
"tailscale.com/util/systemd"
|
||||||
@ -92,7 +93,7 @@ type LocalBackend struct {
|
|||||||
// hostinfo is mutated in-place while mu is held.
|
// hostinfo is mutated in-place while mu is held.
|
||||||
hostinfo *tailcfg.Hostinfo
|
hostinfo *tailcfg.Hostinfo
|
||||||
// netMap is not mutated in-place once set.
|
// netMap is not mutated in-place once set.
|
||||||
netMap *controlclient.NetworkMap
|
netMap *netmap.NetworkMap
|
||||||
nodeByAddr map[netaddr.IP]*tailcfg.Node
|
nodeByAddr map[netaddr.IP]*tailcfg.Node
|
||||||
activeLogin string // last logged LoginName from netMap
|
activeLogin string // last logged LoginName from netMap
|
||||||
engineStatus ipn.EngineStatus
|
engineStatus ipn.EngineStatus
|
||||||
@ -374,7 +375,7 @@ func (b *LocalBackend) setClientStatus(st controlclient.Status) {
|
|||||||
// routes provided by the exit node specified in b.prefs. It returns
|
// routes provided by the exit node specified in b.prefs. It returns
|
||||||
// whether prefs was mutated as part of the process, due to an exit
|
// whether prefs was mutated as part of the process, due to an exit
|
||||||
// node IP being converted into a node ID.
|
// node IP being converted into a node ID.
|
||||||
func (b *LocalBackend) keepOneExitNodeLocked(nm *controlclient.NetworkMap) (prefsChanged bool) {
|
func (b *LocalBackend) keepOneExitNodeLocked(nm *netmap.NetworkMap) (prefsChanged bool) {
|
||||||
if b.prefs.ExitNodeID == "" && b.prefs.ExitNodeIP.IsZero() {
|
if b.prefs.ExitNodeID == "" && b.prefs.ExitNodeIP.IsZero() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -601,7 +602,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
|
|
||||||
// updateFilter updates the packet filter in wgengine based on the
|
// updateFilter updates the packet filter in wgengine based on the
|
||||||
// given netMap and user preferences.
|
// given netMap and user preferences.
|
||||||
func (b *LocalBackend) updateFilter(netMap *controlclient.NetworkMap, prefs *ipn.Prefs) {
|
func (b *LocalBackend) updateFilter(netMap *netmap.NetworkMap, prefs *ipn.Prefs) {
|
||||||
// NOTE(danderson): keep change detection as the first thing in
|
// NOTE(danderson): keep change detection as the first thing in
|
||||||
// this function. Don't try to optimize by returning early, more
|
// this function. Don't try to optimize by returning early, more
|
||||||
// likely than not you'll just end up breaking the change
|
// likely than not you'll just end up breaking the change
|
||||||
@ -660,7 +661,7 @@ func dnsCIDRsEqual(newAddr, oldAddr []netaddr.IPPrefix) bool {
|
|||||||
// dnsMapsEqual determines whether the new and the old network map
|
// dnsMapsEqual determines whether the new and the old network map
|
||||||
// induce the same DNS map. It does so without allocating memory,
|
// induce the same DNS map. It does so without allocating memory,
|
||||||
// at the expense of giving false negatives if peers are reordered.
|
// at the expense of giving false negatives if peers are reordered.
|
||||||
func dnsMapsEqual(new, old *controlclient.NetworkMap) bool {
|
func dnsMapsEqual(new, old *netmap.NetworkMap) bool {
|
||||||
if (old == nil) != (new == nil) {
|
if (old == nil) != (new == nil) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -694,7 +695,7 @@ func dnsMapsEqual(new, old *controlclient.NetworkMap) bool {
|
|||||||
|
|
||||||
// updateDNSMap updates the domain map in the DNS resolver in wgengine
|
// updateDNSMap updates the domain map in the DNS resolver in wgengine
|
||||||
// based on the given netMap and user preferences.
|
// based on the given netMap and user preferences.
|
||||||
func (b *LocalBackend) updateDNSMap(netMap *controlclient.NetworkMap) {
|
func (b *LocalBackend) updateDNSMap(netMap *netmap.NetworkMap) {
|
||||||
if netMap == nil {
|
if netMap == nil {
|
||||||
b.logf("dns map: (not ready)")
|
b.logf("dns map: (not ready)")
|
||||||
return
|
return
|
||||||
@ -1215,7 +1216,7 @@ func (b *LocalBackend) doSetHostinfoFilterServices(hi *tailcfg.Hostinfo) {
|
|||||||
|
|
||||||
// NetMap returns the latest cached network map received from
|
// NetMap returns the latest cached network map received from
|
||||||
// controlclient, or nil if no network map was received yet.
|
// controlclient, or nil if no network map was received yet.
|
||||||
func (b *LocalBackend) NetMap() *controlclient.NetworkMap {
|
func (b *LocalBackend) NetMap() *netmap.NetworkMap {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
return b.netMap
|
return b.netMap
|
||||||
@ -1257,17 +1258,17 @@ func (b *LocalBackend) authReconfig() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags controlclient.WGConfigFlags
|
var flags netmap.WGConfigFlags
|
||||||
if uc.RouteAll {
|
if uc.RouteAll {
|
||||||
flags |= controlclient.AllowSubnetRoutes
|
flags |= netmap.AllowSubnetRoutes
|
||||||
}
|
}
|
||||||
if uc.AllowSingleHosts {
|
if uc.AllowSingleHosts {
|
||||||
flags |= controlclient.AllowSingleHosts
|
flags |= netmap.AllowSingleHosts
|
||||||
}
|
}
|
||||||
if hasPAC && disableSubnetsIfPAC {
|
if hasPAC && disableSubnetsIfPAC {
|
||||||
if flags&controlclient.AllowSubnetRoutes != 0 {
|
if flags&netmap.AllowSubnetRoutes != 0 {
|
||||||
b.logf("authReconfig: have PAC; disabling subnet routes")
|
b.logf("authReconfig: have PAC; disabling subnet routes")
|
||||||
flags &^= controlclient.AllowSubnetRoutes
|
flags &^= netmap.AllowSubnetRoutes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1303,7 +1304,7 @@ func (b *LocalBackend) authReconfig() {
|
|||||||
|
|
||||||
// magicDNSRootDomains returns the subset of nm.DNS.Domains that are the search domains for MagicDNS.
|
// magicDNSRootDomains returns the subset of nm.DNS.Domains that are the search domains for MagicDNS.
|
||||||
// Each entry has a trailing period.
|
// Each entry has a trailing period.
|
||||||
func magicDNSRootDomains(nm *controlclient.NetworkMap) []string {
|
func magicDNSRootDomains(nm *netmap.NetworkMap) []string {
|
||||||
if v := nm.MagicDNSSuffix(); v != "" {
|
if v := nm.MagicDNSSuffix(); v != "" {
|
||||||
return []string{strings.Trim(v, ".") + "."}
|
return []string{strings.Trim(v, ".") + "."}
|
||||||
}
|
}
|
||||||
@ -1596,7 +1597,7 @@ func (b *LocalBackend) setNetInfo(ni *tailcfg.NetInfo) {
|
|||||||
c.SetNetInfo(ni)
|
c.SetNetInfo(ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *LocalBackend) setNetMapLocked(nm *controlclient.NetworkMap) {
|
func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
||||||
var login string
|
var login string
|
||||||
if nm != nil {
|
if nm != nil {
|
||||||
login = nm.UserProfiles[nm.User].LoginName
|
login = nm.UserProfiles[nm.User].LoginName
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNetworkMapCompare(t *testing.T) {
|
func TestNetworkMapCompare(t *testing.T) {
|
||||||
@ -27,7 +27,7 @@ func TestNetworkMapCompare(t *testing.T) {
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
a, b *controlclient.NetworkMap
|
a, b *netmap.NetworkMap
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -38,76 +38,76 @@ func TestNetworkMapCompare(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"b nil",
|
"b nil",
|
||||||
&controlclient.NetworkMap{},
|
&netmap.NetworkMap{},
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"a nil",
|
"a nil",
|
||||||
nil,
|
nil,
|
||||||
&controlclient.NetworkMap{},
|
&netmap.NetworkMap{},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"both default",
|
"both default",
|
||||||
&controlclient.NetworkMap{},
|
&netmap.NetworkMap{},
|
||||||
&controlclient.NetworkMap{},
|
&netmap.NetworkMap{},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"names identical",
|
"names identical",
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&netmap.NetworkMap{Name: "map1"},
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&netmap.NetworkMap{Name: "map1"},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"names differ",
|
"names differ",
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&netmap.NetworkMap{Name: "map1"},
|
||||||
&controlclient.NetworkMap{Name: "map2"},
|
&netmap.NetworkMap{Name: "map2"},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Peers identical",
|
"Peers identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Peer list length",
|
"Peer list length",
|
||||||
// length of Peers list differs
|
// length of Peers list differs
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{{}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{{}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Node names identical",
|
"Node names identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Node names differ",
|
"Node names differ",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "B"}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "B"}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Node lists identical",
|
"Node lists identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Node lists differ",
|
"Node lists differ",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node2}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{node1, node2}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Node Users differ",
|
"Node Users differ",
|
||||||
// User field is not checked.
|
// User field is not checked.
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 0}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 0}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 1}}},
|
&netmap.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 1}}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package controlclient
|
// Package netmap contains the netmap.NetworkMap type.
|
||||||
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -2,11 +2,10 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package controlclient
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
@ -283,15 +282,3 @@ func TestConciseDiffFrom(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewHostinfo(t *testing.T) {
|
|
||||||
hi := NewHostinfo()
|
|
||||||
if hi == nil {
|
|
||||||
t.Fatal("no Hostinfo")
|
|
||||||
}
|
|
||||||
j, err := json.MarshalIndent(hi, " ", "")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Logf("Got: %s", j)
|
|
||||||
}
|
|
@ -48,6 +48,7 @@
|
|||||||
"tailscale.com/tstime"
|
"tailscale.com/tstime"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/nettype"
|
"tailscale.com/types/nettype"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
@ -273,7 +274,7 @@ type Conn struct {
|
|||||||
netInfoLast *tailcfg.NetInfo
|
netInfoLast *tailcfg.NetInfo
|
||||||
|
|
||||||
derpMap *tailcfg.DERPMap // nil (or zero regions/nodes) means DERP is disabled
|
derpMap *tailcfg.DERPMap // nil (or zero regions/nodes) means DERP is disabled
|
||||||
netMap *controlclient.NetworkMap
|
netMap *netmap.NetworkMap
|
||||||
privateKey key.Private // WireGuard private key for this node
|
privateKey key.Private // WireGuard private key for this node
|
||||||
everHadKey bool // whether we ever had a non-zero private key
|
everHadKey bool // whether we ever had a non-zero private key
|
||||||
myDerp int // nearest DERP region ID; 0 means none/unknown
|
myDerp int // nearest DERP region ID; 0 means none/unknown
|
||||||
@ -777,7 +778,7 @@ func (c *Conn) SetNetInfoCallback(fn func(*tailcfg.NetInfo)) {
|
|||||||
|
|
||||||
// peerForIP returns the Node in nm that's responsible for
|
// peerForIP returns the Node in nm that's responsible for
|
||||||
// handling the given IP address.
|
// handling the given IP address.
|
||||||
func peerForIP(nm *controlclient.NetworkMap, ip netaddr.IP) (n *tailcfg.Node, ok bool) {
|
func peerForIP(nm *netmap.NetworkMap, ip netaddr.IP) (n *tailcfg.Node, ok bool) {
|
||||||
if nm == nil {
|
if nm == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -2198,7 +2199,7 @@ func nodesEqual(x, y []*tailcfg.Node) bool {
|
|||||||
//
|
//
|
||||||
// It should not use the DERPMap field of NetworkMap; that's
|
// It should not use the DERPMap field of NetworkMap; that's
|
||||||
// conditionally sent to SetDERPMap instead.
|
// conditionally sent to SetDERPMap instead.
|
||||||
func (c *Conn) SetNetworkMap(nm *controlclient.NetworkMap) {
|
func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
"github.com/tailscale/wireguard-go/tun/tuntest"
|
"github.com/tailscale/wireguard-go/tun/tuntest"
|
||||||
"golang.org/x/crypto/nacl/box"
|
"golang.org/x/crypto/nacl/box"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/derp"
|
"tailscale.com/derp"
|
||||||
"tailscale.com/derp/derphttp"
|
"tailscale.com/derp/derphttp"
|
||||||
"tailscale.com/derp/derpmap"
|
"tailscale.com/derp/derpmap"
|
||||||
@ -41,6 +40,7 @@
|
|||||||
"tailscale.com/tstest/natlab"
|
"tailscale.com/tstest/natlab"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/nettype"
|
"tailscale.com/types/nettype"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
@ -252,9 +252,9 @@ func meshStacks(logf logger.Logf, ms []*magicStack) (cleanup func()) {
|
|||||||
eps = make([][]string, len(ms))
|
eps = make([][]string, len(ms))
|
||||||
)
|
)
|
||||||
|
|
||||||
buildNetmapLocked := func(myIdx int) *controlclient.NetworkMap {
|
buildNetmapLocked := func(myIdx int) *netmap.NetworkMap {
|
||||||
me := ms[myIdx]
|
me := ms[myIdx]
|
||||||
nm := &controlclient.NetworkMap{
|
nm := &netmap.NetworkMap{
|
||||||
PrivateKey: me.privateKey,
|
PrivateKey: me.privateKey,
|
||||||
NodeKey: tailcfg.NodeKey(me.privateKey.Public()),
|
NodeKey: tailcfg.NodeKey(me.privateKey.Public()),
|
||||||
Addresses: []netaddr.IPPrefix{{IP: netaddr.IPv4(1, 0, 0, byte(myIdx+1)), Bits: 32}},
|
Addresses: []netaddr.IPPrefix{{IP: netaddr.IPv4(1, 0, 0, byte(myIdx+1)), Bits: 32}},
|
||||||
@ -287,14 +287,14 @@ func meshStacks(logf logger.Logf, ms []*magicStack) (cleanup func()) {
|
|||||||
eps[idx] = newEps
|
eps[idx] = newEps
|
||||||
|
|
||||||
for i, m := range ms {
|
for i, m := range ms {
|
||||||
netmap := buildNetmapLocked(i)
|
nm := buildNetmapLocked(i)
|
||||||
m.conn.SetNetworkMap(netmap)
|
m.conn.SetNetworkMap(nm)
|
||||||
peerSet := make(map[key.Public]struct{}, len(netmap.Peers))
|
peerSet := make(map[key.Public]struct{}, len(nm.Peers))
|
||||||
for _, peer := range netmap.Peers {
|
for _, peer := range nm.Peers {
|
||||||
peerSet[key.Public(peer.Key)] = struct{}{}
|
peerSet[key.Public(peer.Key)] = struct{}{}
|
||||||
}
|
}
|
||||||
m.conn.UpdatePeers(peerSet)
|
m.conn.UpdatePeers(peerSet)
|
||||||
wg, err := nmcfg.WGCfg(netmap, logf, controlclient.AllowSingleHosts)
|
wg, err := nmcfg.WGCfg(nm, logf, netmap.AllowSingleHosts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// We're too far from the *testing.T to be graceful,
|
// We're too far from the *testing.T to be graceful,
|
||||||
// blow up. Shouldn't happen anyway.
|
// blow up. Shouldn't happen anyway.
|
||||||
@ -1433,7 +1433,7 @@ func BenchmarkReceiveFrom(b *testing.B) {
|
|||||||
// valid peer and not fall through to the legacy magicsock
|
// valid peer and not fall through to the legacy magicsock
|
||||||
// codepath.
|
// codepath.
|
||||||
discoKey := tailcfg.DiscoKey{31: 1}
|
discoKey := tailcfg.DiscoKey{31: 1}
|
||||||
conn.SetNetworkMap(&controlclient.NetworkMap{
|
conn.SetNetworkMap(&netmap.NetworkMap{
|
||||||
Peers: []*tailcfg.Node{
|
Peers: []*tailcfg.Node{
|
||||||
{
|
{
|
||||||
DiscoKey: discoKey,
|
DiscoKey: discoKey,
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
"gvisor.dev/gvisor/pkg/tcpip/transport/udp"
|
"gvisor.dev/gvisor/pkg/tcpip/transport/udp"
|
||||||
"gvisor.dev/gvisor/pkg/waiter"
|
"gvisor.dev/gvisor/pkg/waiter"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/net/packet"
|
"tailscale.com/net/packet"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/wgengine"
|
"tailscale.com/wgengine"
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
"tailscale.com/wgengine/magicsock"
|
"tailscale.com/wgengine/magicsock"
|
||||||
@ -63,7 +63,7 @@ func Impl(logf logger.Logf, tundev *tstun.TUN, e wgengine.Engine, mc *magicsock.
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.AddNetworkMapCallback(func(nm *controlclient.NetworkMap) {
|
e.AddNetworkMapCallback(func(nm *netmap.NetworkMap) {
|
||||||
oldIPs := make(map[tcpip.Address]bool)
|
oldIPs := make(map[tcpip.Address]bool)
|
||||||
for _, ip := range ipstack.AllAddresses()[nicID] {
|
for _, ip := range ipstack.AllAddresses()[nicID] {
|
||||||
oldIPs[ip.AddressWithPrefix.Address] = true
|
oldIPs[ip.AddressWithPrefix.Address] = true
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
"tailscale.com/version/distro"
|
"tailscale.com/version/distro"
|
||||||
@ -1324,7 +1325,7 @@ func (e *userspaceEngine) SetDERPMap(dm *tailcfg.DERPMap) {
|
|||||||
e.magicConn.SetDERPMap(dm)
|
e.magicConn.SetDERPMap(dm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *userspaceEngine) SetNetworkMap(nm *controlclient.NetworkMap) {
|
func (e *userspaceEngine) SetNetworkMap(nm *netmap.NetworkMap) {
|
||||||
e.magicConn.SetNetworkMap(nm)
|
e.magicConn.SetNetworkMap(nm)
|
||||||
e.mu.Lock()
|
e.mu.Lock()
|
||||||
callbacks := make([]NetworkMapCallback, 0, 4)
|
callbacks := make([]NetworkMapCallback, 0, 4)
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/net/interfaces"
|
"tailscale.com/net/interfaces"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
"tailscale.com/wgengine/router"
|
"tailscale.com/wgengine/router"
|
||||||
"tailscale.com/wgengine/tsdns"
|
"tailscale.com/wgengine/tsdns"
|
||||||
@ -107,7 +107,7 @@ func (e *watchdogEngine) SetLinkChangeCallback(cb func(major bool, newState *int
|
|||||||
func (e *watchdogEngine) SetDERPMap(m *tailcfg.DERPMap) {
|
func (e *watchdogEngine) SetDERPMap(m *tailcfg.DERPMap) {
|
||||||
e.watchdog("SetDERPMap", func() { e.wrap.SetDERPMap(m) })
|
e.watchdog("SetDERPMap", func() { e.wrap.SetDERPMap(m) })
|
||||||
}
|
}
|
||||||
func (e *watchdogEngine) SetNetworkMap(nm *controlclient.NetworkMap) {
|
func (e *watchdogEngine) SetNetworkMap(nm *netmap.NetworkMap) {
|
||||||
e.watchdog("SetNetworkMap", func() { e.wrap.SetNetworkMap(nm) })
|
e.watchdog("SetNetworkMap", func() { e.wrap.SetNetworkMap(nm) })
|
||||||
}
|
}
|
||||||
func (e *watchdogEngine) AddNetworkMapCallback(callback NetworkMapCallback) func() {
|
func (e *watchdogEngine) AddNetworkMapCallback(callback NetworkMapCallback) func() {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"tailscale.com/net/tsaddr"
|
"tailscale.com/net/tsaddr"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/wgengine/wgcfg"
|
"tailscale.com/wgengine/wgcfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ func cidrIsSubnet(node *tailcfg.Node, cidr netaddr.IPPrefix) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WGCfg returns the NetworkMaps's Wireguard configuration.
|
// WGCfg returns the NetworkMaps's Wireguard configuration.
|
||||||
func WGCfg(nm *controlclient.NetworkMap, logf logger.Logf, flags controlclient.WGConfigFlags) (*wgcfg.Config, error) {
|
func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags) (*wgcfg.Config, error) {
|
||||||
cfg := &wgcfg.Config{
|
cfg := &wgcfg.Config{
|
||||||
Name: "tailscale",
|
Name: "tailscale",
|
||||||
PrivateKey: wgcfg.PrivateKey(nm.PrivateKey),
|
PrivateKey: wgcfg.PrivateKey(nm.PrivateKey),
|
||||||
@ -88,12 +89,12 @@ func WGCfg(nm *controlclient.NetworkMap, logf logger.Logf, flags controlclient.W
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, allowedIP := range peer.AllowedIPs {
|
for _, allowedIP := range peer.AllowedIPs {
|
||||||
if allowedIP.IsSingleIP() && tsaddr.IsTailscaleIP(allowedIP.IP) && (flags&controlclient.AllowSingleHosts) == 0 {
|
if allowedIP.IsSingleIP() && tsaddr.IsTailscaleIP(allowedIP.IP) && (flags&netmap.AllowSingleHosts) == 0 {
|
||||||
logf("[v1] wgcfg: skipping node IP %v from %q (%v)",
|
logf("[v1] wgcfg: skipping node IP %v from %q (%v)",
|
||||||
allowedIP.IP, nodeDebugName(peer), peer.Key.ShortString())
|
allowedIP.IP, nodeDebugName(peer), peer.Key.ShortString())
|
||||||
continue
|
continue
|
||||||
} else if cidrIsSubnet(peer, allowedIP) {
|
} else if cidrIsSubnet(peer, allowedIP) {
|
||||||
if (flags & controlclient.AllowSubnetRoutes) == 0 {
|
if (flags & netmap.AllowSubnetRoutes) == 0 {
|
||||||
logf("[v1] wgcfg: not accepting subnet route %v from %q (%v)",
|
logf("[v1] wgcfg: not accepting subnet route %v from %q (%v)",
|
||||||
allowedIP, nodeDebugName(peer), peer.Key.ShortString())
|
allowedIP, nodeDebugName(peer), peer.Key.ShortString())
|
||||||
continue
|
continue
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/control/controlclient"
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/net/interfaces"
|
"tailscale.com/net/interfaces"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
"tailscale.com/wgengine/router"
|
"tailscale.com/wgengine/router"
|
||||||
"tailscale.com/wgengine/tsdns"
|
"tailscale.com/wgengine/tsdns"
|
||||||
@ -38,7 +38,7 @@ type Status struct {
|
|||||||
|
|
||||||
// NetworkMapCallback is the type used by callbacks that hook
|
// NetworkMapCallback is the type used by callbacks that hook
|
||||||
// into network map updates.
|
// into network map updates.
|
||||||
type NetworkMapCallback func(*controlclient.NetworkMap)
|
type NetworkMapCallback func(*netmap.NetworkMap)
|
||||||
|
|
||||||
// someHandle is allocated so its pointer address acts as a unique
|
// someHandle is allocated so its pointer address acts as a unique
|
||||||
// map key handle. (It needs to have non-zero size for Go to guarantee
|
// map key handle. (It needs to have non-zero size for Go to guarantee
|
||||||
@ -108,7 +108,7 @@ type Engine interface {
|
|||||||
// ignored as as it might be disabled; get it from SetDERPMap
|
// ignored as as it might be disabled; get it from SetDERPMap
|
||||||
// instead.
|
// instead.
|
||||||
// The network map should only be read from.
|
// The network map should only be read from.
|
||||||
SetNetworkMap(*controlclient.NetworkMap)
|
SetNetworkMap(*netmap.NetworkMap)
|
||||||
|
|
||||||
// AddNetworkMapCallback adds a function to a list of callbacks
|
// AddNetworkMapCallback adds a function to a list of callbacks
|
||||||
// that are called when the network map updates. It returns a
|
// that are called when the network map updates. It returns a
|
||||||
|
Loading…
Reference in New Issue
Block a user