handler

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WSUpgrader = websocket.Upgrader{
	CheckOrigin: checkWSOrigin,
}

WSUpgrader is the shared upgrader for all WebSocket connections.

Functions

func HandleBindError added in v0.0.10

func HandleBindError(c *gin.Context, err error)

HandleBindError processes ShouldBindJSON errors and returns a structured response.

func HandleError added in v0.0.10

func HandleError(c *gin.Context, status int, message string, err error)

HandleError logs the error to Gin context and sends a JSON response.

func SetAuditSvc added in v0.0.10

func SetAuditSvc(c *gin.Context, svc *service.AuditService)

SetAuditSvc stores the audit service in the Gin context for use by handlers.

func SetWSAllowedOrigins added in v0.0.4

func SetWSAllowedOrigins(origins []string)

SetWSAllowedOrigins configures allowed WebSocket origins.

Types

type AuditHandler added in v0.0.10

type AuditHandler struct {
	// contains filtered or unexported fields
}

AuditHandler handles audit log endpoints.

func NewAuditHandler added in v0.0.10

func NewAuditHandler(audit *service.AuditService) *AuditHandler

NewAuditHandler creates a new AuditHandler.

func (*AuditHandler) List added in v0.0.10

func (h *AuditHandler) List(c *gin.Context)

List handles GET /api/v1/audit @Summary List audit entries @Description Retrieve audit log entries with pagination @Tags audit @Produce json @Param limit query int false "Max entries (1-1000, default 100)" @Param offset query int false "Offset (default 0)" @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /audit [get]

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

AuthHandler handles authentication endpoints.

func NewAuthHandler

func NewAuthHandler(settings *store.SettingsStore, blocklist *store.TokenBlocklistStore) *AuthHandler

NewAuthHandler creates a new AuthHandler.

func (*AuthHandler) ChangePassword

func (h *AuthHandler) ChangePassword(c *gin.Context)

ChangePassword handles PUT /api/v1/auth/password @Summary Change password @Description Update the admin password by providing the current and new password @Tags auth @Accept json @Produce json @Param body body passwordRequest true "Current and new password" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 401 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /auth/password [put]

func (*AuthHandler) Login

func (h *AuthHandler) Login(c *gin.Context)

Login handles POST /api/v1/auth/login @Summary Login @Description Authenticate with username and password to obtain an access/refresh token pair @Tags auth @Accept json @Produce json @Param body body loginRequest true "Login credentials" @Success 200 {object} loginResponse @Failure 400 {object} map[string]string @Failure 401 {object} map[string]string @Failure 403 {object} map[string]string @Failure 500 {object} map[string]string @Router /auth/login [post]

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(c *gin.Context)

Logout handles POST /api/v1/auth/logout @Summary Logout @Description Revoke the current access token and optionally a refresh token from the body @Tags auth @Accept json @Produce json @Param body body refreshRequest false "Refresh token to revoke" @Success 200 {object} map[string]string @Security BearerAuth @Router /auth/logout [post]

func (*AuthHandler) Refresh

func (h *AuthHandler) Refresh(c *gin.Context)

Refresh handles POST /api/v1/auth/refresh @Summary Refresh token @Description Exchange a valid refresh token for a new access/refresh token pair @Tags auth @Accept json @Produce json @Param body body refreshRequest true "Refresh token" @Success 200 {object} loginResponse @Failure 400 {object} map[string]string @Failure 401 {object} map[string]string @Failure 500 {object} map[string]string @Router /auth/refresh [post]

func (*AuthHandler) Setup

func (h *AuthHandler) Setup(c *gin.Context)

Setup handles POST /api/v1/auth/setup @Summary Initial setup @Description One-time setup to create the admin password. Returns a token pair on success. @Tags auth @Accept json @Produce json @Param body body setupRequest true "Setup password" @Success 200 {object} loginResponse @Failure 400 {object} map[string]string @Failure 409 {object} map[string]string @Failure 500 {object} map[string]string @Router /auth/setup [post]

type BackupHandler

type BackupHandler struct {
	// contains filtered or unexported fields
}

BackupHandler handles backup endpoints.

func NewBackupHandler

func NewBackupHandler(backups *store.BackupStore, settings *store.SettingsStore, containerSvc *service.ContainerService, auditSvc *service.AuditService) *BackupHandler

NewBackupHandler creates a new BackupHandler.

func (*BackupHandler) Create

func (h *BackupHandler) Create(c *gin.Context)

Create handles POST /api/v1/backups @Summary Create backup @Description Creates a new encrypted or unencrypted backup depending on BACKUP_ENCRYPTION_KEY env var. Returns filename, size, checksum, and creation timestamp. @Tags backup @Produce json @Success 200 {object} map[string]interface{} @Failure 500 {object} map[string]string @Security BearerAuth @Router /backups [post]

func (*BackupHandler) Delete

func (h *BackupHandler) Delete(c *gin.Context)

Delete handles DELETE /api/v1/backups/:filename @Summary Delete backup @Description Deletes a backup file and its checksum sidecar by filename @Tags backup @Produce json @Param filename path string true "Backup filename" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /backups/{filename} [delete]

func (*BackupHandler) Download

func (h *BackupHandler) Download(c *gin.Context)

Download handles GET /api/v1/backups/download/:filename @Summary Download backup @Description Downloads a backup file (encrypted or plain) by filename as a binary attachment @Tags backup @Produce application/octet-stream @Param filename path string true "Backup filename" @Success 200 {file} binary @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Security BearerAuth @Router /backups/download/{filename} [get]

func (*BackupHandler) List

func (h *BackupHandler) List(c *gin.Context)

List handles GET /api/v1/backups @Summary List backups @Description Returns a list of all available backups and whether backup encryption is enabled. @Tags backup @Produce json @Success 200 {object} map[string]interface{} @Failure 500 {object} map[string]string @Security BearerAuth @Router /backups [get]

func (*BackupHandler) Restore

func (h *BackupHandler) Restore(c *gin.Context)

Restore handles POST /api/v1/backups/restore @Summary Restore backup @Description Stops the proxy engine, restores database and config from backup, rotates JWT secret, then restarts the engine. Verifies SHA256 checksum if available. @Tags backup @Accept json @Produce json @Param body body object{filename=string} true "Backup filename to restore" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /backups/restore [post]

type BotHandler

type BotHandler struct {
	// contains filtered or unexported fields
}

BotHandler handles Telegram bot endpoints.

func NewBotHandler

func NewBotHandler(settings *store.SettingsStore, deps *bot.Dependencies) *BotHandler

