handler

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: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIAdminCreateClient

func APIAdminCreateClient(db store.IStore) echo.HandlerFunc

APIAdminCreateClient handles POST /api/v1/admin/create-client

func APIAdminUpdateClient

func APIAdminUpdateClient(db store.IStore) echo.HandlerFunc

APIAdminUpdateClient handles POST /api/v1/admin/update-client

func APIAppUserInfo

func APIAppUserInfo(db store.IStore) echo.HandlerFunc

APIAppUserInfo handles POST /api/v1/app/user-info

func APIConnect

func APIConnect(db store.IStore) echo.HandlerFunc

APIConnect handles POST /api/v1/connect

func APILogin

func APILogin(db store.IStore) echo.HandlerFunc

APILogin handles POST /api/v1/login

func APIStatus

func APIStatus(db store.IStore) echo.HandlerFunc

APIStatus handles POST /api/v1/status

func AboutPage

func AboutPage() echo.HandlerFunc

AboutPage handler

func ApplyServerConfig

func ApplyServerConfig(db store.IStore, tmplDir fs.FS) echo.HandlerFunc

ApplyServerConfig handler to write config file and restart Wireguard server

func BackupSystem

func BackupSystem() echo.HandlerFunc

BackupSystem creates a backup of the database and WireGuard configuration

func CheckForUpdates

func CheckForUpdates(db store.IStore) echo.HandlerFunc

CheckForUpdates checks for system updates

func ClearSystemLogs

func ClearSystemLogs(db store.IStore) echo.HandlerFunc

ClearSystemLogs clears system logs

func ContentTypeJson

func ContentTypeJson(next echo.HandlerFunc) echo.HandlerFunc

ContentTypeJson checks that the requests have the Content-Type header set to "application/json". This helps against CSRF attacks.

func CreateUser

func CreateUser(db store.IStore) echo.HandlerFunc

CreateUser to create a new user

func DeleteWakeOnHost

func DeleteWakeOnHost(db store.IStore) echo.HandlerFunc

func DisplaySettingsSubmit

func DisplaySettingsSubmit(db store.IStore) echo.HandlerFunc

DisplaySettingsSubmit handler to update display settings

func DownloadClient

func DownloadClient(db store.IStore) echo.HandlerFunc

DownloadClient handler

func EmailClient

func EmailClient(db store.IStore, mailer emailer.Emailer, emailSubject, emailContent string) echo.HandlerFunc

EmailClient handler to send the configuration via email

func Favicon

func Favicon() echo.HandlerFunc

func FlushDNSCache

func FlushDNSCache(db store.IStore) echo.HandlerFunc

FlushDNSCache flushes the system DNS cache

func GenerateSystemReport

func GenerateSystemReport(db store.IStore) echo.HandlerFunc

GenerateSystemReport generates a system report

func GetClient

func GetClient(db store.IStore) echo.HandlerFunc

GetClient handler returns a JSON object of Wireguard client data

func GetClientQRCode

func GetClientQRCode(db store.IStore) echo.HandlerFunc

GetClientQRCode handler returns QR code image for a client

func GetClients

func GetClients(db store.IStore) echo.HandlerFunc

GetClients handler return a JSON list of Wireguard client data

func GetHashesChanges

func GetHashesChanges(db store.IStore) echo.HandlerFunc

GetHashesChanges handler returns if database hashes have changed

func GetOrderedSubnetRanges

func GetOrderedSubnetRanges() echo.HandlerFunc

GetOrderedSubnetRanges handler to get the ordered list of subnet ranges

func GetSystemLogs

func GetSystemLogs(db store.IStore) echo.HandlerFunc

GetSystemLogs retrieves system logs

func GetSystemMetrics

func GetSystemMetrics() echo.HandlerFunc

هندلری که اطلاعات سیستمی را در قالب JSON برمی‌گرداند

func GetUser

func GetUser(db store.IStore) echo.HandlerFunc

GetUser handler returns a JSON object of single user

func GetUsers

func GetUsers(db store.IStore) echo.HandlerFunc

GetUsers handler return a JSON list of all users

func GetWakeOnLanHosts

func GetWakeOnLanHosts(db store.IStore) echo.HandlerFunc

func GlobalSettingSubmit

func GlobalSettingSubmit(db store.IStore) echo.HandlerFunc

GlobalSettingSubmit handler to update the global settings

func GlobalSettings

func GlobalSettings(db store.IStore) echo.HandlerFunc

GlobalSettings handler

func Health

func Health() echo.HandlerFunc

Health check handler

func InternalOnly

func InternalOnly(next echo.HandlerFunc) echo.HandlerFunc

InternalOnly middleware to ensure request is from localhost

