api

package
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearSession

func ClearSession(c *gin.Context)

func GetLoginUser

func GetLoginUser(c *gin.Context) string

func IsLogin

func IsLogin(c *gin.Context) bool

func NewAPIHandler

func NewAPIHandler(g *gin.RouterGroup, a2 *APIv2Handler, options ...Option)

func RequestIsHTTPS added in v1.5.7

func RequestIsHTTPS(c *gin.Context) bool

RequestIsHTTPS reports whether the request arrived over HTTPS, trusting X-Forwarded-Proto only when the peer is a configured trusted proxy. Exported so the security-headers middleware can reuse this gated check for its HSTS decision (a spoofed X-Forwarded-Proto from an untrusted client must not trigger HSTS).

func ResetSessionCSRF

func ResetSessionCSRF(s sessions.Session)

func SaveConnContext added in v1.5.6

func SaveConnContext(ctx context.Context, conn net.Conn) context.Context

SaveConnContext stashes the accepted connection into its context. Wire it as http.Server.ConnContext so the long-running import handlers can reach the raw net.Conn.

This indirection is required: the global gzip middleware replaces c.Writer with a wrapper that embeds the gin.ResponseWriter *interface* (which has no Unwrap method), so http.NewResponseController(c.Writer) cannot traverse to the connection and SetWriteDeadline silently returns ErrNotSupported. Without the raw conn, the 30s WriteTimeout would still sever a slow import mid-write, which the browser surfaces as "Network Error".

func SetLoginUser

func SetLoginUser(c *gin.Context, userName string, maxAge int, sessionGeneration string) error

func WithPingInterval

func WithPingInterval(interval time.Duration) realtimeOption

func WithPingTimeout

func WithPingTimeout(timeout time.Duration) realtimeOption

Types

type APIHandler

type APIHandler struct {
	ApiService
	// contains filtered or unexported fields
}

type APIv2Handler

type APIv2Handler struct {
	ApiService
	// contains filtered or unexported fields
}

func NewAPIv2Handler

func NewAPIv2Handler(g *gin.RouterGroup, options ...Option) *APIv2Handler

func (*APIv2Handler) ReloadTokens

func (a *APIv2Handler) ReloadTokens()

type ApiService

func NewApiService

func NewApiService(options ...Option) ApiService

func (*ApiService) AddAdmin added in v1.5.6

func (a *ApiService) AddAdmin(c *gin.Context)

func (*ApiService) AddToken

func (a *ApiService) AddToken(c *gin.Context)

func (*ApiService) BackupToTelegram

func (a *ApiService) BackupToTelegram(c *gin.Context)

func (*ApiService) ChangePass

func (a *ApiService) ChangePass(c *gin.Context)

func (*ApiService) CheckChanges

func (a *ApiService) CheckChanges(c *gin.Context)

func (*ApiService) CheckOutbounds

func (a *ApiService) CheckOutbounds(c *gin.Context)

func (*ApiService) ClearClientIPHistory

func (a *ApiService) ClearClientIPHistory(c *gin.Context)

func (*ApiService) DeleteAdmin added in v1.5.6

func (a *ApiService) DeleteAdmin(c *gin.Context)

func (*ApiService) DeleteToken

func (a *ApiService) DeleteToken(c *gin.Context)

func (*ApiService) DetectTelegramChat added in v1.5.11

func (a *ApiService) DetectTelegramChat(c *gin.Context)

func (*ApiService) DiagnoseClient added in v1.5.8

func (a *ApiService) DiagnoseClient(c *gin.Context)

func (*ApiService) GetCSRF

func (a *ApiService) GetCSRF(c *gin.Context)

func (*ApiService) GetCheckOutbound

func (a *ApiService) GetCheckOutbound(c *gin.Context)

func (*ApiService) GetClientIPHistory

func (a *ApiService) GetClientIPHistory(c *gin.Context)

func (*ApiService) GetCoreHistory

func (a *ApiService) GetCoreHistory(c *gin.Context)

func (*ApiService) GetDb

func (a *ApiService) GetDb(c *gin.Context)

func (*ApiService) GetFailoverStatus added in v1.5.9

func (a *ApiService) GetFailoverStatus(c *gin.Context)

GetFailoverStatus returns every failover group's live active member plus per-member health, for the panel's active-member display.

func (*ApiService) GetKeypairs

func (a *ApiService) GetKeypairs(c *gin.Context)

func (*ApiService) GetLogs

func (a *ApiService) GetLogs(c *gin.Context)

func (*ApiService) GetObservabilityHistory

func (a *ApiService) GetObservabilityHistory(c *gin.Context)

func (*ApiService) GetOnlines

func (a *ApiService) GetOnlines(c *gin.Context)

func (*ApiService) GetSecurityAudit

func (a *ApiService) GetSecurityAudit(c *gin.Context)

func (*ApiService) GetSettings

func (a *ApiService) GetSettings(c *gin.Context)