NewBotHandler creates a new BotHandler.

func (*BotHandler) DetectChatID

func (h *BotHandler) DetectChatID(c *gin.Context)

DetectChatID handles GET /api/v1/bot/detect-chat-id @Summary Detect Telegram chat ID @Description Queries Telegram API for recent messages to detect and auto-save the chat ID @Tags bot @Accept json @Produce json @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /bot/detect-chat-id [get]

func (*BotHandler) SetCommands added in v0.1.0

func (h *BotHandler) SetCommands(c *gin.Context)

SetCommands handles POST /api/v1/bot/commands @Summary Update bot commands @Description Registers the current command list with Telegram via setMyCommands @Tags bot @Produce json @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /bot/commands [post]

func (*BotHandler) Setup

func (h *BotHandler) Setup(c *gin.Context)

Setup handles POST /api/v1/bot/setup @Summary Setup Telegram bot @Description Configures and starts the Telegram notification bot with the provided token, chat ID, interval, and label @Tags bot @Accept json @Produce json @Param body body object{token=string,chat_id=string,interval=int,label=string} true "Bot configuration" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /bot/setup [post]

func (*BotHandler) Status

func (h *BotHandler) Status(c *gin.Context)

Status handles GET /api/v1/bot/status @Summary Bot status @Description Returns the current Telegram bot status including enabled state, running state, and configuration @Tags bot @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /bot/status [get]

func (*BotHandler) Test

func (h *BotHandler) Test(c *gin.Context)

Test handles POST /api/v1/bot/test @Summary Test bot notification @Description Sends a test message via the configured Telegram bot @Tags bot @Accept json @Produce json @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /bot/test [post]

func (*BotHandler) Toggle

func (h *BotHandler) Toggle(c *gin.Context)

Toggle handles PUT /api/v1/bot/toggle @Summary Toggle bot on/off @Description Enables or disables the Telegram notification bot @Tags bot @Accept json @Produce json @Param body body object{enable=bool} true "Enable flag" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /bot/toggle [put]

type ConfigHandler

type ConfigHandler struct {
	// contains filtered or unexported fields
}

ConfigHandler handles configuration endpoints.

func NewConfigHandler

func NewConfigHandler(settings *store.SettingsStore) *ConfigHandler

NewConfigHandler creates a new ConfigHandler.

func (*ConfigHandler) GetAll

func (h *ConfigHandler) GetAll(c *gin.Context)

GetAll handles GET /api/v1/config @Summary Get all settings @Description Returns all application settings @Tags config @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /config [get]

func (*ConfigHandler) GetKey

func (h *ConfigHandler) GetKey(c *gin.Context)

GetKey handles GET /api/v1/config/:key @Summary Get a single setting @Description Returns the value of a specific setting by key name @Tags config @Accept json @Produce json @Param key path string true "Setting key" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /config/{key} [get]

func (*ConfigHandler) Update

func (h *ConfigHandler) Update(c *gin.Context)

Update handles PUT /api/v1/config @Summary Update settings @Description Updates application settings. Only whitelisted keys are accepted; internal keys (jwt_secret, auth_password_hash) are rejected. @Tags config @Accept json @Produce json @Param body body map[string]any true "Settings key-value pairs to update" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /config [put]

type DockerHandler

type DockerHandler struct {
	// contains filtered or unexported fields
}

DockerHandler handles Docker/engine endpoints.

func NewDockerHandler

func NewDockerHandler(docker *dockerutil.DockerClient, dockerSvc *service.DockerService, settings *store.SettingsStore) *DockerHandler

NewDockerHandler creates a new DockerHandler.

func (*DockerHandler) Build

func (h *DockerHandler) Build(c *gin.Context)

Build handles POST /api/v1/engine/build @Summary Build engine image @Description Builds the telemt engine Docker image from source. Supports optional force rebuild @Tags engine @Accept json @Produce json @Param body body object{force=bool} false "Build options" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /engine/build [post]

func (*DockerHandler) EngineStatus

func (h *DockerHandler) EngineStatus(c *gin.Context)

EngineStatus handles GET /api/v1/engine/status @Summary Engine status @Description Returns the telemt engine image status, installed version, and whether it is up to date @Tags engine @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /engine/status [get]

func (*DockerHandler) Install

func (h *DockerHandler) Install(c *gin.Context)

Install handles POST /api/v1/docker/install @Summary Install Docker @Description Ensures Docker is installed on the host system @Tags docker @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /docker/install [post]

func (*DockerHandler) Status

func (h *DockerHandler) Status(c *gin.Context)

Status handles GET /api/v1/docker/status @Summary Docker status @Description Returns Docker installation and running status along with server version @Tags docker @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /docker/status [get]

type GeoblockHandler

type GeoblockHandler struct {
	// contains filtered or unexported fields
}

GeoblockHandler handles geo-blocking endpoints.

func NewGeoblockHandler

func NewGeoblockHandler(settings *store.SettingsStore, geoSvc *service.GeoblockService) *GeoblockHandler

NewGeoblockHandler creates a new GeoblockHandler.

func (*GeoblockHandler) Add

func (h *GeoblockHandler) Add(c *gin.Context)

Add handles POST /api/v1/geoblock/add @Summary Add country to blocklist @Description Adds a country (ISO 3166-1 alpha-2 code) to the geo-block list and applies iptables rules @Tags geoblock @Accept json @Produce json @Param body body object{country=string} true "Country code to add" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /geoblock/add [post]

func (*GeoblockHandler) Clear

func (h *GeoblockHandler) Clear(c *gin.Context)

Clear handles POST /api/v1/geoblock/clear @Summary Clear all geo-block rules @Description Removes all countries from the geo-block list and clears iptables rules @Tags geoblock @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /geoblock/clear [post]

func (*GeoblockHandler) Get

func (h *GeoblockHandler) Get(c *gin.Context)

Get handles GET /api/v1/geoblock @Summary Get geo-block settings @Description Returns the current geo-blocking mode and list of blocked/allowed countries @Tags geoblock @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /geoblock [get]

func (*GeoblockHandler) Remove

func (h *GeoblockHandler) Remove(c *gin.Context)

Remove handles POST /api/v1/geoblock/remove @Summary Remove country from blocklist @Description Removes a country (ISO 3166-1 alpha-2 code) from the geo-block list and re-applies rules @Tags geoblock @Accept json @Produce json @Param body body object{country=string} true "Country code to remove" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /geoblock/remove [post]

func (*GeoblockHandler) SetMode

func (h *GeoblockHandler) SetMode(c *gin.Context)