func LoadProfile

func LoadProfile(db store.IStore) echo.HandlerFunc

LoadProfile to load user information

func Login

func Login(db store.IStore) echo.HandlerFunc

Login for signing in handler

func LoginPage

func LoginPage() echo.HandlerFunc

LoginPage handler

func Logout

func Logout() echo.HandlerFunc

Logout to log a user out

func MachineIPAddresses

func MachineIPAddresses() echo.HandlerFunc

MachineIPAddresses handler to get local interface ip addresses

func NeedsAdmin

func NeedsAdmin(next echo.HandlerFunc) echo.HandlerFunc

func NewClient

func NewClient(db store.IStore) echo.HandlerFunc

NewClient handler

func RefreshSession

func RefreshSession(next echo.HandlerFunc) echo.HandlerFunc

RefreshSession must only be used after ValidSession middleware RefreshSession checks if the session is eligible for the refresh, but doesn't check if it's fully valid

func RemoveClient

func RemoveClient(db store.IStore) echo.HandlerFunc

RemoveClient handler

func RemoveUser

func RemoveUser(db store.IStore) echo.HandlerFunc

RemoveUser handler

func RestartWireGuardService

func RestartWireGuardService(db store.IStore) echo.HandlerFunc

RestartWireGuardService restarts the WireGuard service

func RestoreSystem

func RestoreSystem(db store.IStore) echo.HandlerFunc

RestoreSystem restores the database and WireGuard configuration from a backup

func SaveWakeOnLanHost

func SaveWakeOnLanHost(db store.IStore) echo.HandlerFunc

func SendTelegramClient

func SendTelegramClient(db store.IStore) echo.HandlerFunc

SendTelegramClient handler to send the configuration via Telegram

func SetClientStatus

func SetClientStatus(db store.IStore) echo.HandlerFunc

SetClientStatus handler to enable / disable a client

func StartQuotaChecker

func StartQuotaChecker(db store.IStore, tmplDir fs.FS)

StartQuotaChecker starts a goroutine that periodically checks client quotas and expiration dates

func StaticHandler

func StaticHandler(next echo.HandlerFunc) echo.HandlerFunc

StaticHandler handles serving static files with proper MIME types

func Status

func Status(db store.IStore) echo.HandlerFunc

Status handler to show wireguard connection status

func StatusData

func StatusData(db store.IStore) echo.HandlerFunc

StatusData handler to return JSON status data for clients

func SuggestIPAllocation

func SuggestIPAllocation(db store.IStore) echo.HandlerFunc

SuggestIPAllocation handler to get the list of ip address for client

func SystemMonitorPage

func SystemMonitorPage() echo.HandlerFunc

هندلری برای رندر صفحهٔ مانیتورینگ سیستم

func TerminateClient

func TerminateClient(db store.IStore, tmplDir fs.FS) echo.HandlerFunc

TerminateClient handler to terminate a client connection

func UpdateClient

func UpdateClient(db store.IStore) echo.HandlerFunc

UpdateClient handler to update client information

func UpdateUser

func UpdateUser(db store.IStore) echo.HandlerFunc

UpdateUser to update user information

func UsersSettings

func UsersSettings(db store.IStore) echo.HandlerFunc

UsersSettings handler

func UtilitiesPage

func UtilitiesPage(db store.IStore) echo.HandlerFunc

UtilitiesPage handles the utilities page request

func ValidSession

func ValidSession(next echo.HandlerFunc) echo.HandlerFunc

func WakeOnHost

func WakeOnHost(db store.IStore) echo.HandlerFunc

func WireGuardClients

func WireGuardClients(db store.IStore) echo.HandlerFunc

WireGuardClients handler

func WireGuardServer

func WireGuardServer(db store.IStore) echo.HandlerFunc

WireGuardServer handler

func WireGuardServerInterfaces

func WireGuardServerInterfaces(db store.IStore) echo.HandlerFunc

WireGuardServerInterfaces handler

func WireGuardServerKeyPair

func WireGuardServerKeyPair(db store.IStore) echo.HandlerFunc

WireGuardServerKeyPair handler to generate private and public keys

Types

type APIConnectResponse

type APIConnectResponse struct {
	Config string `json:"config"`
}

APIConnectResponse represents the response for connect endpoint

type APILoginResponse

type APILoginResponse struct {
	Status           string    `json:"status"`
	Token            string    `json:"token"`
	ExpireAt         time.Time `json:"expire_at"`
	TotalTraffic     int64     `json:"total_traffic"`
	RemainingTraffic int64     `json:"remaining_traffic"`
}

APILoginResponse represents the response for login endpoint

type APIRequest

type APIRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

