models

package
v0.0.98 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 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 CountActiveTunnels added in v0.0.44

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

func CountTunnels

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

func CountUsers

func CountUsers(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 GetNextIP

func GetNextIP(db *gorm.DB, config *config.Config) (string, 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"`
	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 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 ListTunnels

func ListTunnels(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