SetMode handles PUT /api/v1/geoblock/mode @Summary Set geo-block mode @Description Sets the geo-blocking mode to either blacklist or whitelist and re-applies rules @Tags geoblock @Accept json @Produce json @Param body body object{mode=string} true "Mode to set (blacklist or whitelist)" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /geoblock/mode [put]

type HealthHandler

type HealthHandler struct {
	// contains filtered or unexported fields
}

HealthHandler handles health check endpoint.

func NewHealthHandler

func NewHealthHandler() *HealthHandler

NewHealthHandler creates a new HealthHandler.

func (*HealthHandler) Check

func (h *HealthHandler) Check(c *gin.Context)

Check handles GET /api/v1/health @Summary Health check @Description Returns the health status of the service, including version, Docker, and container info @Tags health @Produce json @Success 200 {object} map[string]interface{} @Router /health [get]

func (*HealthHandler) SetHealthService

func (h *HealthHandler) SetHealthService(svc *service.HealthService)

SetHealthService sets the health service.

type InstanceHandler

type InstanceHandler struct {
	// contains filtered or unexported fields
}

InstanceHandler handles instance endpoints.

func NewInstanceHandler

func NewInstanceHandler(instances *store.InstanceStore) *InstanceHandler

NewInstanceHandler creates a new InstanceHandler.

func (*InstanceHandler) Add

func (h *InstanceHandler) Add(c *gin.Context)

Add handles POST /api/v1/instances @Summary Add an instance @Description Create a new proxy instance with a port, optional metrics port, and label @Tags instances @Accept json @Produce json @Param body body addInstanceRequest true "Instance configuration" @Success 201 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /instances [post]

func (*InstanceHandler) CheckPort added in v0.1.0

func (h *InstanceHandler) CheckPort(c *gin.Context)

CheckPort handles GET /api/v1/instances/check-port?port=XXX&exclude=ID @Summary Check port availability @Description Check if a TCP port is available for a new instance @Tags instances @Produce json @Param port query int true "Port number to check" @Param exclude query int false "Instance ID to exclude from conflict check" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Security BearerAuth @Router /instances/check-port [get]

func (*InstanceHandler) InstanceLogs added in v0.1.0

func (h *InstanceHandler) InstanceLogs(c *gin.Context)

InstanceLogs handles GET /api/v1/instances/:id/logs @Summary Instance logs @Description Retrieve logs for a specific proxy instance. Supports SSE streaming when follow=true. @Tags instances @Produce plain @Param id path int true "Instance ID" @Param tail query int false "Number of log lines to return (default 100)" @Param follow query bool false "Enable SSE streaming of log output" @Success 200 {string} string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /instances/{id}/logs [get]

func (*InstanceHandler) InstanceStatus added in v0.1.0

func (h *InstanceHandler) InstanceStatus(c *gin.Context)

InstanceStatus handles GET /api/v1/instances/:id/status @Summary Instance status @Description Retrieve the current status of a specific proxy instance @Tags instances @Produce json @Param id path int true "Instance ID" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id}/status [get]

func (*InstanceHandler) List

func (h *InstanceHandler) List(c *gin.Context)

List handles GET /api/v1/instances @Summary List instances @Description Retrieve all proxy instances @Tags instances @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances [get]

func (*InstanceHandler) ReloadInstance added in v0.1.0

func (h *InstanceHandler) ReloadInstance(c *gin.Context)

ReloadInstance handles POST /api/v1/instances/:id/reload @Summary Reload an instance @Description Reload a specific proxy instance configuration @Tags instances @Produce json @Param id path int true "Instance ID" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id}/reload [post]

func (*InstanceHandler) Remove

func (h *InstanceHandler) Remove(c *gin.Context)

Remove handles DELETE /api/v1/instances/:id @Summary Remove an instance @Description Delete a proxy instance by ID. The last instance cannot be removed. @Tags instances @Produce json @Param id path int true "Instance ID" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id} [delete]

func (*InstanceHandler) SetContainerSvc added in v0.1.0

func (h *InstanceHandler) SetContainerSvc(svc *service.ContainerService)

SetContainerSvc sets the container service for per-instance management.

func (*InstanceHandler) SetDockerClient added in v0.1.0

func (h *InstanceHandler) SetDockerClient(d *dockerutil.DockerClient)

SetDockerClient sets the Docker client for log streaming.

func (*InstanceHandler) StartInstance added in v0.1.0

func (h *InstanceHandler) StartInstance(c *gin.Context)

StartInstance handles POST /api/v1/instances/:id/start @Summary Start an instance @Description Start a specific proxy instance container @Tags instances @Produce json @Param id path int true "Instance ID" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id}/start [post]

func (*InstanceHandler) StopInstance added in v0.1.0

func (h *InstanceHandler) StopInstance(c *gin.Context)

StopInstance handles POST /api/v1/instances/:id/stop @Summary Stop an instance @Description Stop a specific proxy instance container @Tags instances @Produce json @Param id path int true "Instance ID" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id}/stop [post]

func (*InstanceHandler) Update added in v0.1.0

func (h *InstanceHandler) Update(c *gin.Context)

Update handles PUT /api/v1/instances/:id @Summary Update an instance @Description Update an existing proxy instance configuration @Tags instances @Accept json @Produce json @Param id path int true "Instance ID" @Param body body updateInstanceRequest true "Instance updates" @Success 200 {object} object @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /instances/{id} [put]

type ProxyHandler

type ProxyHandler struct {
	// contains filtered or unexported fields
}

ProxyHandler handles proxy control endpoints.

func NewProxyHandler

func NewProxyHandler(container *service.ContainerService, secrets *store.SecretStore, settings *store.SettingsStore, secretSvc *service.SecretService) *ProxyHandler

NewProxyHandler creates a new ProxyHandler.

func (*ProxyHandler) Logs

func (h *ProxyHandler) Logs(c *gin.Context)

Logs handles GET /api/v1/proxy/logs @Summary Proxy logs @Description Retrieve proxy container logs. Supports SSE streaming when follow=true. @Tags proxy @Produce plain @Param tail query int false "Number of log lines to return (default 100)" @Param follow query bool false "Enable SSE streaming of log output" @Success 200 {string} string @Failure 500 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /proxy/logs [get]

func (*ProxyHandler) Reload

func (h *ProxyHandler) Reload(c *gin.Context)

Reload handles POST /api/v1/proxy/reload @Summary Reload proxy configuration @Description Reload the proxy configuration without restarting the container @Tags proxy @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /proxy/reload [post]