APIRequest represents a generic API request

type APIStatusResponse

type APIStatusResponse struct {
	Status           string    `json:"status"`
	TotalTraffic     int64     `json:"total_traffic"`
	UsedTraffic      int64     `json:"used_traffic"`
	RemainingTraffic int64     `json:"remaining_traffic"`
	ExpireAt         time.Time `json:"expire_at"`
	Expired          bool      `json:"expired"`
}

APIStatusResponse represents the response for status endpoint

type AdminCreateClientRequest

type AdminCreateClientRequest struct {
	Username   string `json:"username"`
	Email      string `json:"email"`
	Token      string `json:"token"`
	Expiration string `json:"expiration,omitempty"` // Optional RFC3339 format (e.g., "2024-12-05T15:00:00Z")
}

AdminCreateClientRequest represents the request for admin create client endpoint

type AdminCreateClientResponse

type AdminCreateClientResponse struct {
	Status string `json:"status"`
	Config string `json:"config"`
}

AdminCreateClientResponse represents the response for admin create client endpoint

type AdminUpdateClientRequest

type AdminUpdateClientRequest struct {
	Username   string `json:"username"`
	AddDays    int    `json:"add_days"`
	ResetQuota bool   `json:"reset_quota"`
	Enable     *bool  `json:"enable,omitempty"` // Optional: explicitly enable/disable client
	Token      string `json:"token"`
}

AdminUpdateClientRequest represents the request for admin update client endpoint

type AdminUpdateClientResponse

type AdminUpdateClientResponse struct {
	Status        string    `json:"status"`
	NewExpiration time.Time `json:"new_expiration"`
	Message       string    `json:"message"`
}

AdminUpdateClientResponse represents the response for admin update client endpoint

type AppUserInfoRequest

type AppUserInfoRequest struct {
	Username string `json:"username"`
}

AppUserInfoRequest represents the request for mobile app user info endpoint

type AppUserInfoResponse

type AppUserInfoResponse struct {
	Status         string    `json:"status"`
	PeerFound      bool      `json:"peer_found"`
	IsExpired      bool      `json:"is_expired"`
	IsOverQuota    bool      `json:"is_over_quota"`
	QuotaRemaining int64     `json:"quota_remaining"`
	ExpirationDate time.Time `json:"expiration_date"`
	Config         string    `json:"config,omitempty"`
	Message        string    `json:"message,omitempty"`
}

AppUserInfoResponse represents the response for the mobile app user info endpoint

type DeviceVM

type DeviceVM struct {
	Name  string
	Peers []PeerVM
}

DeviceVM view model

type PeerVM

type PeerVM struct {
	PublicKey         string
	Name              string
	Email             string
	AllocatedIP       string
	Endpoint          string
	ReceivedBytes     int64
	TransmitBytes     int64
	LastHandshakeTime time.Time
	LastHandshakeRel  time.Duration
	Connected         bool
}

PeerVM view model

type Route

type Route struct {
	Method     string
	Path       string
	Handler    func(store.IStore) echo.HandlerFunc
	Middleware []echo.MiddlewareFunc
}

Route represents an internal API route

func GetInternalRoutes

func GetInternalRoutes() []Route

GetInternalRoutes returns the list of internal routes

type SystemMetrics

type SystemMetrics struct {
	CPU struct {
		Usage float64 `json:"usage"`
		Cores int     `json:"cores"`
	} `json:"cpu"`

	RAM struct {
		Total uint64  `json:"total"`
		Used  uint64  `json:"used"`
		Usage float64 `json:"usage"`
	} `json:"ram"`

	Swap struct {
		Total uint64  `json:"total"`
		Used  uint64  `json:"used"`
		Usage float64 `json:"usage"`
	} `json:"swap"`

	Disk struct {
		Total uint64  `json:"total"`
		Used  uint64  `json:"used"`
		Usage float64 `json:"usage"`
	} `json:"disk"`

	Network struct {
		UploadSpeed   float64 `json:"uploadSpeed"`   // KB/s
		DownloadSpeed float64 `json:"downloadSpeed"` // KB/s
		TotalOut      uint64  `json:"totalOut"`      // MB
		TotalIn       uint64  `json:"totalIn"`       // MB
	} `json:"network"`

	SystemLoad string `json:"systemLoad"`
	Uptime     string `json:"uptime"`
}

ساختار پاسخ JSON برای متریک‌های سیستمی

type WakeOnLanHostSavePayload

type WakeOnLanHostSavePayload struct {
	Name          string `json:"name"`
	MacAddress    string `json:"mac_address"`
	OldMacAddress string `json:"old_mac_address"`
}

Jump to

Keyboard shortcuts

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