domain

package
v0.0.1-preview3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFilterRules

func BuildFilterRules(policy *ACLPolicy, dst *Machine, peers []Machine) []tailcfg.FilterRule

func IsValidPeer

func IsValidPeer(policy *ACLPolicy, src *Machine, dest *Machine) bool

Types

type ACL

type ACL struct {
	Action string   `json:"action"`
	Src    []string `json:"src"`
	Dst    []string `json:"dst"`
}

type ACLPolicy

type ACLPolicy struct {
	Groups map[string][]string `json:"groups,omitempty"`
	Hosts  map[string]string   `json:"hosts,omitempty"`
	ACLs   []ACL               `json:"acls"`
}

type Account

type Account struct {
	ID uint64 `gorm:"primary_key;autoIncrement:false"`

	ExternalID   string
	LoginName    string
	AuthMethodID uint64
}

type AllowIPs

type AllowIPs []netaddr.IPPrefix

func (AllowIPs) GormDBDataType

func (AllowIPs) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (AllowIPs) GormDataType

func (AllowIPs) GormDataType() string

GormDataType gorm common data type

func (*AllowIPs) Scan

func (hi *AllowIPs) Scan(destination interface{}) error

func (AllowIPs) Value

func (hi AllowIPs) Value() (driver.Value, error)

type AuthFilter

type AuthFilter struct {
	ID           uint64 `gorm:"primary_key;autoIncrement:false"`
	Expr         string
	AuthMethodID uint64
	AuthMethod   AuthMethod
	TailnetID    *uint64
	Tailnet      *Tailnet
}

func (*AuthFilter) Evaluate

func (f *AuthFilter) Evaluate(v interface{}) (bool, error)

type AuthFilters

type AuthFilters []AuthFilter

func (AuthFilters) Evaluate

func (fs AuthFilters) Evaluate(v interface{}) []Tailnet

type AuthKey

type AuthKey struct {
	ID        uint64 `gorm:"primary_key;autoIncrement:false"`
	Key       string `gorm:"type:varchar(64);unique_index"`
	Hash      string
	Ephemeral bool
	Tags      Tags

	CreatedAt time.Time
	ExpiresAt *time.Time

	TailnetID uint64
	Tailnet   Tailnet

	UserID uint64
	User   User
}

func CreateAuthKey

func CreateAuthKey(tailnet *Tailnet, user *User, ephemeral bool, tags Tags, expiresAt *time.Time) (string, *AuthKey)

type AuthMethod

type AuthMethod struct {
	ID           uint64 `gorm:"primary_key;autoIncrement:false"`
	Name         string `gorm:"type:varchar(64);unique_index"`
	Type         string
	Issuer       string
	ClientId     string
	ClientSecret string
}

type ControlKeys added in v0.2.0

type ControlKeys struct {
	ControlKey       key.MachinePrivate
	LegacyControlKey key.MachinePrivate
}

type DNSConfig

type DNSConfig struct {
	MagicDNS         bool
	OverrideLocalDNS bool
	Nameservers      []string
	Routes           map[string][]string
}

type Endpoints

type Endpoints []string

func (Endpoints) GormDBDataType

func (Endpoints) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (Endpoints) GormDataType

func (Endpoints) GormDataType() string

GormDataType gorm common data type

func (*Endpoints) Scan

func (hi *Endpoints) Scan(destination interface{}) error

func (Endpoints) Value

func (hi Endpoints) Value() (driver.Value, error)

type HostInfo

type HostInfo tailcfg.Hostinfo

func (HostInfo) GormDBDataType

func (HostInfo) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (HostInfo) GormDataType

func (HostInfo) GormDataType() string

GormDataType gorm common data type

func (*HostInfo) Scan

func (hi *HostInfo) Scan(destination interface{}) error

func (HostInfo) Value

func (hi HostInfo) Value() (driver.Value, error)

type IP

type IP struct {
	*netaddr.IP
}

func (*IP) Scan

func (i *IP) Scan(destination interface{}) error

func (IP) Value

func (i IP) Value() (driver.Value, error)

type Machine