func (*ProxyHandler) Restart

func (h *ProxyHandler) Restart(c *gin.Context)

Restart handles POST /api/v1/proxy/restart @Summary Restart proxy @Description Restart the proxy container @Tags proxy @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /proxy/restart [post]

func (*ProxyHandler) SetDockerClient

func (h *ProxyHandler) SetDockerClient(d *dockerutil.DockerClient)

SetDockerClient sets the Docker client for log streaming.

func (*ProxyHandler) SetInstanceStore added in v0.1.0

func (h *ProxyHandler) SetInstanceStore(s *store.InstanceStore)

SetInstanceStore sets the instance store for log streaming.

func (*ProxyHandler) Start

func (h *ProxyHandler) Start(c *gin.Context)

Start handles POST /api/v1/proxy/start @Summary Start proxy @Description Start the proxy container and return links for all enabled secrets @Tags proxy @Produce json @Success 200 {object} map[string]interface{} @Failure 500 {object} map[string]string @Security BearerAuth @Router /proxy/start [post]

func (*ProxyHandler) Status

func (h *ProxyHandler) Status(c *gin.Context)

Status handles GET /api/v1/proxy/status @Summary Proxy status @Description Retrieve the current status of the proxy container @Tags proxy @Produce json @Success 200 {object} map[string]interface{} @Failure 500 {object} map[string]string @Security BearerAuth @Router /proxy/status [get]

func (*ProxyHandler) Stop

func (h *ProxyHandler) Stop(c *gin.Context)

Stop handles POST /api/v1/proxy/stop @Summary Stop proxy @Description Stop the proxy container @Tags proxy @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /proxy/stop [post]

type ReplicationHandler

type ReplicationHandler struct {
	// contains filtered or unexported fields
}

ReplicationHandler handles replication endpoints.

func NewReplicationHandler

func NewReplicationHandler(settings *store.SettingsStore, slaves *store.SlaveStore) *ReplicationHandler

NewReplicationHandler creates a new ReplicationHandler.

func (*ReplicationHandler) AddSlave

func (h *ReplicationHandler) AddSlave(c *gin.Context)

AddSlave handles POST /api/v1/replication/slaves @Summary Add replication slave @Description Registers a new replication slave with host, port, and optional label @Tags replication @Accept json @Produce json @Param body body object{host=string,port=int,label=string} true "Slave configuration" @Success 201 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /replication/slaves [post]

func (*ReplicationHandler) GetSSHKey added in v0.0.5

func (h *ReplicationHandler) GetSSHKey(c *gin.Context)

GetSSHKey handles GET /api/v1/replication/ssh-key @Summary Get SSH public key @Description Returns the SSH public key used for replication @Tags replication @Accept json @Produce json @Success 200 {object} map[string]string @Failure 404 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /replication/ssh-key [get]

func (*ReplicationHandler) ListSlaves

func (h *ReplicationHandler) ListSlaves(c *gin.Context)

ListSlaves handles GET /api/v1/replication/slaves @Summary List replication slaves @Description Returns a list of all configured replication slaves @Tags replication @Accept json @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /replication/slaves [get]

func (*ReplicationHandler) RemoveSlave

func (h *ReplicationHandler) RemoveSlave(c *gin.Context)

RemoveSlave handles DELETE /api/v1/replication/slaves/:host @Summary Remove replication slave @Description Removes a replication slave by its host address @Tags replication @Accept json @Produce json @Param host path string true "Slave host address" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /replication/slaves/{host} [delete]

func (*ReplicationHandler) SSHKeygen

func (h *ReplicationHandler) SSHKeygen(c *gin.Context)

SSHKeygen handles POST /api/v1/replication/ssh-keygen @Summary Generate SSH key pair @Description Generates a new SSH key pair for replication and returns the public key @Tags replication @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /replication/ssh-keygen [post]

func (*ReplicationHandler) SetReplicationService

func (h *ReplicationHandler) SetReplicationService(svc *service.ReplicationService)

SetReplicationService sets the replication service.

func (*ReplicationHandler) Setup

func (h *ReplicationHandler) Setup(c *gin.Context)

Setup handles POST /api/v1/replication/setup @Summary Setup replication @Description Configures replication role (master or slave) with optional SSH settings @Tags replication @Accept json @Produce json @Param body body object{role=string,ssh_user=string,ssh_port=int} true "Replication configuration" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /replication/setup [post]

func (*ReplicationHandler) Status

func (h *ReplicationHandler) Status(c *gin.Context)

Status handles GET /api/v1/replication/status @Summary Replication status @Description Returns the current replication role, enabled state, and list of slaves @Tags replication @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /replication/status [get]

func (*ReplicationHandler) Sync

func (h *ReplicationHandler) Sync(c *gin.Context)

Sync handles POST /api/v1/replication/sync @Summary Sync to all slaves @Description Triggers a configuration sync to all registered replication slaves via SSH/SFTP @Tags replication @Accept json @Produce json @Success 200 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /replication/sync [post]

func (*ReplicationHandler) Test

func (h *ReplicationHandler) Test(c *gin.Context)

Test handles POST /api/v1/replication/test @Summary Test SSH connection @Description Tests SSH connectivity to a specified replication slave host @Tags replication @Accept json @Produce json @Param body body object{host=string} true "Host to test" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /replication/test [post]

type SchedulerHandler added in v0.0.10

type SchedulerHandler struct {
	// contains filtered or unexported fields
}

SchedulerHandler handles scheduler management endpoints.

func NewSchedulerHandler added in v0.0.10

func NewSchedulerHandler(svc *service.SchedulerService) *SchedulerHandler

NewSchedulerHandler creates a new SchedulerHandler.

func (*SchedulerHandler) AllHistory added in v0.0.10

func (h *SchedulerHandler) AllHistory(c *gin.Context)

AllHistory handles GET /api/v1/scheduler/history @Summary Get all execution history @Description Returns execution history records for all scheduled tasks @Tags scheduler @Accept json @Produce json @Param limit query int false "Max records to return (default: 20, max: 100)" @Param offset query int false "Records to skip (default: 0)" @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /scheduler/history [get]

func (*SchedulerHandler) History added in v0.0.10

func (h *SchedulerHandler) History(c *gin.Context)

History handles GET /api/v1/scheduler/tasks/:name/history @Summary Get task execution history @Description Returns execution history records for a specific scheduled task @Tags scheduler @Accept json @Produce json @Param name path string true "Task name" @Param limit query int false "Max records to return (default: 20, max: 100)" @Param offset query int false "Records to skip (default: 0)" @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /scheduler/tasks/{name}/history [get]

