ipn, wgengine/filter: remove exported type aliases
This commit is contained in:
parent
8b0be7475b
commit
8a3e77fc43
|
@ -39,8 +39,6 @@ type EngineStatus struct {
|
||||||
LivePeers map[tailcfg.NodeKey]wgengine.PeerStatus
|
LivePeers map[tailcfg.NodeKey]wgengine.PeerStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkMap = controlclient.NetworkMap
|
|
||||||
|
|
||||||
// Notify is a communication from a backend (e.g. tailscaled) to a frontend
|
// Notify is a communication from a backend (e.g. tailscaled) to a frontend
|
||||||
// (cmd/tailscale, iOS, macOS, Win Tasktray).
|
// (cmd/tailscale, iOS, macOS, Win Tasktray).
|
||||||
// In any given notification, any or all of these may be nil, meaning
|
// In any given notification, any or all of these may be nil, meaning
|
||||||
|
@ -48,16 +46,16 @@ type NetworkMap = controlclient.NetworkMap
|
||||||
// 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
|
ErrMessage *string // critical error message, if any
|
||||||
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 *NetworkMap // new netmap received
|
NetMap *controlclient.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
|
||||||
|
|
||||||
// type is mirrored in xcode/Shared/IPN.swift
|
// type is mirrored in xcode/Shared/IPN.swift
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"tailscale.com/control/controlclient"
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ func (b *FakeBackend) StartLoginInteractive() {
|
||||||
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: &NetworkMap{}})
|
b.notify(Notify{NetMap: &controlclient.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{}})
|
||||||
|
@ -78,5 +79,5 @@ func (b *FakeBackend) RequestStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *FakeBackend) FakeExpireAfter(x time.Duration) {
|
func (b *FakeBackend) FakeExpireAfter(x time.Duration) {
|
||||||
b.notify(Notify{NetMap: &NetworkMap{}})
|
b.notify(Notify{NetMap: &controlclient.NetworkMap{}})
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tailscale/wireguard-go/wgcfg"
|
"github.com/tailscale/wireguard-go/wgcfg"
|
||||||
|
"tailscale.com/control/controlclient"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ type Handle struct {
|
||||||
|
|
||||||
// Mutex protects everything below
|
// Mutex protects everything below
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
netmapCache *NetworkMap
|
netmapCache *controlclient.NetworkMap
|
||||||
engineStatusCache EngineStatus
|
engineStatusCache EngineStatus
|
||||||
stateCache State
|
stateCache State
|
||||||
prefsCache *Prefs
|
prefsCache *Prefs
|
||||||
|
@ -127,7 +128,7 @@ func (h *Handle) LocalAddrs() []wgcfg.CIDR {
|
||||||
return []wgcfg.CIDR{}
|
return []wgcfg.CIDR{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) NetMap() *NetworkMap {
|
func (h *Handle) NetMap() *controlclient.NetworkMap {
|
||||||
h.mu.Lock()
|
h.mu.Lock()
|
||||||
defer h.mu.Unlock()
|
defer h.mu.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type tuple struct {
|
type tuple struct {
|
||||||
SrcIP IP
|
SrcIP packet.IP
|
||||||
DstIP IP
|
DstIP packet.IP
|
||||||
SrcPort uint16
|
SrcPort uint16
|
||||||
DstPort uint16
|
DstPort uint16
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@ import (
|
||||||
"tailscale.com/wgengine/packet"
|
"tailscale.com/wgengine/packet"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Type aliases only in test code: (but ideally nowhere)
|
||||||
type QDecode = packet.QDecode
|
type QDecode = packet.QDecode
|
||||||
|
type IP = packet.IP
|
||||||
|
|
||||||
var Junk = packet.Junk
|
var Junk = packet.Junk
|
||||||
var ICMP = packet.ICMP
|
var ICMP = packet.ICMP
|
||||||
|
|
|
@ -13,18 +13,16 @@ import (
|
||||||
"tailscale.com/wgengine/packet"
|
"tailscale.com/wgengine/packet"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IP = packet.IP
|
func NewIP(ip net.IP) packet.IP {
|
||||||
|
|
||||||
func NewIP(ip net.IP) IP {
|
|
||||||
return packet.NewIP(ip)
|
return packet.NewIP(ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Net struct {
|
type Net struct {
|
||||||
IP IP
|
IP packet.IP
|
||||||
Mask IP
|
Mask packet.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Net) Includes(ip IP) bool {
|
func (n Net) Includes(ip packet.IP) bool {
|
||||||
return (n.IP & n.Mask) == (ip & n.Mask)
|
return (n.IP & n.Mask) == (ip & n.Mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,11 +42,11 @@ func (n Net) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var NetAny = Net{0, 0}
|
var NetAny = Net{0, 0}
|
||||||
var NetNone = Net{^IP(0), ^IP(0)}
|
var NetNone = Net{^packet.IP(0), ^packet.IP(0)}
|
||||||
|
|
||||||
func Netmask(bits int) IP {
|
func Netmask(bits int) packet.IP {
|
||||||
b := ^uint32((1 << (32 - bits)) - 1)
|
b := ^uint32((1 << (32 - bits)) - 1)
|
||||||
return IP(b)
|
return packet.IP(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortRange struct {
|
type PortRange struct {
|
||||||
|
@ -126,7 +124,7 @@ func (m Matches) Clone() (res Matches) {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func ipInList(ip IP, netlist []Net) bool {
|
func ipInList(ip packet.IP, netlist []Net) bool {
|
||||||
for _, net := range netlist {
|
for _, net := range netlist {
|
||||||
if net.Includes(ip) {
|
if net.Includes(ip) {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue