tailcfg

package
v0.97.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: BSD-3-Clause Imports: 10 Imported by: 242

Documentation

Index

Constants

View Source
const (
	CapRead  = CapType("read")
	CapWrite = CapType("write")
)
View Source
const (
	MachineUnknown      = MachineStatus(iota)
	MachineUnauthorized // server has yet to approve
	MachineAuthorized   // server has approved
	MachineInvalid      // server has explicitly rejected this machine key
)
View Source
const (
	TCP = ServiceProto("tcp")
	UDP = ServiceProto("udp")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CapType

type CapType string

type Capability

type Capability struct {
	ID   CapabilityID
	Type CapType
	Val  ID
}

type CapabilityID

type CapabilityID ID

func (CapabilityID) String

func (id CapabilityID) String() string

type Group

type Group struct {
	ID      GroupID
	Name    string
	Members []ID
}

type GroupID

type GroupID ID

func (GroupID) String

func (id GroupID) String() string

type Hostinfo

type Hostinfo struct {
	// TODO(crawshaw): mark all these fields ",omitempty" when all the
	// iOS apps are updated with the latest swift version of this struct.
	IPNVersion    string       // version of this code
	FrontendLogID string       // logtail ID of frontend instance
	BackendLogID  string       // logtail ID of backend instance
	OS            string       // operating system the client runs on
	Hostname      string       // name of the host the client runs on
	RoutableIPs   []wgcfg.CIDR `json:",omitempty"` // set of IP ranges this client can route
	Services      []Service    `json:",omitempty"` // services advertised by this machine
	NetInfo       *NetInfo     `json:",omitempty"`
}

Hostinfo contains a summary of a Tailscale host.

Because it contains pointers (slices), this type should not be used as a value type.

func (*Hostinfo) Clone

func (h *Hostinfo) Clone() (res *Hostinfo)

Clone makes a deep copy of Hostinfo. The result aliases no memory with the original.

func (*Hostinfo) Equal

func (h *Hostinfo) Equal(h2 *Hostinfo) bool

Equal reports whether h and h2 are equal.

type ID

type ID int64

func (ID) String

func (id ID) String() string

type Login

type Login struct {
	ID            LoginID
	Provider      string
	LoginName     string
	DisplayName   string
	ProfilePicURL string
	Domain        string
}

type LoginID

type LoginID ID

func (LoginID) String

func (id LoginID) String() string

type MachineKey

type MachineKey [32]byte

MachineKey is the curve25519 public key for a machine.

func (MachineKey) MarshalText

func (k MachineKey) MarshalText() ([]byte, error)

func (MachineKey) String

func (k MachineKey) String() string

func (*MachineKey) UnmarshalText

func (k *MachineKey) UnmarshalText(text []byte) error

type MachineStatus

type MachineStatus int

func (MachineStatus) MarshalText

func (m MachineStatus) MarshalText() ([]byte, error)

func (MachineStatus) String

func (m MachineStatus) String() string

func (*MachineStatus) UnmarshalText

func (m *MachineStatus) UnmarshalText(b []byte) error

type MapRequest

type MapRequest struct {
	Version   int    // current version is 4
	Compress  string // "zstd" or "" (no compression)
	KeepAlive bool   // server sends keep-alives
	NodeKey   NodeKey
	Endpoints []string
	Stream    bool // if true, multiple MapResponse objects are returned
	Hostinfo  *Hostinfo
}

MapRequest is sent by a client to start a long-poll network map updates. The request includes a copy of the client's current set of WireGuard endpoints and general host information.

The request is encoded to JSON, encrypted with golang.org/x/crypto/nacl/box, using the local machine key, and sent to:

https://login.tailscale.com/machine/<mkey hex>/map

type MapResponse

type MapResponse struct {
	KeepAlive bool // if set, all other fields are ignored

	// Networking
	Node        Node
	Peers       []Node
	DNS         []wgcfg.IP
	SearchPaths []string

	// ACLs
	Domain       string
	PacketFilter filter.Matches
	UserProfiles []UserProfile
	Roles        []Role
}

type NetInfo

type NetInfo struct {
	// MappingVariesByDestIP says whether the host's NAT mappings
	// vary based on the destination IP.
	MappingVariesByDestIP opt.Bool

	// HairPinning is their router does hairpinning.
	// It reports true even if there's no NAT involved.
	HairPinning opt.Bool

	// WorkingIPv6 is whether IPv6 works.
	WorkingIPv6 opt.Bool

	// WorkingUDP is whether UDP works.
	WorkingUDP opt.Bool

	// PreferredDERP is this node's preferred DERP server
	// for incoming traffic. The node might be be temporarily
	// connected to multiple DERP servers (to send to other nodes)
	// but PreferredDERP is the instance number that the node
	// subscribes to traffic at.
	// Zero means disconnected or unknown.
	PreferredDERP int

	// LinkType is the current link type, if known.
	LinkType string // "wired", "wifi", "mobile" (LTE, 4G, 3G, etc)

	// DERPLatency is the fastest recent time to reach various
	// DERP STUN servers, in seconds. The map key is the DERP
	// server's STUN host:port.
	//
	// This should only be updated rarely, or when there's a
	// material change, as any change here also gets uploaded to
	// the control plane.
	DERPLatency map[string]float64 `json:",omitempty"`
}

NetInfo contains information about the host's network state.

func (*NetInfo) BasicallyEqual

func (ni *NetInfo) BasicallyEqual(ni2 *NetInfo) bool

BasicallyEqual reports whether ni and ni2 are basically equal, ignoring changes in DERPLatency.

func (*NetInfo) Clone

func (ni *NetInfo) Clone() (res *NetInfo)

func (*NetInfo) String

func (ni *NetInfo) String() string

type Node

type Node struct {
	ID         NodeID
	Name       string // DNS
	User       UserID
	Key        NodeKey
	KeyExpiry  time.Time
	Machine    MachineKey
	Addresses  []wgcfg.CIDR // IP addresses of this Node directly
	AllowedIPs []wgcfg.CIDR // range of IP addresses to route to this node
	Endpoints  []string     `json:",omitempty"` // IP+port (public via STUN, and local LANs)
	DERP       string       `json:",omitempty"` // DERP-in-IP:port ("127.3.3.40:N") endpoint
	Hostinfo   Hostinfo
	Created    time.Time
	LastSeen   *time.Time `json:",omitempty"`

	KeepAlive bool // open and keep open a connection to this peer

	MachineAuthorized bool // TODO(crawshaw): replace with MachineStatus

}

func (*Node) Clone

func (n *Node) Clone() (res *Node)

Clone makes a deep copy of Node. The result aliases no memory with the original.

func (*Node) Equal

func (n *Node) Equal(n2 *Node) bool

Equal reports whether n and n2 are equal.

type NodeID

type NodeID ID

func (NodeID) String

func (id NodeID) String() string

type NodeKey

type NodeKey [32]byte

MachineKey is the curve25519 public key for a node.

func (NodeKey) AbbrevString

func (k NodeKey) AbbrevString() string

func (*NodeKey) IsZero

func (k *NodeKey) IsZero() bool

func (NodeKey) MarshalText

func (k NodeKey) MarshalText() ([]byte, error)

func (NodeKey) String

func (k NodeKey) String() string

func (*NodeKey) UnmarshalText

func (k *NodeKey) UnmarshalText(text []byte) error

type RegisterRequest

type RegisterRequest struct {
	Version    int // currently 1
	NodeKey    NodeKey
	OldNodeKey NodeKey
	Auth       struct {
		Provider  string
		LoginName string
		// One of LoginName or Oauth2Token is set.
		Oauth2Token *oauth2.Token
	}
	Expiry   time.Time // requested key expiry, server policy may override
	Followup string    // response waits until AuthURL is visited
	Hostinfo *Hostinfo
}

RegisterRequest is sent by a client to register the key for a node. It is encoded to JSON, encrypted with golang.org/x/crypto/nacl/box, using the local machine key, and sent to:

https://login.tailscale.com/machine/<mkey hex>

func (*RegisterRequest) Clone

func (req *RegisterRequest) Clone() *RegisterRequest

Clone makes a deep copy of RegisterRequest. The result aliases no memory with the original.

type RegisterResponse

type RegisterResponse struct {
	User              User
	Login             Login
	NodeKeyExpired    bool   // if true, the NodeKey needs to be replaced
	MachineAuthorized bool   // TODO(crawshaw): move to using MachineStatus
	AuthURL           string // if set, authorization pending
}

RegisterResponse is returned by the server in response to a RegisterRequest.

type Role

type Role struct {
	ID           RoleID
	Name         string
	Capabilities []CapabilityID
}

type RoleID

type RoleID ID

func (RoleID) String

func (id RoleID) String() string

type Service

type Service struct {
	Proto       ServiceProto // TCP or UDP
	Port        uint16       // port number service is listening on
	Description string       // text description of service

}

type ServiceProto

type ServiceProto string

type User

type User struct {
	ID            UserID
	LoginName     string `json:"-"` // not stored, filled from Login // TODO REMOVE
	DisplayName   string // if non-empty overrides Login field
	ProfilePicURL string // if non-empty overrides Login field
	Domain        string
	Logins        []LoginID
	Roles         []RoleID
	Created       time.Time
}

User is an IPN user.

A user can have multiple logins associated with it (e.g. gmail and github oauth). (Note: none of our UIs support this yet.)

Some properties are inhereted from the logins and can be overridden, such as display name and profile picture.

Other properties must be the same for all logins associated with a user. In particular: domain. If a user has a "tailscale.io" domain login, they cannot have a general gmail address login associated with the user.

func (*User) Clone

func (u *User) Clone() *User

Clone returns a copy of u that aliases no memory with the original.

type UserID

type UserID ID

func (UserID) String

func (id UserID) String() string

type UserProfile

type UserProfile struct {
	ID            UserID
	LoginName     string // for display purposes only (provider is not listed)
	DisplayName   string
	ProfilePicURL string
	Roles         []RoleID
}

A UserProfile is display-friendly data for a user. It includes the LoginName for display purposes but *not* the Provider. It also includes derived data from one of the user's logins.

Jump to

Keyboard shortcuts

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