Documentation ¶
Index ¶
- Constants
- Variables
- func GetDNSConfig() (*tailcfg.DNSConfig, string)
- func IsCLIConfigured() bool
- func LoadConfig(path string, isFile bool) error
- type ACLConfig
- type APIKey
- type CLIConfig
- type Config
- type DERPConfig
- type IPPrefix
- type IPPrefixes
- type LetsEncryptConfig
- type LogConfig
- type LogTailConfig
- type Node
- func (node *Node) AfterFind(tx *gorm.DB) error
- func (node *Node) ApplyPeerChange(change *tailcfg.PeerChange)
- func (node *Node) BeforeSave(tx *gorm.DB) error
- func (node *Node) CanAccess(filter []tailcfg.FilterRule, node2 *Node) bool
- func (node *Node) GetFQDN(dnsConfig *tailcfg.DNSConfig, baseDomain string) (string, error)
- func (node *Node) IsEphemeral() bool
- func (node Node) IsExpired() bool
- func (node *Node) PeerChangeFromMapRequest(req tailcfg.MapRequest) tailcfg.PeerChange
- func (node *Node) Proto() *v1.Node
- type NodeAddresses
- func (na NodeAddresses) AppendToIPSet(build *netipx.IPSetBuilder)
- func (na NodeAddresses) InIPSet(set *netipx.IPSet) bool
- func (na NodeAddresses) Prefixes() []netip.Prefix
- func (na *NodeAddresses) Scan(destination interface{}) error
- func (na NodeAddresses) Sort()
- func (na NodeAddresses) StringSlice() []string
- func (na NodeAddresses) Value() (driver.Value, error)
- type Nodes
- type OIDCConfig
- type PreAuthKey
- type PreAuthKeyACLTag
- type Route
- type Routes
- type StateUpdate
- type StateUpdateType
- type StringList
- type TLSConfig
- type User
Constants ¶
Variables ¶
var ( ErrNodeAddressesInvalid = errors.New("failed to parse node addresses") ErrHostnameTooLong = errors.New("hostname too long, cannot except 255 ASCII chars") ErrNodeHasNoGivenName = errors.New("node has no given name") ErrNodeUserHasNoName = errors.New("node user has no name") )
var ( ExitRouteV4 = netip.MustParsePrefix("0.0.0.0/0") ExitRouteV6 = netip.MustParsePrefix("::/0") )
var ErrCannotParsePrefix = errors.New("cannot parse prefix")
Functions ¶
func GetDNSConfig ¶
func IsCLIConfigured ¶
func IsCLIConfigured() bool
func LoadConfig ¶
Types ¶
type ACLConfig ¶
type ACLConfig struct {
PolicyPath string
}
func GetACLConfig ¶
func GetACLConfig() ACLConfig
type APIKey ¶
type APIKey struct { ID uint64 `gorm:"primary_key"` Prefix string `gorm:"uniqueIndex"` Hash []byte CreatedAt *time.Time Expiration *time.Time LastSeen *time.Time }
APIKey describes the datamodel for API keys used to remotely authenticate with headscale.
type Config ¶
type Config struct { ServerURL string Addr string MetricsAddr string GRPCAddr string GRPCAllowInsecure bool EphemeralNodeInactivityTimeout time.Duration NodeUpdateCheckInterval time.Duration IPPrefixes []netip.Prefix NoisePrivateKeyPath string BaseDomain string Log LogConfig DisableUpdateCheck bool DERP DERPConfig DBtype string DBpath string DBhost string DBport int DBname string DBuser string DBpass string DBssl string TLS TLSConfig ACMEURL string ACMEEmail string DNSConfig *tailcfg.DNSConfig UnixSocket string UnixSocketPermission fs.FileMode OIDC OIDCConfig LogTail LogTailConfig RandomizeClientPort bool CLI CLIConfig ACL ACLConfig }
Config contains the initial Headscale configuration.
func GetHeadscaleConfig ¶
type DERPConfig ¶
type DERPConfig struct { ServerEnabled bool AutomaticallyAddEmbeddedDerpRegion bool ServerRegionID int ServerRegionCode string ServerRegionName string ServerPrivateKeyPath string STUNAddr string URLs []url.URL Paths []string AutoUpdate bool UpdateFrequency time.Duration IPv4 string IPv6 string }
func GetDERPConfig ¶
func GetDERPConfig() DERPConfig
type IPPrefixes ¶
func (*IPPrefixes) Scan ¶
func (i *IPPrefixes) Scan(destination interface{}) error
type LetsEncryptConfig ¶
type LogConfig ¶
func GetLogConfig ¶
func GetLogConfig() LogConfig
type LogTailConfig ¶
type LogTailConfig struct {
Enabled bool
}
func GetLogTailConfig ¶
func GetLogTailConfig() LogTailConfig
type Node ¶
type Node struct { ID uint64 `gorm:"primary_key"` // MachineKeyDatabaseField is the string representation of MachineKey // it is _only_ used for reading and writing the key to the // database and should not be used. // Use MachineKey instead. MachineKeyDatabaseField string `gorm:"column:machine_key;unique_index"` MachineKey key.MachinePublic `gorm:"-"` // NodeKeyDatabaseField is the string representation of NodeKey // it is _only_ used for reading and writing the key to the // database and should not be used. // Use NodeKey instead. NodeKeyDatabaseField string `gorm:"column:node_key"` NodeKey key.NodePublic `gorm:"-"` // DiscoKeyDatabaseField is the string representation of DiscoKey // it is _only_ used for reading and writing the key to the // database and should not be used. // Use DiscoKey instead. DiscoKeyDatabaseField string `gorm:"column:disco_key"` DiscoKey key.DiscoPublic `gorm:"-"` // EndpointsDatabaseField is the string list representation of Endpoints // it is _only_ used for reading and writing the key to the // database and should not be used. // Use Endpoints instead. EndpointsDatabaseField StringList `gorm:"column:endpoints"` Endpoints []netip.AddrPort `gorm:"-"` // EndpointsDatabaseField is the string list representation of Endpoints // it is _only_ used for reading and writing the key to the // database and should not be used. // Use Endpoints instead. HostinfoDatabaseField string `gorm:"column:host_info"` Hostinfo *tailcfg.Hostinfo `gorm:"-"` IPAddresses NodeAddresses // Hostname represents the name given by the Tailscale // client during registration Hostname string // Givenname represents either: // a DNS normalized version of Hostname // a valid name set by the User // // GivenName is the name used in all DNS related // parts of headscale. GivenName string `gorm:"type:varchar(63);unique_index"` UserID uint User User `gorm:"foreignKey:UserID"` RegisterMethod string ForcedTags StringList // TODO(kradalby): This seems like irrelevant information? AuthKeyID uint AuthKey *PreAuthKey LastSeen *time.Time Expiry *time.Time Routes []Route CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time IsOnline *bool `gorm:"-"` }
Node is a Headscale client.
func (*Node) AfterFind ¶
AfterFind is a hook that ensures that Node objects fields that has a different type in the database is unwrapped and populated correctly. This currently unmarshals all the keys, stored as strings, into the proper types.
func (*Node) ApplyPeerChange ¶
func (node *Node) ApplyPeerChange(change *tailcfg.PeerChange)
ApplyPeerChange takes a PeerChange struct and updates the node.
func (*Node) BeforeSave ¶
BeforeSave is a hook that ensures that some values that cannot be directly marshalled into database values are stored correctly in the database. This currently means storing the keys as strings.
func (*Node) IsEphemeral ¶
IsEphemeral returns if the node is registered as an Ephemeral node. https://tailscale.com/kb/1111/ephemeral-nodes/
func (*Node) PeerChangeFromMapRequest ¶
func (node *Node) PeerChangeFromMapRequest(req tailcfg.MapRequest) tailcfg.PeerChange
PeerChangeFromMapRequest takes a MapRequest and compares it to the node to produce a PeerChange struct that can be used to updated the node and inform peers about smaller changes to the node. When a field is added to this function, remember to also add it to: - node.ApplyPeerChange - logTracePeerChange in poll.go.
type NodeAddresses ¶
func (NodeAddresses) AppendToIPSet ¶
func (na NodeAddresses) AppendToIPSet(build *netipx.IPSetBuilder)
AppendToIPSet adds the individual ips in NodeAddresses to a given netipx.IPSetBuilder.
func (NodeAddresses) Prefixes ¶
func (na NodeAddresses) Prefixes() []netip.Prefix
func (*NodeAddresses) Scan ¶
func (na *NodeAddresses) Scan(destination interface{}) error
func (NodeAddresses) Sort ¶
func (na NodeAddresses) Sort()
func (NodeAddresses) StringSlice ¶
func (na NodeAddresses) StringSlice() []string
type OIDCConfig ¶
type PreAuthKey ¶
type PreAuthKey struct { ID uint64 `gorm:"primary_key"` Key string UserID uint User User Reusable bool Ephemeral bool `gorm:"default:false"` Used bool `gorm:"default:false"` ACLTags []PreAuthKeyACLTag CreatedAt *time.Time Expiration *time.Time }
PreAuthKey describes a pre-authorization key usable in a particular user.
func (*PreAuthKey) Proto ¶
func (key *PreAuthKey) Proto() *v1.PreAuthKey
type PreAuthKeyACLTag ¶
PreAuthKeyACLTag describes an autmatic tag applied to a node when registered with the associated PreAuthKey.
type Route ¶
type Route struct { gorm.Model NodeID uint64 Node Node // TODO(kradalby): change this custom type to netip.Prefix Prefix IPPrefix Advertised bool Enabled bool IsPrimary bool }
func (*Route) IsAnnouncable ¶
func (*Route) IsExitRoute ¶
type Routes ¶
type Routes []Route
type StateUpdate ¶
type StateUpdate struct { // The type of update Type StateUpdateType // ChangeNodes must be set when Type is StatePeerAdded // and StatePeerChanged and contains the full node // object for added nodes. ChangeNodes Nodes // ChangePatches must be set when Type is StatePeerChangedPatch // and contains a populated PeerChange object. ChangePatches []*tailcfg.PeerChange // Removed must be set when Type is StatePeerRemoved and // contain a list of the nodes that has been removed from // the network. Removed []tailcfg.NodeID // DERPMap must be set when Type is StateDERPUpdated and // contain the new DERP Map. DERPMap *tailcfg.DERPMap // Additional message for tracking origin or what being // updated, useful for ambiguous updates like StatePeerChanged. Message string }
StateUpdate is an internal message containing information about a state change that has happened to the network. If type is StateFullUpdate, all fields are ignored.
func (*StateUpdate) Valid ¶
func (su *StateUpdate) Valid() bool
Valid reports if a StateUpdate is correctly filled and panics if the mandatory fields for a type is not filled. Reports true if valid.
type StateUpdateType ¶
type StateUpdateType int
const ( StateFullUpdate StateUpdateType = iota // StatePeerChanged is used for updates that needs // to be calculated with all peers and all policy rules. // This would typically be things that include tags, routes // and similar. StatePeerChanged StatePeerChangedPatch StatePeerRemoved // StateSelfUpdate is used to indicate that the node // has changed in control, and the client needs to be // informed. // The updated node is inside the ChangeNodes field // which should have a length of one. StateSelfUpdate StateDERPUpdated )
type StringList ¶
type StringList []string
func (*StringList) Scan ¶
func (i *StringList) Scan(destination interface{}) error
type TLSConfig ¶
type TLSConfig struct { CertPath string KeyPath string LetsEncrypt LetsEncryptConfig }
func GetTLSConfig ¶
func GetTLSConfig() TLSConfig
type User ¶
User is the way Headscale implements the concept of users in Tailscale
At the end of the day, users in Tailscale are some kind of 'bubbles' or users that contain our machines.