netmap

package
v0.0.0-...-9d29f1b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package netmap contains the netmap.NetworkMap type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MagicDNSSuffixOfNodeName

func MagicDNSSuffixOfNodeName(nodeName string) string

MagicDNSSuffix returns the domain's MagicDNS suffix (even if MagicDNS isn't necessarily in use) of the provided Node.Name value.

It will neither start nor end with a period.

Types

type NetworkMap

type NetworkMap struct {
	SelfNode   tailcfg.NodeView
	NodeKey    key.NodePublic
	PrivateKey key.NodePrivate
	Expiry     time.Time
	// Name is the DNS name assigned to this node.
	// It is the MapResponse.Node.Name value and ends with a period.
	Name string

	// Addresses is SelfNode.Addresses. (IP addresses of this Node directly)
	//
	// TODO(bradfitz): remove this field and make this a method.
	Addresses []netip.Prefix

	// MachineStatus is either tailcfg.MachineAuthorized or tailcfg.MachineUnauthorized,
	// depending on SelfNode.MachineAuthorized.
	// TODO(bradfitz): remove this field and make it a method.
	MachineStatus tailcfg.MachineStatus

	MachineKey key.MachinePublic

	Peers []tailcfg.NodeView // sorted by Node.ID
	DNS   tailcfg.DNSConfig

	PacketFilter      []filter.Match
	PacketFilterRules views.Slice[tailcfg.FilterRule]
	SSHPolicy         *tailcfg.SSHPolicy // or nil, if not enabled/allowed

	// CollectServices reports whether this node's Tailnet has
	// requested that info about services be included in HostInfo.
	// If set, Hostinfo.ShieldsUp blocks services collection; that
	// takes precedence over this field.
	CollectServices bool

	// DERPMap is the last DERP server map received. It's reused
	// between updates and should not be modified.
	DERPMap *tailcfg.DERPMap

	// ControlHealth are the list of health check problems for this
	// node from the perspective of the control plane.
	// If empty, there are no known problems from the control plane's
	// point of view, but the node might know about its own health
	// check problems.
	ControlHealth []string

	// TKAEnabled indicates whether the tailnet key authority should be
	// enabled, from the perspective of the control plane.
	TKAEnabled bool
	// TKAHead indicates the control plane's understanding of 'head' (the
	// hash of the latest update message to tick through TKA).
	TKAHead tka.AUMHash

	// Domain is the current Tailnet name.
	Domain string

	// DomainAuditLogID is an audit log ID provided by control and
	// only populated if the domain opts into data-plane audit logging.
	// If this is empty, then data-plane audit logging is disabled.
	DomainAuditLogID string

	UserProfiles map[tailcfg.UserID]tailcfg.UserProfile
}

NetworkMap is the current state of the world.

The fields should all be considered read-only. They might alias parts of previous NetworkMap values.

func (*NetworkMap) AnyPeersAdvertiseRoutes

func (nm *NetworkMap) AnyPeersAdvertiseRoutes() bool

AnyPeersAdvertiseRoutes reports whether any peer is advertising non-exit node routes.

func (*NetworkMap) Concise

func (nm *NetworkMap) Concise() string

func (*NetworkMap) ConciseDiffFrom

func (b *NetworkMap) ConciseDiffFrom(a *NetworkMap) string

func (*NetworkMap) JSON

func (nm *NetworkMap) JSON() string

func (*NetworkMap) MagicDNSSuffix

func (nm *NetworkMap) MagicDNSSuffix() string

MagicDNSSuffix returns the domain's MagicDNS suffix (even if MagicDNS isn't necessarily in use).

It will neither start nor end with a period.

func (*NetworkMap) PeerByTailscaleIP

func (nm *NetworkMap) PeerByTailscaleIP(ip netip.Addr) (peer tailcfg.NodeView, ok bool)

PeerByTailscaleIP returns a peer's Node based on its Tailscale IP.

If nm is nil or no peer is found, ok is false.

func (*NetworkMap) PeerWithStableID

func (nm *NetworkMap) PeerWithStableID(pid tailcfg.StableNodeID) (_ tailcfg.NodeView, ok bool)

PeerWithStableID finds and returns the peer associated to the inputted StableNodeID.

func (*NetworkMap) SelfCapabilities

func (nm *NetworkMap) SelfCapabilities() views.Slice[string]

SelfCapabilities returns SelfNode.Capabilities if nm and nm.SelfNode are non-nil. This is a method so we can use it in envknob/logknob without a circular dependency.

func (*NetworkMap) String

func (nm *NetworkMap) String() string

func (*NetworkMap) User

func (nm *NetworkMap) User() tailcfg.UserID

User returns nm.SelfNode.User if nm.SelfNode is non-nil, otherwise it returns 0.

func (*NetworkMap) VeryConcise

func (nm *NetworkMap) VeryConcise() string

type WGConfigFlags

type WGConfigFlags int

WGConfigFlags is a bitmask of flags to control the behavior of the wireguard configuration generation done by NetMap.WGCfg.

const (
	AllowSingleHosts WGConfigFlags = 1 << iota
	AllowSubnetRoutes
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL