model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const WakeOnLanHostCollectionName = "wake_on_lan_hosts"

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseData

type BaseData struct {
	Active      string
	CurrentUser string
	Admin       bool
	BasePath    string
}

BaseData struct to pass value to the base template

type Client

type Client struct {
	ID               string    `json:"id"`
	PrivateKey       string    `json:"private_key"`
	PublicKey        string    `json:"public_key"`
	PresharedKey     string    `json:"preshared_key"`
	Name             string    `json:"name"`
	TgUserid         string    `json:"telegram_userid"`
	Email            string    `json:"email"`
	SubnetRanges     []string  `json:"subnet_ranges,omitempty"`
	AllocatedIPs     []string  `json:"allocated_ips"`
	AllowedIPs       []string  `json:"allowed_ips"`
	ExtraAllowedIPs  []string  `json:"extra_allowed_ips"`
	Endpoint         string    `json:"endpoint"`
	AdditionalNotes  string    `json:"additional_notes"`
	UseServerDNS     bool      `json:"use_server_dns"`
	Enabled          bool      `json:"enabled"`
	CreatedBy        string    `json:"created_by,omitempty"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
	Quota            int64     `json:"quota,omitempty"`
	UsedQuota        int64     `json:"used_quota,omitempty"`
	Expiration       time.Time `json:"expiration,omitempty"`
	ExpirationDays   int       `json:"expiration_days,omitempty"`
	FirstConnectedAt time.Time `json:"first_connected_at,omitempty"`
	Status           string    `json:"status,omitempty"`
	LastHandshake    time.Time `json:"last_handshake,omitempty"`
	// Persistent storage for usage data
	PersistentUsageData *ClientUsageData `json:"persistent_usage_data,omitempty"`
}

Client model

type ClientData

type ClientData struct {
	Client *Client
	QRCode string
}

ClientData includes the Client and extra data

type ClientDefaults

type ClientDefaults struct {
	AllowedIps          []string
	ExtraAllowedIps     []string
	UseServerDNS        bool
	EnableAfterCreation bool
}

ClientDefaults Defaults for creation of new clients used in the templates

type ClientServerHashes

type ClientServerHashes struct {
	Client string `json:"client"`
	Server string `json:"server"`
}

ClientServerHashes struct, to save hashes to detect changes

type ClientUsageData

type ClientUsageData struct {
	TotalBytesReceived         uint64    `json:"total_bytes_received"`
	TotalBytesSent             uint64    `json:"total_bytes_sent"`
	LastInterfaceBytesReceived uint64    `json:"last_interface_bytes_received"`
	LastInterfaceBytesSent     uint64    `json:"last_interface_bytes_sent"`
	LastSeen                   time.Time `json:"last_seen"`
	FirstSeen                  time.Time `json:"first_seen"`
	UpdatedAt                  time.Time `json:"updated_at"`
}

ClientUsageData stores persistent usage information

type GlobalSetting

type GlobalSetting struct {
	EndpointAddress     string    `json:"endpoint_address"`
	RelayEndpoint       string    `json:"relay_endpoint"`
	DNSServers          []string  `json:"dns_servers"`
	MTU                 int       `json:"mtu,string"`
	PersistentKeepalive int       `json:"persistent_keepalive,string"`
	FirewallMark        string    `json:"firewall_mark"`
	Table               string    `json:"table"`
	ConfigFilePath      string    `json:"config_file_path"`
	AppSecretToken      string    `json:"app_secret_token"`
	UpdatedAt           time.Time `json:"updated_at"`

	// Display settings
	Timezone string `json:"timezone"`
	Language string `json:"language"`
}

GlobalSetting model

type Interface

type Interface struct {
	Name      string `json:"name"`
	IPAddress string `json:"ip_address"`
}

Interface model

type QRCodeSettings

type QRCodeSettings struct {
	Enabled    bool
	IncludeDNS bool
	IncludeMTU bool
}

type Server

type Server struct {
	KeyPair   *ServerKeypair
	Interface *ServerInterface
}

Server model

type ServerInterface

type ServerInterface struct {
	Addresses  []string  `json:"addresses"`
	ListenPort int       `json:"listen_port"`
	UpdatedAt  time.Time `json:"updated_at"`
	PostUp     string    `json:"post_up"`
	PreDown    string    `json:"pre_down"`
	PostDown   string    `json:"post_down"`

	// فیلد جدید برای فاصله بررسی (بر حسب دقیقه)
	CheckInterval int `json:"check_interval"`
}

ServerInterface model

func (*ServerInterface) UnmarshalJSON

func (s *ServerInterface) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom decoding to allow listen_port and check_interval to be provided as either strings or numbers.

type ServerKeypair

type ServerKeypair struct {
	PrivateKey string    `json:"private_key"`
	PublicKey  string    `json:"public_key"`
	UpdatedAt  time.Time `json:"updated_at"`
}

ServerKeypair model

type User

type User struct {
	Username     string    `json:"username"`
	PasswordHash string    `json:"password_hash"`
	Role         UserRole  `json:"role"`
	APIToken     string    `json:"api_token,omitempty"`
	TokenExpire  time.Time `json:"token_expire,omitempty"`
}

User model

type UserRole

type UserRole string

UserRole تعریف نوع نقش کاربر

const (
	RoleAdmin   UserRole = "admin"
	RoleManager UserRole = "manager"
	RoleUser    UserRole = "user"
)

type WakeOnLanHost

type WakeOnLanHost struct {
	MacAddress string     `json:"MacAddress"`
	Name       string     `json:"Name"`
	LatestUsed *time.Time `json:"LatestUsed"`
}

func (WakeOnLanHost) ResolveResourceName

func (host WakeOnLanHost) ResolveResourceName() (string, error)

Jump to

Keyboard shortcuts

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