func (*SchedulerHandler) List added in v0.0.10

func (h *SchedulerHandler) List(c *gin.Context)

List handles GET /api/v1/scheduler/tasks @Summary List scheduler tasks @Description Returns all scheduled tasks with their current configuration, enabled state, and schedule @Tags scheduler @Accept json @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /scheduler/tasks [get]

func (*SchedulerHandler) RunNow added in v0.0.10

func (h *SchedulerHandler) RunNow(c *gin.Context)

RunNow handles POST /api/v1/scheduler/tasks/:name/run @Summary Run scheduler task now @Description Triggers immediate execution of a scheduled task and returns the execution record @Tags scheduler @Accept json @Produce json @Param name path string true "Task name" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /scheduler/tasks/{name}/run [post]

func (*SchedulerHandler) Update added in v0.0.10

func (h *SchedulerHandler) Update(c *gin.Context)

Update handles PUT /api/v1/scheduler/tasks/:name @Summary Update scheduler task @Description Updates a scheduled task's enabled state and/or cron schedule @Tags scheduler @Accept json @Produce json @Param name path string true "Task name" @Param body body object{enabled=bool,schedule=string} true "Task update fields" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /scheduler/tasks/{name} [put]

type SecretHandler

type SecretHandler struct {
	// contains filtered or unexported fields
}

SecretHandler handles secret endpoints.

func NewSecretHandler

func NewSecretHandler(secrets *service.SecretService, settings *store.SettingsStore) *SecretHandler

NewSecretHandler creates a new SecretHandler.

func (*SecretHandler) Add

func (h *SecretHandler) Add(c *gin.Context)

Add handles POST /api/v1/secrets @Summary Add a secret @Description Create a new secret with a unique label and optional hex secret value @Tags secrets @Accept json @Produce json @Param body body addSecretRequest true "Secret to add" @Success 201 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets [post]

func (*SecretHandler) Archive added in v0.0.10

func (h *SecretHandler) Archive(c *gin.Context)

Archive handles POST /api/v1/secrets/:label/archive @Summary Archive a secret @Description Archive a secret to hide it from normal listings @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/archive [post]

func (*SecretHandler) BulkExtend added in v0.0.10

func (h *SecretHandler) BulkExtend(c *gin.Context)

BulkExtend handles POST /api/v1/secrets/bulk-extend @Summary Bulk extend secrets @Description Extend expiry for multiple secrets at once @Tags secrets @Accept json @Produce json @Param body body bulkExtendRequest true "Labels and days" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/bulk-extend [post]

func (*SecretHandler) BulkRotate added in v0.0.10

func (h *SecretHandler) BulkRotate(c *gin.Context)

BulkRotate handles POST /api/v1/secrets/bulk-rotate @Summary Bulk rotate secrets @Description Rotate keys for multiple secrets at once @Tags secrets @Accept json @Produce json @Param body body bulkRotateRequest true "Labels" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/bulk-rotate [post]

func (*SecretHandler) BulkSetLimits added in v0.0.10

func (h *SecretHandler) BulkSetLimits(c *gin.Context)

BulkSetLimits handles POST /api/v1/secrets/bulk-set-limits @Summary Bulk set secret limits @Description Configure connection, IP, quota, and expiry limits for multiple secrets at once by labels or tag @Tags secrets @Accept json @Produce json @Param body body bulkSetLimitsRequest true "Labels or tag and limits configuration" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/bulk-set-limits [post]

func (*SecretHandler) BulkToggle added in v0.0.10

func (h *SecretHandler) BulkToggle(c *gin.Context)

BulkToggle handles POST /api/v1/secrets/bulk-toggle @Summary Bulk toggle secrets @Description Enable or disable multiple secrets at once by labels or tag @Tags secrets @Accept json @Produce json @Param body body bulkToggleRequest true "Labels or tag and enable flag" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/bulk-toggle [post]

func (*SecretHandler) Clone added in v0.0.10

func (h *SecretHandler) Clone(c *gin.Context)

Clone handles POST /api/v1/secrets/:label/clone @Summary Clone a secret @Description Create a copy of a secret with a new label and generated key @Tags secrets @Accept json @Produce json @Param label path string true "Source secret label" @Param body body cloneSecretRequest true "New label" @Success 201 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/clone [post]

func (*SecretHandler) DisableExpired added in v0.0.10

func (h *SecretHandler) DisableExpired(c *gin.Context)

DisableExpired handles POST /api/v1/secrets/disable-expired @Summary Disable expired secrets @Description Disable all secrets whose expiry date has passed @Tags secrets @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/disable-expired [post]

func (*SecretHandler) Export added in v0.0.10

func (h *SecretHandler) Export(c *gin.Context)

Export handles GET /api/v1/secrets/export @Summary Export secrets @Description Export all secrets as JSON @Tags secrets @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/export [get]

func (*SecretHandler) Extend added in v0.0.10

func (h *SecretHandler) Extend(c *gin.Context)

Extend handles POST /api/v1/secrets/:label/extend @Summary Extend secret expiry @Description Extend a secret's expiry by the given number of days. Re-enables the secret if it was disabled. @Tags secrets @Accept json @Produce json @Param label path string true "Secret label" @Param body body extendSecretRequest true "Days to extend" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/extend [post]

func (*SecretHandler) Get

func (h *SecretHandler) Get(c *gin.Context)

Get handles GET /api/v1/secrets/:label @Summary Get a secret @Description Retrieve a single secret by its label @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} object @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/{label} [get]

func (*SecretHandler) GetLimits

func (h *SecretHandler) GetLimits(c *gin.Context)

GetLimits handles GET /api/v1/secrets/:label/limits @Summary Get secret limits @Description Retrieve the current limits (connections, IPs, quota, expiry) for a secret @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} map[string]interface{} @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/limits [get]

func (h *SecretHandler) GetLink(c *gin.Context)

GetLink handles GET /api/v1/secrets/:label/link @Summary Get proxy link @Description Generate the Telegram proxy link for a given secret label @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/link [get]

func (*SecretHandler) GetQR

func (h *SecretHandler) GetQR(c *gin.Context)

GetQR handles GET /api/v1/secrets/:label/qr @Summary Get QR code @Description Generate a PNG QR code image for the proxy link associated with the secret @Tags secrets @Produce image/png @Param label path string true "Secret label" @Param size query int false "QR code image size in pixels (64-2048, default 256)" @Success 200 {file} binary @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/qr [get]

func (*SecretHandler) Import added in v0.0.10

