model

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase(path string, admins map[string]string) (*gorm.DB, error)

Types

type Addr

type Addr netip.Addr

func (*Addr) Scan

func (a *Addr) Scan(value any) error

func (Addr) ToNetip

func (a Addr) ToNetip() netip.Addr

func (Addr) Value

func (a Addr) Value() (driver.Value, error)

type AddrPort

type AddrPort netip.AddrPort

func (*AddrPort) Scan

func (a *AddrPort) Scan(value any) error

func (AddrPort) ToNetip

func (a AddrPort) ToNetip() netip.AddrPort

func (AddrPort) Value

func (a AddrPort) Value() (driver.Value, error)

type Admin

type Admin struct {
	gorm.Model
	Name          string
	PublicKeyHash sql.NullString `gorm:"unique"`
}

type Certificate

type Certificate struct {
	gorm.Model
	Hash           string
	Groups         string
	Address        Addr
	NotAfter       time.Time
	RevokedAfter   time.Time
	RenewableAfter time.Time

	NetworkID uint
	Network   Network

	ClientID uint
	Client   Client
}

type Client

type Client struct {
	gorm.Model
	HardwareAddress string
	PublicKeyHash   sql.NullString `gorm:"unique"`
	CommonName      string
	ClientNetworks  []ClientNetwork
}

type ClientNetwork

type ClientNetwork struct {
	gorm.Model
	Address      Addr
	IsLighthouse bool
	Subnets      Prefixes

	ClientID uint
	Client   Client

	NetworkID uint
	Network   Network
	Groups    string
}

type Lighthouse

type Lighthouse struct {
	gorm.Model
	PublicAddr AddrPort
	NebulaIP   Addr

	NetworkID uint
	Network   Network
}

type Network

type Network struct {
	gorm.Model
	Name   string `gorm:"unique"`
	Prefix Prefix

	ClientNetworks []ClientNetwork
	NetworkGroups  []NetworkGroup
}

func (*Network) FreeIP

func (n *Network) FreeIP() (netip.Addr, error)

func (*Network) IsFree

func (n *Network) IsFree(ip netip.Addr) bool

type NetworkGroup

type NetworkGroup struct {
	gorm.Model
	Name string

	NetworkID uint
	Network   Network
}

type Prefix

type Prefix netip.Prefix

func (*Prefix) Scan

func (p *Prefix) Scan(value any) error

func (Prefix) ToNetip

func (p Prefix) ToNetip() netip.Prefix

func (Prefix) Value

func (p Prefix) Value() (driver.Value, error)

type Prefixes

type Prefixes []Prefix

func (*Prefixes) Scan

func (p *Prefixes) Scan(value any) error

func (Prefixes) ToNetip

func (p Prefixes) ToNetip() []netip.Prefix

func (Prefixes) Value

func (p Prefixes) Value() (driver.Value, error)

type Router

type Router struct {
	gorm.Model
	Subnet   Prefix
	NebulaIP Addr

	NetworkID uint
	Network   Network
}

Jump to

Keyboard shortcuts

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