Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func AbsolutePathFromConfigPath(path string) string
- func CheckForFQDNRules(name string) error
- func DiscoPublicKeyEnsurePrefix(discoKey string) string
- func DiscoPublicKeyStripPrefix(discoKey key.DiscoPublic) string
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomStringDNSSafe(size int) (string, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GetDERPMap(cfg DERPConfig) *tailcfg.DERPMap
- func GetDNSConfig() (*tailcfg.DNSConfig, string)
- func GetFileMode(key string) fs.FileMode
- func GetIPPrefixEndpoints(na netip.Prefix) (netip.Addr, netip.Addr)
- func GrpcSocketDialer(ctx context.Context, addr string) (net.Conn, error)
- func IsCLIConfigured() bool
- func IsStringInSlice(slice []string, str string) bool
- func LoadConfig(path string, isFile bool) error
- func MachinePublicKeyEnsurePrefix(machineKey string) string
- func MachinePublicKeyStripPrefix(machineKey key.MachinePublic) string
- func NodePublicKeyEnsurePrefix(nodeKey string) string
- func NodePublicKeyStripPrefix(nodeKey key.NodePublic) string
- func NormalizeToFQDNRules(name string, stripEmailDomain bool) (string, error)
- func PrivateKeyEnsurePrefix(privateKey string) string
- func SwaggerAPIv1(writer http.ResponseWriter, req *http.Request)
- func SwaggerUI(writer http.ResponseWriter, req *http.Request)
- type ACL
- type ACLConfig
- type ACLPolicy
- type ACLTest
- type APIKey
- type AppleMobileConfig
- type AppleMobilePlatformConfig
- type AutoApprovers
- type CLIConfig
- type Config
- type DERPConfig
- type DERPServer
- type Error
- type Groups
- type Headscale
- func (h *Headscale) AppleConfigMessage(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) ApplePlatformConfig(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) CreateAPIKey(expiration *time.Time) (string, *APIKey, error)
- func (h *Headscale) CreateNamespace(name string) (*Namespace, error)
- func (h *Headscale) CreatePreAuthKey(namespaceName string, reusable bool, ephemeral bool, expiration *time.Time, ...) (*PreAuthKey, error)
- func (h *Headscale) DERPBootstrapDNSHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) DERPHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) DERPProbeHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) DeleteMachine(machine *Machine) error
- func (h *Headscale) DestroyAPIKey(key APIKey) error
- func (h *Headscale) DestroyNamespace(name string) error
- func (h *Headscale) DestroyPreAuthKey(pak PreAuthKey) error
- func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine)
- func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr string) errordeprecated
- func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error
- func (h *Headscale) ExpireAPIKey(key *APIKey) error
- func (h *Headscale) ExpireMachine(machine *Machine) error
- func (h *Headscale) ExpirePreAuthKey(k *PreAuthKey) error
- func (h *Headscale) GenerateGivenName(machineKey string, suppliedName string) (string, error)
- func (h *Headscale) GetAPIKey(prefix string) (*APIKey, error)
- func (h *Headscale) GetAPIKeyByID(id uint64) (*APIKey, error)
- func (h *Headscale) GetAdvertisedNodeRoutes(namespace string, nodeName string) (*[]netip.Prefix, error)deprecated
- func (h *Headscale) GetEnabledNodeRoutes(namespace string, nodeName string) ([]netip.Prefix, error)deprecated
- func (h *Headscale) GetMachine(namespace string, name string) (*Machine, error)
- func (h *Headscale) GetMachineByAnyNodeKey(nodeKey key.NodePublic, oldNodeKey key.NodePublic) (*Machine, error)
- func (h *Headscale) GetMachineByGivenName(namespace string, givenName string) (*Machine, error)
- func (h *Headscale) GetMachineByID(id uint64) (*Machine, error)
- func (h *Headscale) GetMachineByMachineKey(machineKey key.MachinePublic) (*Machine, error)
- func (h *Headscale) GetMachineByNodeKey(nodeKey key.NodePublic) (*Machine, error)
- func (h *Headscale) GetNamespace(name string) (*Namespace, error)
- func (h *Headscale) GetPreAuthKey(namespace string, key string) (*PreAuthKey, error)
- func (h *Headscale) HardDeleteMachine(machine *Machine) error
- func (h *Headscale) HealthHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) IsNodeRouteEnabled(namespace string, nodeName string, routeStr string) booldeprecated
- func (h *Headscale) KeyHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) ListAPIKeys() ([]APIKey, error)
- func (h *Headscale) ListMachines() ([]Machine, error)
- func (h *Headscale) ListMachinesByGivenName(givenName string) ([]Machine, error)
- func (h *Headscale) ListMachinesInNamespace(name string) ([]Machine, error)
- func (h *Headscale) ListNamespaces() ([]Namespace, error)
- func (h *Headscale) ListPeers(machine *Machine) (Machines, error)
- func (h *Headscale) ListPreAuthKeys(namespaceName string) ([]PreAuthKey, error)
- func (h *Headscale) LoadACLPolicy(path string) error
- func (h *Headscale) NewDERPServer() (*DERPServer, error)
- func (h *Headscale) NoisePollNetMapHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) NoiseRegistrationHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) NoiseUpgradeHandler(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) OIDCCallback(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) RefreshMachine(machine *Machine, expiry time.Time) error
- func (h *Headscale) RegisterMachine(machine Machine) (*Machine, error)
- func (h *Headscale) RegisterMachineFromAuthCallback(nodeKeyStr string, namespaceName string, registrationMethod string) (*Machine, error)
- func (h *Headscale) RegisterOIDC(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) RegisterWebAPI(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) RenameMachine(machine *Machine, newName string) error
- func (h *Headscale) RenameNamespace(oldName, newName string) error
- func (h *Headscale) Serve() error
- func (h *Headscale) ServeSTUN()
- func (h *Headscale) SetMachineNamespace(machine *Machine, namespaceName string) error
- func (h *Headscale) SetTags(machine *Machine, tags []string) error
- func (h *Headscale) TouchMachine(machine *Machine) error
- func (h *Headscale) UpdateACLRules() error
- func (h *Headscale) UpdateMachineFromDatabase(machine *Machine) error
- func (h *Headscale) UsePreAuthKey(k *PreAuthKey) error
- func (h *Headscale) ValidateAPIKey(keyStr string) (bool, error)
- func (h *Headscale) WindowsConfigMessage(writer http.ResponseWriter, req *http.Request)
- func (h *Headscale) WindowsRegConfig(writer http.ResponseWriter, req *http.Request)
- type HostInfo
- type Hosts
- type IDTokenClaims
- type IPPrefixes
- type KV
- type LetsEncryptConfig
- type LogConfig
- type LogTailConfig
- type Machine
- func (machine *Machine) GetAdvertisedRoutes() []netip.Prefix
- func (machine *Machine) GetEnabledRoutes() []netip.Prefix
- func (machine *Machine) GetHostInfo() tailcfg.Hostinfo
- func (machine *Machine) IsRoutesEnabled(routeStr string) bool
- func (machine *Machine) RoutesToProto() *v1.Routes
- func (machine Machine) String() string
- type MachineAddresses
- type Machines
- type MachinesP
- type Namespace
- type OIDCConfig
- type PreAuthKey
- type PreAuthKeyACLTag
- type StringList
- type TLSConfig
- type TagOwners
- type WindowsRegistryConfig
Constants ¶
const ( Base8 = 8 Base10 = 10 BitSize16 = 16 BitSize32 = 32 BitSize64 = 64 )
const ( RegisterMethodAuthKey = "authkey" RegisterMethodOIDC = "oidc" RegisterMethodCLI = "cli" ErrRegisterMethodCLIDoesNotSupportExpire = Error( "machines registered with CLI does not support expire", ) )
const ( AuthPrefix = "Bearer " Postgres = "postgres" Sqlite = "sqlite3" HTTPReadTimeout = 30 * time.Second HTTPShutdownTimeout = 3 * time.Second DisabledClientAuth = "disabled" RelaxedClientAuth = "relaxed" EnforcedClientAuth = "enforced" )
const ( JSONLogFormat = "json" TextLogFormat = "text" )
const ( ErrMachineNotFound = Error("machine not found") ErrMachineRouteIsNotAvailable = Error("route is not available on machine") ErrMachineAddressesInvalid = Error("failed to parse machine addresses") ErrMachineNotFoundRegistrationCache = Error( "machine not found in registration cache", ) ErrCouldNotConvertMachineInterface = Error("failed to convert machine interface") ErrHostnameTooLong = Error("Hostname too long") ErrDifferentRegisteredNamespace = Error( "machine was previously registered with a different namespace", ) MachineGivenNameHashLength = 8 MachineGivenNameTrimSize = 2 )
const ( ErrNamespaceExists = Error("Namespace already exists") ErrNamespaceNotFound = Error("Namespace not found") ErrNamespaceNotEmptyOfNodes = Error("Namespace not empty: node(s) found") ErrInvalidNamespaceName = Error("Invalid namespace name") )
const ( ErrPreAuthKeyNotFound = Error("AuthKey not found") ErrPreAuthKeyExpired = Error("AuthKey expired") ErrSingleUseAuthKeyHasBeenUsed = Error("AuthKey has already been used") ErrNamespaceMismatch = Error("namespace mismatch") ErrPreAuthKeyACLTagInvalid = Error("AuthKey tag is invalid") )
const ( ErrCannotDecryptResponse = Error("cannot decrypt response") ErrCouldNotAllocateIP = Error("could not find any suitable IP") PermissionFallback = 0o700 ZstdCompression = "zstd" )
const (
ByteSize = 8
)
const (
ErrAPIKeyFailedToParse = Error("Failed to parse ApiKey")
)
const (
ErrRouteIsNotAvailable = Error("route is not available")
)
const ( // The CapabilityVersion is used by Tailscale clients to indicate // their codebase version. Tailscale clients can communicate over TS2021 // from CapabilityVersion 28, but we only have good support for it // since https://github.com/tailscale/tailscale/pull/4323 (Noise in any HTTPS port). // // Related to this change, there is https://github.com/tailscale/tailscale/pull/5379, // where CapabilityVersion 39 is introduced to indicate #4323 was merged. // // See also https://github.com/tailscale/tailscale/blob/main/tailcfg/tailcfg.go NoiseCapabilityVersion = 39 )
const (
ProtocolFC = 133 // Fibre Channel
)
For some reason golang.org/x/net/internal/iana is an internal package.
Variables ¶
var ( ExitRouteV4 = netip.MustParsePrefix("0.0.0.0/0") ExitRouteV6 = netip.MustParsePrefix("::/0") )
var NodePublicKeyRegex = regexp.MustCompile("nodekey:[a-fA-F0-9]+")
Functions ¶
func AbsolutePathFromConfigPath ¶ added in v0.16.0
func CheckForFQDNRules ¶ added in v0.15.0
func DiscoPublicKeyEnsurePrefix ¶ added in v0.12.1
func DiscoPublicKeyStripPrefix ¶ added in v0.12.1
func DiscoPublicKeyStripPrefix(discoKey key.DiscoPublic) string
func GenerateRandomBytes ¶ added in v0.13.0
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringDNSSafe ¶ added in v0.16.0
GenerateRandomStringDNSSafe returns a DNS-safe securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringURLSafe ¶ added in v0.13.0
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GetDERPMap ¶ added in v0.11.0
func GetDERPMap(cfg DERPConfig) *tailcfg.DERPMap
func GetDNSConfig ¶ added in v0.16.0
func GetFileMode ¶ added in v0.16.0
func GetIPPrefixEndpoints ¶ added in v0.13.0
func GrpcSocketDialer ¶ added in v0.12.1
func IsCLIConfigured ¶ added in v0.17.0
func IsCLIConfigured() bool
func IsStringInSlice ¶ added in v0.16.0
func LoadConfig ¶ added in v0.16.0
func MachinePublicKeyEnsurePrefix ¶ added in v0.12.1
func MachinePublicKeyStripPrefix ¶ added in v0.12.1
func MachinePublicKeyStripPrefix(machineKey key.MachinePublic) string
func NodePublicKeyEnsurePrefix ¶ added in v0.12.1
func NodePublicKeyStripPrefix ¶ added in v0.12.1
func NodePublicKeyStripPrefix(nodeKey key.NodePublic) string
func NormalizeToFQDNRules ¶ added in v0.15.0
NormalizeToFQDNRules will replace forbidden chars in namespace it can also return an error if the namespace doesn't respect RFC 952 and 1123.
func PrivateKeyEnsurePrefix ¶ added in v0.12.1
func SwaggerAPIv1 ¶ added in v0.12.1
func SwaggerAPIv1( writer http.ResponseWriter, req *http.Request, )
Types ¶
type ACL ¶ added in v0.3.0
type ACL struct { Action string `json:"action" yaml:"action"` Protocol string `json:"proto" yaml:"proto"` Sources []string `json:"src" yaml:"src"` Destinations []string `json:"dst" yaml:"dst"` }
ACL is a basic rule for the ACL Policy.
type ACLConfig ¶ added in v0.16.0
type ACLConfig struct {
PolicyPath string
}
func GetACLConfig ¶ added in v0.16.0
func GetACLConfig() ACLConfig
type ACLPolicy ¶ added in v0.3.0
type ACLPolicy struct { Groups Groups `json:"groups" yaml:"groups"` Hosts Hosts `json:"hosts" yaml:"hosts"` TagOwners TagOwners `json:"tagOwners" yaml:"tagOwners"` ACLs []ACL `json:"acls" yaml:"acls"` Tests []ACLTest `json:"tests" yaml:"tests"` AutoApprovers AutoApprovers `json:"autoApprovers" yaml:"autoApprovers"` }
ACLPolicy represents a Tailscale ACL Policy.
type ACLTest ¶ added in v0.3.0
type ACLTest struct { Source string `json:"src" yaml:"src"` Accept []string `json:"accept" yaml:"accept"` Deny []string `json:"deny,omitempty" yaml:"deny,omitempty"` }
ACLTest is not implemented, but should be use to check if a certain rule is allowed.
type APIKey ¶ added in v0.13.0
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 AppleMobileConfig ¶ added in v0.9.2
type AppleMobilePlatformConfig ¶ added in v0.9.2
type AutoApprovers ¶ added in v0.17.0
type AutoApprovers struct { Routes map[string][]string `json:"routes" yaml:"routes"` ExitNode []string `json:"exitNode" yaml:"exitNode"` }
AutoApprovers specify which users (namespaces?), groups or tags have their advertised routes or exit node status automatically enabled.
func (*AutoApprovers) GetRouteApprovers ¶ added in v0.17.0
func (autoApprovers *AutoApprovers) GetRouteApprovers( prefix netip.Prefix, ) ([]string, error)
Returns the list of autoApproving namespaces, groups or tags for a given IPPrefix.
type Config ¶
type Config struct { ServerURL string Addr string MetricsAddr string GRPCAddr string GRPCAllowInsecure bool EphemeralNodeInactivityTimeout time.Duration NodeUpdateCheckInterval time.Duration IPPrefixes []netip.Prefix PrivateKeyPath string 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 ¶ added in v0.16.0
type DERPConfig ¶ added in v0.11.0
type DERPConfig struct { ServerEnabled bool ServerRegionID int ServerRegionCode string ServerRegionName string STUNAddr string URLs []url.URL Paths []string AutoUpdate bool UpdateFrequency time.Duration }
func GetDERPConfig ¶ added in v0.16.0
func GetDERPConfig() DERPConfig
type DERPServer ¶ added in v0.15.0
type DERPServer struct {
// contains filtered or unexported fields
}
type Error ¶
type Error string
Error is used to compare errors as per https://dave.cheney.net/2016/04/07/constant-errors
type Headscale ¶
type Headscale struct { DERPMap *tailcfg.DERPMap DERPServer *DERPServer // contains filtered or unexported fields }
Headscale represents the base app of the service.
func NewHeadscale ¶
func (*Headscale) AppleConfigMessage ¶ added in v0.15.0
func (h *Headscale) AppleConfigMessage( writer http.ResponseWriter, req *http.Request, )
AppleConfigMessage shows a simple message in the browser to point the user to the iOS/MacOS profile and instructions for how to install it.
func (*Headscale) ApplePlatformConfig ¶ added in v0.9.2
func (h *Headscale) ApplePlatformConfig( writer http.ResponseWriter, req *http.Request, )
func (*Headscale) CreateAPIKey ¶ added in v0.13.0
CreateAPIKey creates a new ApiKey in a namespace, and returns it.
func (*Headscale) CreateNamespace ¶
CreateNamespace creates a new Namespace. Returns error if could not be created or another namespace already exists.
func (*Headscale) CreatePreAuthKey ¶
func (h *Headscale) CreatePreAuthKey( namespaceName string, reusable bool, ephemeral bool, expiration *time.Time, aclTags []string, ) (*PreAuthKey, error)
CreatePreAuthKey creates a new PreAuthKey in a namespace, and returns it.
func (*Headscale) DERPBootstrapDNSHandler ¶ added in v0.15.0
func (h *Headscale) DERPBootstrapDNSHandler( writer http.ResponseWriter, req *http.Request, )
DERPBootstrapDNSHandler implements the /bootsrap-dns endpoint Described in https://github.com/tailscale/tailscale/issues/1405, this endpoint provides a way to help a client when it fails to start up because its DNS are broken. The initial implementation is here https://github.com/tailscale/tailscale/pull/1406 They have a cache, but not clear if that is really necessary at Headscale, uh, scale. An example implementation is found here https://derp.tailscale.com/bootstrap-dns
func (*Headscale) DERPHandler ¶ added in v0.15.0
func (h *Headscale) DERPHandler( writer http.ResponseWriter, req *http.Request, )
func (*Headscale) DERPProbeHandler ¶ added in v0.15.0
func (h *Headscale) DERPProbeHandler( writer http.ResponseWriter, req *http.Request, )
DERPProbeHandler is the endpoint that js/wasm clients hit to measure DERP latency, since they can't do UDP STUN queries.
func (*Headscale) DeleteMachine ¶ added in v0.6.1
DeleteMachine softs deletes a Machine from the database.
func (*Headscale) DestroyAPIKey ¶ added in v0.13.0
DestroyAPIKey destroys a ApiKey. Returns error if the ApiKey does not exist.
func (*Headscale) DestroyNamespace ¶
DestroyNamespace destroys a Namespace. Returns error if the Namespace does not exist or if there are machines associated with it.
func (*Headscale) DestroyPreAuthKey ¶ added in v0.12.1
func (h *Headscale) DestroyPreAuthKey(pak PreAuthKey) error
DestroyPreAuthKey destroys a preauthkey. Returns error if the PreAuthKey does not exist.
func (*Headscale) EnableAutoApprovedRoutes ¶ added in v0.17.0
Enabled any routes advertised by a machine that match the ACL autoApprovers policy.
func (*Headscale) EnableRoutes ¶ added in v0.12.1
EnableNodeRoute enables new routes based on a list of new routes. It will _replace_ the previous list of routes.
func (*Headscale) ExpireAPIKey ¶ added in v0.13.0
ExpireAPIKey marks a ApiKey as expired.
func (*Headscale) ExpireMachine ¶ added in v0.12.1
ExpireMachine takes a Machine struct and sets the expire field to now.
func (*Headscale) ExpirePreAuthKey ¶ added in v0.12.1
func (h *Headscale) ExpirePreAuthKey(k *PreAuthKey) error
MarkExpirePreAuthKey marks a PreAuthKey as expired.
func (*Headscale) GenerateGivenName ¶ added in v0.16.0
func (*Headscale) GetAPIKeyByID ¶ added in v0.13.0
GetAPIKeyByID returns a ApiKey for a given id.
func (*Headscale) GetAdvertisedNodeRoutes
deprecated
added in
v0.7.0
func (*Headscale) GetEnabledNodeRoutes
deprecated
added in
v0.7.0
func (*Headscale) GetMachine ¶
GetMachine finds a Machine by name and namespace and returns the Machine struct.
func (*Headscale) GetMachineByAnyNodeKey ¶ added in v0.17.0
func (h *Headscale) GetMachineByAnyNodeKey( nodeKey key.NodePublic, oldNodeKey key.NodePublic, ) (*Machine, error)
GetMachineByAnyNodeKey finds a Machine by its current NodeKey or the old one, and returns the Machine struct.
func (*Headscale) GetMachineByGivenName ¶ added in v0.17.0
GetMachineByGivenName finds a Machine by given name and namespace and returns the Machine struct.
func (*Headscale) GetMachineByID ¶ added in v0.6.1
GetMachineByID finds a Machine by ID and returns the Machine struct.
func (*Headscale) GetMachineByMachineKey ¶ added in v0.9.3
func (h *Headscale) GetMachineByMachineKey( machineKey key.MachinePublic, ) (*Machine, error)
GetMachineByMachineKey finds a Machine by its MachineKey and returns the Machine struct.
func (*Headscale) GetMachineByNodeKey ¶ added in v0.16.1
func (h *Headscale) GetMachineByNodeKey( nodeKey key.NodePublic, ) (*Machine, error)
GetMachineByNodeKey finds a Machine by its current NodeKey.
func (*Headscale) GetNamespace ¶
GetNamespace fetches a namespace by name.
func (*Headscale) GetPreAuthKey ¶ added in v0.6.1
func (h *Headscale) GetPreAuthKey(namespace string, key string) (*PreAuthKey, error)
GetPreAuthKey returns a PreAuthKey for a given key.
func (*Headscale) HardDeleteMachine ¶ added in v0.6.1
HardDeleteMachine hard deletes a Machine from the database.
func (*Headscale) HealthHandler ¶ added in v0.16.1
func (h *Headscale) HealthHandler( writer http.ResponseWriter, req *http.Request, )
func (*Headscale) KeyHandler ¶
func (h *Headscale) KeyHandler( writer http.ResponseWriter, req *http.Request, )
KeyHandler provides the Headscale pub key Listens in /key.
func (*Headscale) ListAPIKeys ¶ added in v0.13.0
ListAPIKeys returns the list of ApiKeys for a namespace.
func (*Headscale) ListMachines ¶ added in v0.12.1
func (*Headscale) ListMachinesByGivenName ¶ added in v0.17.0
func (*Headscale) ListMachinesInNamespace ¶
ListMachinesInNamespace gets all the nodes in a given namespace.
func (*Headscale) ListNamespaces ¶
ListNamespaces gets all the existing namespaces.
func (*Headscale) ListPreAuthKeys ¶ added in v0.12.1
func (h *Headscale) ListPreAuthKeys(namespaceName string) ([]PreAuthKey, error)
ListPreAuthKeys returns the list of PreAuthKeys for a namespace.
func (*Headscale) LoadACLPolicy ¶ added in v0.3.0
LoadACLPolicy loads the ACL policy from the specify path, and generates the ACL rules.
func (*Headscale) NewDERPServer ¶ added in v0.15.0
func (h *Headscale) NewDERPServer() (*DERPServer, error)
func (*Headscale) NoisePollNetMapHandler ¶ added in v0.17.0
func (h *Headscale) NoisePollNetMapHandler( writer http.ResponseWriter, req *http.Request, )
NoisePollNetMapHandler takes care of /machine/:id/map using the Noise protocol
This is the busiest endpoint, as it keeps the HTTP long poll that updates the clients when something in the network changes.
The clients POST stuff like HostInfo and their Endpoints here, but only after their first request (marked with the ReadOnly field).
At this moment the updates are sent in a quite horrendous way, but they kinda work.
func (*Headscale) NoiseRegistrationHandler ¶ added in v0.17.0
func (h *Headscale) NoiseRegistrationHandler( writer http.ResponseWriter, req *http.Request, )
// NoiseRegistrationHandler handles the actual registration process of a machine.
func (*Headscale) NoiseUpgradeHandler ¶ added in v0.17.0
func (h *Headscale) NoiseUpgradeHandler( writer http.ResponseWriter, req *http.Request, )
NoiseUpgradeHandler is to upgrade the connection and hijack the net.Conn in order to use the Noise-based TS2021 protocol. Listens in /ts2021.
func (*Headscale) OIDCCallback ¶ added in v0.12.1
func (h *Headscale) OIDCCallback( writer http.ResponseWriter, req *http.Request, )
OIDCCallback handles the callback from the OIDC endpoint Retrieves the nkey from the state cache and adds the machine to the users email namespace TODO: A confirmation page for new machines should be added to avoid phishing vulnerabilities TODO: Add groups information from OIDC tokens into machine HostInfo Listens in /oidc/callback.
func (*Headscale) RefreshMachine ¶ added in v0.12.1
RefreshMachine takes a Machine struct and sets the expire field to now.
func (*Headscale) RegisterMachine ¶
RegisterMachine is executed from the CLI to register a new Machine using its MachineKey.
func (*Headscale) RegisterMachineFromAuthCallback ¶ added in v0.15.0
func (*Headscale) RegisterOIDC ¶ added in v0.12.1
func (h *Headscale) RegisterOIDC( writer http.ResponseWriter, req *http.Request, )
RegisterOIDC redirects to the OIDC provider for authentication Puts NodeKey in cache so the callback can retrieve it using the oidc state param Listens in /oidc/register/:nKey.
func (*Headscale) RegisterWebAPI ¶
func (h *Headscale) RegisterWebAPI( writer http.ResponseWriter, req *http.Request, )
RegisterWebAPI shows a simple message in the browser to point to the CLI Listens in /register/:nkey.
This is not part of the Tailscale control API, as we could send whatever URL in the RegisterResponse.AuthURL field.
func (*Headscale) RenameMachine ¶ added in v0.16.0
RenameMachine takes a Machine struct and a new GivenName for the machines and renames it.
func (*Headscale) RenameNamespace ¶ added in v0.10.4
RenameNamespace renames a Namespace. Returns error if the Namespace does not exist or if another Namespace exists with the new name.
func (*Headscale) ServeSTUN ¶ added in v0.15.0
func (h *Headscale) ServeSTUN()
ServeSTUN starts a STUN server on the configured addr.
func (*Headscale) SetMachineNamespace ¶
SetMachineNamespace assigns a Machine to a namespace.
func (*Headscale) SetTags ¶ added in v0.16.0
SetTags takes a Machine struct pointer and update the forced tags.
func (*Headscale) TouchMachine ¶ added in v0.12.4
func (*Headscale) UpdateACLRules ¶ added in v0.14.0
func (*Headscale) UpdateMachineFromDatabase ¶ added in v0.16.0
UpdateMachineFromDatabase takes a Machine struct pointer (typically already loaded from database and updates it with the latest data from the database.
func (*Headscale) UsePreAuthKey ¶ added in v0.15.0
func (h *Headscale) UsePreAuthKey(k *PreAuthKey) error
UsePreAuthKey marks a PreAuthKey as used.
func (*Headscale) ValidateAPIKey ¶ added in v0.13.0
func (*Headscale) WindowsConfigMessage ¶ added in v0.15.0
func (h *Headscale) WindowsConfigMessage( writer http.ResponseWriter, req *http.Request, )
WindowsConfigMessage shows a simple message in the browser for how to configure the Windows Tailscale client.
func (*Headscale) WindowsRegConfig ¶ added in v0.15.0
func (h *Headscale) WindowsRegConfig( writer http.ResponseWriter, req *http.Request, )
WindowsRegConfig generates and serves a .reg file configured with the Headscale server address.
type HostInfo ¶ added in v0.15.0
This is a "wrapper" type around tailscales Hostinfo to allow us to add database "serialization" methods. This allows us to use a typed values throughout the code and not have to marshal/unmarshal and error check all over the code.
type Hosts ¶ added in v0.3.0
Hosts are alias for IP addresses or subnets.
func (*Hosts) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON allows to parse the Hosts directly into netip objects.
func (*Hosts) UnmarshalYAML ¶ added in v0.15.0
UnmarshalYAML allows to parse the Hosts directly into netip objects.
type IDTokenClaims ¶ added in v0.12.1
type IPPrefixes ¶ added in v0.15.0
func (*IPPrefixes) Scan ¶ added in v0.15.0
func (i *IPPrefixes) Scan(destination interface{}) error
type LetsEncryptConfig ¶ added in v0.16.0
type LogConfig ¶ added in v0.17.0
func GetLogConfig ¶ added in v0.17.0
func GetLogConfig() LogConfig
type LogTailConfig ¶ added in v0.16.0
type LogTailConfig struct {
Enabled bool
}
func GetLogTailConfig ¶ added in v0.16.0
func GetLogTailConfig() LogTailConfig
type Machine ¶
type Machine struct { ID uint64 `gorm:"primary_key"` MachineKey string `gorm:"type:varchar(64);unique_index"` NodeKey string DiscoKey string IPAddresses MachineAddresses // 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"` NamespaceID uint Namespace Namespace `gorm:"foreignKey:NamespaceID"` RegisterMethod string ForcedTags StringList // TODO(kradalby): This seems like irrelevant information? AuthKeyID uint AuthKey *PreAuthKey LastSeen *time.Time LastSuccessfulUpdate *time.Time Expiry *time.Time HostInfo HostInfo Endpoints StringList EnabledRoutes IPPrefixes CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time }
Machine is a Headscale client.
func (*Machine) GetAdvertisedRoutes ¶ added in v0.12.1
func (*Machine) GetEnabledRoutes ¶ added in v0.12.1
func (*Machine) GetHostInfo ¶
GetHostInfo returns a Hostinfo struct for the machine.
func (*Machine) IsRoutesEnabled ¶ added in v0.12.1
func (*Machine) RoutesToProto ¶ added in v0.12.1
type MachineAddresses ¶ added in v0.13.0
func (*MachineAddresses) Scan ¶ added in v0.13.0
func (ma *MachineAddresses) Scan(destination interface{}) error
func (MachineAddresses) ToStringSlice ¶ added in v0.13.0
func (ma MachineAddresses) ToStringSlice() []string
type Namespace ¶
Namespace 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 namespaces that contain our machines.
type OIDCConfig ¶ added in v0.12.1
type PreAuthKey ¶
type PreAuthKey struct { ID uint64 `gorm:"primary_key"` Key string NamespaceID uint Namespace Namespace 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 namespace.
type PreAuthKeyACLTag ¶ added in v0.17.0
PreAuthKeyACLTag describes an autmatic tag applied to a node when registered with the associated PreAuthKey.
type StringList ¶ added in v0.15.0
type StringList []string
func (*StringList) Scan ¶ added in v0.15.0
func (i *StringList) Scan(destination interface{}) error
type TLSConfig ¶ added in v0.16.0
type TLSConfig struct { CertPath string KeyPath string LetsEncrypt LetsEncryptConfig }
func GetTLSConfig ¶ added in v0.16.0
func GetTLSConfig() TLSConfig
type TagOwners ¶ added in v0.3.0
TagOwners specify what users (namespaces?) are allow to use certain tags.
type WindowsRegistryConfig ¶ added in v0.15.0
type WindowsRegistryConfig struct {
URL string
}
Source Files ¶
- acls.go
- acls_types.go
- api.go
- api_common.go
- api_key.go
- app.go
- config.go
- db.go
- derp.go
- derp_server.go
- dns.go
- grpcv1.go
- handler_placeholder.go
- machine.go
- metrics.go
- namespaces.go
- noise.go
- oidc.go
- platform_config.go
- preauth_keys.go
- protocol_common.go
- protocol_common_poll.go
- protocol_common_utils.go
- protocol_noise.go
- protocol_noise_poll.go
- routes.go
- swagger.go
- utils.go
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gen
|
|
go/headscale/v1
Package v1 is a reverse proxy.
|
Package v1 is a reverse proxy. |