func (h *SecretHandler) Import(c *gin.Context)

Import handles POST /api/v1/secrets/import @Summary Import secrets @Description Import multiple secrets at once @Tags secrets @Accept json @Produce json @Param body body importSecretsRequest true "Secrets to import" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/import [post]

func (*SecretHandler) List

func (h *SecretHandler) List(c *gin.Context)

List handles GET /api/v1/secrets @Summary List secrets @Description Retrieve all registered secrets @Tags secrets @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets [get]

func (*SecretHandler) ListByTag added in v0.0.10

func (h *SecretHandler) ListByTag(c *gin.Context)

ListByTag handles GET /api/v1/secrets/by-tag/:tag @Summary List secrets by tag @Description Retrieve all secrets that have the specified tag @Tags secrets @Produce json @Param tag path string true "Tag name" @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/by-tag/{tag} [get]

func (*SecretHandler) ListTags added in v0.0.10

func (h *SecretHandler) ListTags(c *gin.Context)

ListTags handles GET /api/v1/secrets/tags @Summary List all tags @Description Retrieve all unique tags assigned to secrets @Tags secrets @Produce json @Success 200 {object} map[string][]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/tags [get]

func (*SecretHandler) Remove

func (h *SecretHandler) Remove(c *gin.Context)

Remove handles DELETE /api/v1/secrets/:label @Summary Remove a secret @Description Delete a secret by its label. Use force=true to remove even if in use. @Tags secrets @Produce json @Param label path string true "Secret label" @Param force query bool false "Force removal" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label} [delete]

func (*SecretHandler) Rename added in v0.0.10

func (h *SecretHandler) Rename(c *gin.Context)

Rename handles PUT /api/v1/secrets/:label/rename @Summary Rename a secret @Description Change the label of an existing secret @Tags secrets @Accept json @Produce json @Param label path string true "Current secret label" @Param body body renameSecretRequest true "New label" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/rename [put]

func (*SecretHandler) ResetAllTraffic

func (h *SecretHandler) ResetAllTraffic(c *gin.Context)

ResetAllTraffic handles POST /api/v1/secrets/reset-traffic @Summary Reset all traffic @Description Reset traffic counters for all secrets @Tags secrets @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/reset-traffic [post]

func (*SecretHandler) ResetTraffic

func (h *SecretHandler) ResetTraffic(c *gin.Context)

ResetTraffic handles POST /api/v1/secrets/:label/reset-traffic @Summary Reset secret traffic @Description Reset traffic counters for a specific secret @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/reset-traffic [post]

func (*SecretHandler) Rotate

func (h *SecretHandler) Rotate(c *gin.Context)

Rotate handles POST /api/v1/secrets/:label/rotate @Summary Rotate a secret @Description Generate a new secret value for the given label @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/rotate [post]

func (*SecretHandler) Search added in v0.0.10

func (h *SecretHandler) Search(c *gin.Context)

Search handles GET /api/v1/secrets/search @Summary Search secrets @Description Search secrets by label or notes @Tags secrets @Produce json @Param q query string true "Search query" @Success 200 {array} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/search [get]

func (*SecretHandler) SetContainerSvc added in v0.1.0

func (h *SecretHandler) SetContainerSvc(svc *service.ContainerService)

SetContainerSvc sets the container service for revalidation after secret changes.

func (*SecretHandler) SetLimits

func (h *SecretHandler) SetLimits(c *gin.Context)

SetLimits handles PUT /api/v1/secrets/:label/limits @Summary Set secret limits @Description Configure connection, IP, quota, and expiry limits for a secret @Tags secrets @Accept json @Produce json @Param label path string true "Secret label" @Param body body setLimitsRequest true "Limits configuration" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/limits [put]

func (*SecretHandler) SetTags added in v0.0.10

func (h *SecretHandler) SetTags(c *gin.Context)

SetTags handles PUT /api/v1/secrets/:label/tags @Summary Set secret tags @Description Set tags as JSON array for a secret @Tags secrets @Accept json @Produce json @Param label path string true "Secret label" @Param body body setTagsRequest true "Tags" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/tags [put]

func (*SecretHandler) Toggle

func (h *SecretHandler) Toggle(c *gin.Context)

Toggle handles PUT /api/v1/secrets/:label/toggle @Summary Toggle a secret @Description Enable or disable a secret by label @Tags secrets @Accept json @Produce json @Param label path string true "Secret label" @Param body body secretToggleRequest true "Enabled state" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/toggle [put]

func (*SecretHandler) Top added in v0.0.10

func (h *SecretHandler) Top(c *gin.Context)

Top handles GET /api/v1/secrets/top @Summary Top secrets by traffic @Description Get secrets ordered by total traffic usage @Tags secrets @Produce json @Param limit query int false "Number of results (default 10)" @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /secrets/top [get]

func (*SecretHandler) Unarchive added in v0.0.10

func (h *SecretHandler) Unarchive(c *gin.Context)

Unarchive handles POST /api/v1/secrets/:label/unarchive @Summary Unarchive a secret @Description Restore an archived secret to normal listings @Tags secrets @Produce json @Param label path string true "Secret label" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/unarchive [post]

func (*SecretHandler) UpdateNotes

func (h *SecretHandler) UpdateNotes(c *gin.Context)

UpdateNotes handles PUT /api/v1/secrets/:label/notes @Summary Update secret notes @Description Set or update the notes field for a secret @Tags secrets @Accept json @Produce json @Param label path string true "Secret label" @Param body body updateNotesRequest true "Notes content" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /secrets/{label}/notes [put]

type SystemHandler

type SystemHandler struct {
	// contains filtered or unexported fields
}

SystemHandler handles system-level endpoints.

func NewSystemHandler

func NewSystemHandler() *SystemHandler

NewSystemHandler creates a new SystemHandler.

func (*SystemHandler) GetOS

func (h *SystemHandler) GetOS(c *gin.Context)

GetOS handles GET /api/v1/system/os @Summary Detect operating system @Description Returns detected OS information including distribution, version, and architecture @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /system/os [get]

func (*SystemHandler) GetResources added in v0.0.10

func (h *SystemHandler) GetResources(c *gin.Context)

GetResources handles GET /api/v1/system/resources @Summary Get system resources @Description Returns current CPU, memory, disk, and load information @Tags system @Accept json @Produce json @Success 200 {object} model.SystemResources @Security BearerAuth @Router /system/resources [get]

func (*SystemHandler) InstallService

func (h *SystemHandler) InstallService(c *gin.Context)

