models

package
v0.0.190 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UserSeederRows = 1

Variables

This section is empty.

Functions

func ClearActiveFromAllTunnels

func ClearActiveFromAllTunnels(db *gorm.DB) error

func CountAllActiveTunnels added in v0.0.100

func CountAllActiveTunnels(db *gorm.DB) (int, error)

func CountUsers

func CountUsers(db *gorm.DB) (int, error)

func CountVTunActiveTunnels added in v0.0.100

func CountVTunActiveTunnels(db *gorm.DB) (int, error)

func CountVtunTunnels added in v0.0.100

func CountVtunTunnels(db *gorm.DB) (int, error)

func CountWireguardActiveTunnels added in v0.0.100

func CountWireguardActiveTunnels(db *gorm.DB) (int, error)

func CountWireguardTunnels added in v0.0.100

func CountWireguardTunnels(db *gorm.DB) (int, error)

func DeleteTunnel

func DeleteTunnel(db *gorm.DB, id uint) error

func DeleteUser

func DeleteUser(db *gorm.DB, id uint) error

func GetNextVTunIP added in v0.0.100

func GetNextVTunIP(db *gorm.DB, config *config.Config) (string, error)

func GetNextWireguardIP added in v0.0.100

func GetNextWireguardIP(db *gorm.DB, config *config.Config) (string, error)

func GetNextWireguardPort added in v0.0.100

func GetNextWireguardPort(db *gorm.DB, config *config.Config) (uint16, error)

func TunnelIDExists

func TunnelIDExists(db *gorm.DB, id uint) (bool, error)

func UserExists

func UserExists(db *gorm.DB, user User) (bool, error)

func UserIDExists

func UserIDExists(db *gorm.DB, id uint) (bool, error)

Types

type AppSettings

type AppSettings struct {
	ID        uint `gorm:"primaryKey"`
	HasSeeded bool
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Tunnel

type Tunnel struct {
	ID                 uint           `json:"id" gorm:"primaryKey"`
	Hostname           string         `json:"hostname" binding:"required"`
	IP                 string         `json:"ip" binding:"required"`
	Password           string         `json:"-" binding:"required"`
	Active             bool           `json:"active"`
	Client             bool           `json:"client"`
	TunnelInterface    string         `json:"-"`
	RXBytes            uint64         `json:"rx_bytes"`
	TXBytes            uint64         `json:"tx_bytes"`
	TotalRXMB          float64        `json:"total_rx_mb"`
	TotalTXMB          float64        `json:"total_tx_mb"`
	RXBytesPerSec      uint64         `json:"rx_bytes_per_sec"`
	TXBytesPerSec      uint64         `json:"tx_bytes_per_sec"`
	Wireguard          bool           `json:"wireguard" gorm:"default:false"`
	WireguardServerKey string         `json:"wireguard_server_key"`
	WireguardPort      uint16         `json:"wireguard_port"`
	ConnectionTime     time.Time      `json:"connection_time"`
	CreatedAt          time.Time      `json:"created_at"`
	UpdatedAt          time.Time      `json:"-"`
	DeletedAt          gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindTunnelByID

func FindTunnelByID(db *gorm.DB, id uint) (Tunnel, error)

func FindTunnelByIP

func FindTunnelByIP(db *gorm.DB, ip net.IP) (Tunnel, error)

func FindTunnelByInterface

func FindTunnelByInterface(db *gorm.DB, iface string) (Tunnel, error)

func ListAllTunnels added in v0.0.100

func ListAllTunnels(db *gorm.DB) ([]Tunnel, error)

func ListClientTunnels added in v0.0.30

func ListClientTunnels(db *gorm.DB) ([]Tunnel, error)

func ListServerTunnels added in v0.0.30

func ListServerTunnels(db *gorm.DB) ([]Tunnel, error)

func ListVtunTunnels added in v0.0.100

func ListVtunTunnels(db *gorm.DB) ([]Tunnel, error)

func ListWireguardTunnels added in v0.0.100

func ListWireguardTunnels(db *gorm.DB) ([]Tunnel, error)

type User

type User struct {
	ID        uint           `json:"id" gorm:"primaryKey" binding:"required"`
	Username  string         `json:"username" gorm:"uniqueIndex" binding:"required"`
	Password  string         `json:"-"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindUserByID

func FindUserByID(db *gorm.DB, id uint) (User, error)

func ListUsers

func ListUsers(db *gorm.DB) ([]User, error)

func (User) TableName

func (u User) TableName() string

type UsersSeeder

type UsersSeeder struct {
	gorm_seeder.SeederAbstract
	// contains filtered or unexported fields
}

func NewUsersSeeder

func NewUsersSeeder(cfg gorm_seeder.SeederConfiguration, config *config.Config) UsersSeeder

func (*UsersSeeder) Clear

func (s *UsersSeeder) Clear(db *gorm.DB) error

func (*UsersSeeder) Seed

func (s *UsersSeeder) Seed(db *gorm.DB) error

Jump to

Keyboard shortcuts

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