domain

package
v0.0.0-dev Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

	IPv4 string
	IPv6 string

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

	UserID uint64
	User   User

	TailnetID uint64
	Tailnet   Tailnet
}

type Machines

type Machines []Machine

type Repository

type Repository interface {
	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)

	SaveAuthKey(ctx context.Context, key *AuthKey) error
	DeleteAuthKey(ctx context.Context, id uint64) (bool, 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)

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

func NewRepository

func NewRepository(db *gorm.DB) Repository

type ServerConfig

type ServerConfig struct {
	Key   string `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 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