InstallService handles POST /api/v1/system/service/install @Summary Install systemd service @Description Installs and enables the PopuGate systemd service unit @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /system/service/install [post]

func (*SystemHandler) ReloadService

func (h *SystemHandler) ReloadService(c *gin.Context)

ReloadService handles POST /api/v1/system/service/reload @Summary Reload service @Description Sends a reload signal to the PopuGate systemd service @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /system/service/reload [post]

func (*SystemHandler) RestartService

func (h *SystemHandler) RestartService(c *gin.Context)

RestartService handles POST /api/v1/system/service/restart @Summary Restart service @Description Restarts the PopuGate systemd service @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /system/service/restart [post]

func (*SystemHandler) ServiceStatus

func (h *SystemHandler) ServiceStatus(c *gin.Context)

ServiceStatus handles GET /api/v1/system/service/status @Summary Service status @Description Returns the current systemd service status (running, stopped, etc.) @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /system/service/status [get]

func (*SystemHandler) SetNotify added in v0.0.10

func (h *SystemHandler) SetNotify(fn service.NotifyFunc)

SetNotify sets the notification function for alerting.

func (*SystemHandler) StreamResources added in v0.0.10

func (h *SystemHandler) StreamResources(c *gin.Context)

StreamResources handles WebSocket connection for real-time resource updates.

func (*SystemHandler) UninstallService

func (h *SystemHandler) UninstallService(c *gin.Context)

UninstallService handles DELETE /api/v1/system/service/uninstall @Summary Uninstall systemd service @Description Stops and removes the PopuGate systemd service unit @Tags system @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /system/service/uninstall [delete]

type TelemtUpdateHandler added in v0.0.7

type TelemtUpdateHandler struct {
	// contains filtered or unexported fields
}

TelemtUpdateHandler handles telemt engine update endpoints.

func NewTelemtUpdateHandler added in v0.0.7

func NewTelemtUpdateHandler(
	telemtUpdateSvc *service.TelemtUpdateService,
	telemtCfg *service.DBTelemtConfig,
	dockerSvc *service.DockerService,
) *TelemtUpdateHandler

NewTelemtUpdateHandler creates a new TelemtUpdateHandler.

func (*TelemtUpdateHandler) Apply added in v0.0.7

func (h *TelemtUpdateHandler) Apply(c *gin.Context)

Apply handles POST /api/v1/engine/update @Summary Apply engine update @Description Applies a telemt engine update by downloading and installing the specified version @Tags engine @Accept json @Produce json @Param body body object{version=string,commit=string} true "Version to apply" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /engine/update [post]

func (*TelemtUpdateHandler) CheckRemote added in v0.0.7

func (h *TelemtUpdateHandler) CheckRemote(c *gin.Context)

CheckRemote handles POST /api/v1/engine/check @Summary Check for engine updates @Description Checks remote source for new telemt engine releases and returns updated status @Tags engine @Accept json @Produce json @Success 200 {object} map[string]string @Failure 502 {object} map[string]string @Security BearerAuth @Router /engine/check [post]

func (*TelemtUpdateHandler) GetReleases added in v0.0.7

func (h *TelemtUpdateHandler) GetReleases(c *gin.Context)

GetReleases handles GET /api/v1/engine/releases @Summary List engine releases @Description Returns a list of available telemt engine releases from the remote source @Tags engine @Accept json @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /engine/releases [get]

func (*TelemtUpdateHandler) GetStatus added in v0.0.7

func (h *TelemtUpdateHandler) GetStatus(c *gin.Context)

GetStatus handles GET /api/v1/engine/update @Summary Engine update status @Description Returns the current telemt engine version, latest available version, and update availability @Tags engine @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /engine/update [get]

type TemplateHandler added in v0.0.10

type TemplateHandler struct {
	// contains filtered or unexported fields
}

TemplateHandler handles secret template endpoints.

func NewTemplateHandler added in v0.0.10

func NewTemplateHandler(templates *service.TemplateService) *TemplateHandler

NewTemplateHandler creates a new TemplateHandler.

func (*TemplateHandler) Apply added in v0.0.10

func (h *TemplateHandler) Apply(c *gin.Context)

Apply handles POST /api/v1/templates/:name/apply @Summary Apply template to secret @Description Apply a template's limits to an existing secret @Tags templates @Accept json @Produce json @Param name path string true "Template name" @Param body body applyTemplateRequest true "Secret label" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /templates/{name}/apply [post]

func (*TemplateHandler) Create added in v0.0.10

func (h *TemplateHandler) Create(c *gin.Context)

Create handles POST /api/v1/templates @Summary Create a template @Description Create a new secret template @Tags templates @Accept json @Produce json @Param body body createTemplateRequest true "Template" @Success 201 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /templates [post]

func (*TemplateHandler) Delete added in v0.0.10

func (h *TemplateHandler) Delete(c *gin.Context)

Delete handles DELETE /api/v1/templates/:name @Summary Delete a template @Description Delete a template by name @Tags templates @Produce json @Param name path string true "Template name" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /templates/{name} [delete]

func (*TemplateHandler) Get added in v0.0.10

func (h *TemplateHandler) Get(c *gin.Context)

Get handles GET /api/v1/templates/:name @Summary Get a template @Description Retrieve a single template by name @Tags templates @Produce json @Param name path string true "Template name" @Success 200 {object} object @Failure 404 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /templates/{name} [get]

func (*TemplateHandler) List added in v0.0.10

func (h *TemplateHandler) List(c *gin.Context)

List handles GET /api/v1/templates @Summary List templates @Description Retrieve all secret templates @Tags templates @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /templates [get]

type TrafficHandler

type TrafficHandler struct {
	// contains filtered or unexported fields
}

TrafficHandler handles traffic monitoring endpoints.

func NewTrafficHandler

func NewTrafficHandler(traffic *store.TrafficStore, settings *store.SettingsStore) *TrafficHandler

NewTrafficHandler creates a new TrafficHandler.

func (*TrafficHandler) Get

func (h *TrafficHandler) Get(c *gin.Context)

Get handles GET /api/v1/traffic @Summary Get traffic summary @Description Returns global traffic statistics (bytes in/out) and per-user traffic breakdown @Tags traffic @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /traffic [get]

func (*TrafficHandler) GetHistory added in v0.0.10

func (h *TrafficHandler) GetHistory(c *gin.Context)

