domain

package
v0.0.1-preview2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: BSD-3-Clause Imports: 15 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 {
	Hosts map[string]string `json:"hosts,omitempty"`
	ACLs  []ACL             `json:"acls"`
}

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 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 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) IsAllowedIP

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

func (*Machine) IsAllowedIPPrefix

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

type Machines

type Machines []Machine

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

	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

	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)
	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

	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 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"
)

type User

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

	TailnetRole TailnetRole
	TailnetID   uint64
	Tailnet     Tailnet
}

type Users

type Users []User

Jump to

Keyboard shortcuts

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