func (*ApiService) GetSingboxConfig

func (a *ApiService) GetSingboxConfig(c *gin.Context)

func (*ApiService) GetStats

func (a *ApiService) GetStats(c *gin.Context)

func (*ApiService) GetStatus

func (a *ApiService) GetStatus(c *gin.Context)

func (*ApiService) GetTokens

func (a *ApiService) GetTokens(c *gin.Context)

func (*ApiService) GetTrafficStats added in v1.5.10

func (a *ApiService) GetTrafficStats(c *gin.Context)

func (*ApiService) GetUsers

func (a *ApiService) GetUsers(c *gin.Context)

func (*ApiService) GetVersionInfo

func (a *ApiService) GetVersionInfo(c *gin.Context)

func (*ApiService) ImportDb

func (a *ApiService) ImportDb(c *gin.Context)

func (*ApiService) ImportXui

func (a *ApiService) ImportXui(c *gin.Context)

func (*ApiService) ImportXuiApply

func (a *ApiService) ImportXuiApply(c *gin.Context)

func (*ApiService) ImportXuiPlan

func (a *ApiService) ImportXuiPlan(c *gin.Context)

func (*ApiService) ImportXuiReports

func (a *ApiService) ImportXuiReports(c *gin.Context)

func (*ApiService) ImportXuiRollback

func (a *ApiService) ImportXuiRollback(c *gin.Context)

func (*ApiService) IssueCSRFToken

func (a *ApiService) IssueCSRFToken(c *gin.Context)

func (*ApiService) IssueWSToken

func (a *ApiService) IssueWSToken(c *gin.Context)

func (*ApiService) LinkConvert

func (a *ApiService) LinkConvert(c *gin.Context)

func (*ApiService) LoadData

func (a *ApiService) LoadData(c *gin.Context)

func (*ApiService) LoadPartialData

func (a *ApiService) LoadPartialData(c *gin.Context, objs []string) error

func (*ApiService) LoadTokens

func (a *ApiService) LoadTokens() ([]byte, error)

func (*ApiService) Login

func (a *ApiService) Login(c *gin.Context)

func (*ApiService) Logout

func (a *ApiService) Logout(c *gin.Context)

func (*ApiService) LogoutAllAdmins

func (a *ApiService) LogoutAllAdmins(c *gin.Context)

func (*ApiService) RealtimeWS

func (a *ApiService) RealtimeWS(c *gin.Context)

func (*ApiService) RealtimeWSWithOptions

func (a *ApiService) RealtimeWSWithOptions(options ...realtimeOption) gin.HandlerFunc

func (*ApiService) RestartApp

func (a *ApiService) RestartApp(c *gin.Context)

func (*ApiService) RestartSb

func (a *ApiService) RestartSb(c *gin.Context)

func (*ApiService) RotateSubSecret

func (a *ApiService) RotateSubSecret(c *gin.Context)

func (*ApiService) RunDoctor added in v1.5.8

func (a *ApiService) RunDoctor(c *gin.Context)

func (*ApiService) RunTelegramBackup

func (a *ApiService) RunTelegramBackup(c *gin.Context)

func (*ApiService) Save

func (a *ApiService) Save(c *gin.Context, loginUser string)

func (*ApiService) SetTokenEnabled

func (a *ApiService) SetTokenEnabled(c *gin.Context)

func (*ApiService) SubConvert

func (a *ApiService) SubConvert(c *gin.Context)

func (*ApiService) TestTelegram

func (a *ApiService) TestTelegram(c *gin.Context)

func (*ApiService) UpdateApply added in v1.5.9

func (a *ApiService) UpdateApply(c *gin.Context)

UpdateApply starts an update to the channel's available version. It enforces step-up re-authentication (SR-010) and a confirmed target version (FR-016). POST /api/update/apply.

func (*ApiService) UpdateCheck added in v1.5.9

func (a *ApiService) UpdateCheck(c *gin.Context)

UpdateCheck performs an explicit, rate-limited check for the selected channel and persists the channel choice. POST /api/update/check.

func (*ApiService) UpdateStatus added in v1.5.9

func (a *ApiService) UpdateStatus(c *gin.Context)

UpdateStatus reports current/available versions and job state without a forced network call (uses the cache). GET /api/update/status.

type Msg

type Msg struct {
	Success bool        `json:"success"`
	Msg     string      `json:"msg"`
	Obj     interface{} `json:"obj"`
}

type Option

type Option func(*ApiService)

func WithRuntime

func WithRuntime(runtime *service.Runtime) Option

type TokenInMemory

type TokenInMemory struct {
	ID          uint   `json:"id"`
	TokenHash   string `json:"tokenHash"`
	TokenPrefix string `json:"tokenPrefix"`
	Scope       string `json:"scope"`
	Enabled     bool   `json:"enabled"`
	Expiry      int64  `json:"expiry"`
	Username    string `json:"username"`
}

Jump to

Keyboard shortcuts

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