GetHistory handles GET /api/v1/traffic/history @Summary Get traffic history @Description Returns historical traffic records with optional time range filtering and aggregation @Tags traffic @Accept json @Produce json @Param start query int false "Start timestamp (Unix epoch, default: 24h ago)" @Param end query int false "End timestamp (Unix epoch, default: now)" @Param label query string false "Filter by user label" @Param aggregate query string false "Aggregation mode: none, hour, or day (default: none)" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /traffic/history [get]

func (*TrafficHandler) GetLive

func (h *TrafficHandler) GetLive(c *gin.Context)

GetLive handles GET /api/v1/traffic/live @Summary Get live traffic metrics @Description Returns real-time connection metrics scraped from the telemt engine Prometheus endpoint @Tags traffic @Accept json @Produce json @Success 200 {object} map[string]string @Failure 503 {object} map[string]string @Security BearerAuth @Router /traffic/live [get]

func (*TrafficHandler) GetUser

func (h *TrafficHandler) GetUser(c *gin.Context)

GetUser handles GET /api/v1/traffic/:label @Summary Get user traffic @Description Returns traffic statistics for a specific user identified by label @Tags traffic @Accept json @Produce json @Param label path string true "User label" @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /traffic/{label} [get]

func (*TrafficHandler) SetTrafficService

func (h *TrafficHandler) SetTrafficService(svc *service.TrafficService)

SetTrafficService sets the traffic service for live metrics.

type UpdateHandler

type UpdateHandler struct {
	// contains filtered or unexported fields
}

UpdateHandler handles auto-update endpoints.

func NewUpdateHandler

func NewUpdateHandler(svc *service.UpdateService) *UpdateHandler

NewUpdateHandler creates a new UpdateHandler.

func (*UpdateHandler) Apply

func (h *UpdateHandler) Apply(c *gin.Context)

Apply handles POST /api/v1/update/apply @Summary Apply PopuGate update @Description Downloads and installs the latest PopuGate update, then triggers a restart. In binary mode: replaces the binary. In Docker mode: pulls a new image and recreates the container. @Tags update @Accept json @Produce json @Success 200 {object} map[string]string @Failure 500 {object} map[string]string @Security BearerAuth @Router /update/apply [post]

func (*UpdateHandler) Check

func (h *UpdateHandler) Check(c *gin.Context)

Check handles GET /api/v1/update/check @Summary Check for PopuGate updates @Description Checks remote source for new PopuGate releases and returns update availability status @Tags update @Accept json @Produce json @Success 200 {object} map[string]string @Security BearerAuth @Router /update/check [get]

type UpstreamHandler

type UpstreamHandler struct {
	// contains filtered or unexported fields
}

UpstreamHandler handles upstream endpoints.

func NewUpstreamHandler

func NewUpstreamHandler(upstreams *service.UpstreamService) *UpstreamHandler

NewUpstreamHandler creates a new UpstreamHandler.

func (*UpstreamHandler) Add

func (h *UpstreamHandler) Add(c *gin.Context)

Add handles POST /api/v1/upstreams @Summary Add an upstream @Description Create a new upstream proxy configuration @Tags upstreams @Accept json @Produce json @Param body body addUpstreamRequest true "Upstream to add" @Success 201 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams [post]

func (*UpstreamHandler) Interfaces added in v0.0.4

func (h *UpstreamHandler) Interfaces(c *gin.Context)

Interfaces handles GET /api/v1/upstreams/interfaces @Summary List network interfaces @Description Retrieve the host's active network interfaces and their addresses @Tags upstreams @Produce json @Success 200 {array} netIface @Failure 500 {object} map[string]string @Security BearerAuth @Router /upstreams/interfaces [get]

func (*UpstreamHandler) List

func (h *UpstreamHandler) List(c *gin.Context)

List handles GET /api/v1/upstreams @Summary List upstreams @Description Retrieve all configured upstream proxies @Tags upstreams @Produce json @Success 200 {array} object @Failure 500 {object} map[string]string @Security BearerAuth @Router /upstreams [get]

func (*UpstreamHandler) Remove

func (h *UpstreamHandler) Remove(c *gin.Context)

Remove handles DELETE /api/v1/upstreams/:name @Summary Remove an upstream @Description Delete an upstream proxy configuration by name @Tags upstreams @Produce json @Param name path string true "Upstream name" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams/{name} [delete]

func (*UpstreamHandler) Test

func (h *UpstreamHandler) Test(c *gin.Context)

Test handles POST /api/v1/upstreams/:name/test @Summary Test an upstream @Description Run a connectivity test against an existing upstream by name @Tags upstreams @Produce json @Param name path string true "Upstream name" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams/{name}/test [post]

func (*UpstreamHandler) TestConfig added in v0.0.4

func (h *UpstreamHandler) TestConfig(c *gin.Context)

TestConfig handles POST /api/v1/upstreams/test @Summary Test upstream configuration @Description Test raw upstream configuration without saving it @Tags upstreams @Accept json @Produce json @Param body body testUpstreamRequest true "Upstream configuration to test" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams/test [post]

func (*UpstreamHandler) Toggle

func (h *UpstreamHandler) Toggle(c *gin.Context)

Toggle handles PUT /api/v1/upstreams/:name/toggle @Summary Toggle an upstream @Description Enable or disable an upstream proxy by name @Tags upstreams @Accept json @Produce json @Param name path string true "Upstream name" @Param body body upstreamToggleRequest true "Enabled state" @Success 200 {object} map[string]string @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams/{name}/toggle [put]

func (*UpstreamHandler) Update added in v0.0.7

func (h *UpstreamHandler) Update(c *gin.Context)

Update handles PUT /api/v1/upstreams/:name @Summary Update an upstream @Description Update the configuration of an existing upstream proxy @Tags upstreams @Accept json @Produce json @Param name path string true "Upstream name" @Param body body updateUpstreamRequest true "Upstream configuration" @Success 200 {object} object @Failure 400 {object} map[string]string @Security BearerAuth @Router /upstreams/{name} [put]

type WSHandler

type WSHandler struct {
	// contains filtered or unexported fields
}

WSHandler handles WebSocket live metrics streaming.

func NewWSHandler

func NewWSHandler(traffic *service.TrafficService, telemt *service.TelemtUpdateService) *WSHandler

NewWSHandler creates a new WSHandler.

func (*WSHandler) Handle

func (h *WSHandler) Handle(c *gin.Context)

Handle upgrades to WebSocket and streams live metrics every 2 seconds.

func (*WSHandler) HandleEngineUpdate added in v0.0.10

func (h *WSHandler) HandleEngineUpdate(c *gin.Context)

HandleEngineUpdate upgrades to WebSocket and streams engine update status.

Jump to

Keyboard shortcuts

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