type Machine struct {
	ID             uint64 `gorm:"primary_key;autoIncrement:false"`
	Name           string
	NameIdx        uint64
	MachineKey     string
	NodeKey        string
	DiscoKey       string
	Ephemeral      bool
	RegisteredTags Tags
	Tags           Tags

	HostInfo  HostInfo
	Endpoints Endpoints
	AllowIPs  AllowIPs

	IPv4 IP
	IPv6 IP

	CreatedAt time.Time
	ExpiresAt *time.Time
	LastSeen  *time.Time

	UserID uint64
	User   User

	TailnetID uint64
	Tailnet   Tailnet
}

func (*Machine) HasIP

func (m *Machine) HasIP(v netaddr.IP) bool

func (*Machine) HasTag

func (m *Machine) HasTag(tag string) bool

func (*Machine) HasTags

func (m *Machine) HasTags() bool

func (*Machine) HasUser

func (m *Machine) HasUser(loginName string) bool

func (*Machine) IsAllowedIP

func (m *Machine) IsAllowedIP(i netaddr.IP) bool

func (*Machine) IsAllowedIPPrefix

func (m *Machine) IsAllowedIPPrefix(i netaddr.IPPrefix) bool

func (*Machine) IsExpired

func (m *Machine) IsExpired() bool

type Machines

type Machines []Machine

type RegistrationRequest

type RegistrationRequest struct {
	MachineKey    string `gorm:"primary_key;autoIncrement:false"`
	Key           string `gorm:"type:varchar(64);unique_index"`
	Data          RegistrationRequestData
	CreatedAt     time.Time
	Authenticated bool
	Error         string
}

func (*RegistrationRequest) IsFinished

func (r *RegistrationRequest) IsFinished() bool

type RegistrationRequestData

type RegistrationRequestData tailcfg.RegisterRequest

func (RegistrationRequestData) GormDBDataType

func (RegistrationRequestData) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (RegistrationRequestData) GormDataType

func (RegistrationRequestData) GormDataType() string

GormDataType gorm common data type

func (*RegistrationRequestData) Scan

func (hi *RegistrationRequestData) Scan(destination interface{}) error

func (RegistrationRequestData) Value

func (hi RegistrationRequestData) Value() (driver.Value, error)

type Repository

type Repository interface {
	GetControlKeys(ctx context.Context) (*ControlKeys, error)
	SetControlKeys(ctx context.Context, v *ControlKeys) error

	GetDERPMap(ctx context.Context) (*tailcfg.DERPMap, error)
	SetDERPMap(ctx context.Context, v *tailcfg.DERPMap) error

	SaveAuthMethod(ctx context.Context, m *AuthMethod) error
	ListAuthMethods(ctx context.Context) ([]AuthMethod, error)
	GetAuthMethod(ctx context.Context, id uint64) (*AuthMethod, error)

	GetAuthFilter(ctx context.Context, id uint64) (*AuthFilter, error)
	SaveAuthFilter(ctx context.Context, m *AuthFilter) error
	ListAuthFilters(ctx context.Context) (AuthFilters, error)
	ListAuthFiltersByAuthMethod(ctx context.Context, authMethodID uint64) (AuthFilters, error)
	DeleteAuthFilter(ctx context.Context, id uint64) error
	DeleteAuthFiltersByTailnet(ctx context.Context, tailnetID uint64) error

	GetAccount(ctx context.Context, accountID uint64) (*Account, error)
	GetOrCreateAccount(ctx context.Context, authMethodID uint64, externalID, loginName string) (*Account, bool, error)

	GetOrCreateTailnet(ctx context.Context, name string) (*Tailnet, bool, error)
	GetTailnet(ctx context.Context, id uint64) (*Tailnet, error)
	ListTailnets(ctx context.Context) ([]Tailnet, error)
	DeleteTailnet(ctx context.Context, id uint64) error

	GetDNSConfig(ctx context.Context, tailnetID uint64) (*DNSConfig, error)
	SetDNSConfig(ctx context.Context, tailnetID uint64, config *DNSConfig) error
	DeleteDNSConfig(ctx context.Context, tailnetID uint64) error
	GetACLPolicy(ctx context.Context, tailnetID uint64) (*ACLPolicy, error)
	SetACLPolicy(ctx context.Context, tailnetID uint64, policy *ACLPolicy) error
	DeleteACLPolicy(ctx context.Context, tailnetID uint64) error

	GetAuthKey(ctx context.Context, id uint64) (*AuthKey, error)
	SaveAuthKey(ctx context.Context, key *AuthKey) error
	DeleteAuthKey(ctx context.Context, id uint64) (bool, error)
	DeleteAuthKeysByTailnet(ctx context.Context, tailnetID uint64) error
	ListAuthKeys(ctx context.Context, tailnetID uint64) ([]AuthKey, error)
	LoadAuthKey(ctx context.Context, key string) (*AuthKey, error)

	GetOrCreateServiceUser(ctx context.Context, tailnet *Tailnet) (*User, bool, error)
	ListUsers(ctx context.Context, tailnetID uint64) (Users, error)
	GetOrCreateUserWithAccount(ctx context.Context, tailnet *Tailnet, account *Account) (*User, bool, error)
	DeleteUsersByTailnet(ctx context.Context, tailnetID uint64) error

	SaveMachine(ctx context.Context, m *Machine) error
	DeleteMachine(ctx context.Context, id uint64) (bool, error)
	GetMachine(ctx context.Context, id uint64) (*Machine, error)
	GetMachineByKey(ctx context.Context, tailnetID uint64, key string) (*Machine, error)
	GetMachineByKeys(ctx context.Context, machineKey string, nodeKey string) (*Machine, error)
	CountMachinesWithIPv4(ctx context.Context, ip string) (int64, error)
	GetNextMachineNameIndex(ctx context.Context, tailnetID uint64, name string) (uint64, error)
	ListMachineByTailnet(ctx context.Context, tailnetID uint64) (Machines, error)
	CountMachineByTailnet(ctx context.Context, tailnetID uint64) (int64, error)
	DeleteMachineByTailnet(ctx context.Context, tailnetID uint64) error
	ListMachinePeers(ctx context.Context, tailnetID uint64, key string) (Machines, error)
	ListInactiveEphemeralMachines(ctx context.Context, checkpoint time.Time) (Machines, error)
	SetMachineLastSeen(ctx context.Context, machineID uint64) error
	ExpireMachineByAuthMethod(ctx context.Context, authMethodID uint64) (int64, error)

	SaveRegistrationRequest(ctx context.Context, request *RegistrationRequest) error
	GetRegistrationRequestByKey(ctx context.Context, key string) (*RegistrationRequest, error)
	GetRegistrationRequestByMachineKey(ctx context.Context, key string) (*RegistrationRequest, error)

	Transaction(func(rp Repository) error) error
}

func NewRepository

func NewRepository(db *gorm.DB) Repository

type ServerConfig

type ServerConfig struct {
	Key   configKey `gorm:"primary_key"`
	Value []byte
}

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

func (*StringSet) Add

func (s *StringSet) Add(t ...string) *StringSet

func (*StringSet) Items

func (s *StringSet) Items() []string

type Tags

type Tags []string

func SanitizeTags

func SanitizeTags(input []string) Tags

func (*Tags) Scan

func (i *Tags) Scan(destination interface{}) error

func (Tags) Value

func (i Tags) Value() (driver.Value, error)

type Tailnet

type Tailnet struct {
	ID   uint64 `gorm:"primary_key;autoIncrement:false"`
	Name string `gorm:"type:varchar(64);unique_index"`
}

type TailnetConfig

type TailnetConfig struct {
	Key       string `gorm:"primary_key"`
	TailnetID uint64 `gorm:"primary_key;autoIncrement:false"`
	Value     []byte
}

type TailnetRole

type TailnetRole string
const (
	TailnetRoleService TailnetRole = "service"
	TailnetRoleMember  TailnetRole = "member"
)

type User

type User struct {
	ID   uint64 `gorm:"primary_key;autoIncrement:false"`
	Name string

	TailnetRole TailnetRole
	TailnetID   uint64
	Tailnet     Tailnet

	AccountID *uint64
	Account   *Account
}

type Users

type Users []User

Jump to

Keyboard shortcuts

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