api

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: GPL-3.0 Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseSessionOptions added in v1.8.2

func BaseSessionOptions(maxAgeMinutes int) sessions.Options

BaseSessionOptions are the cookie attributes that do not depend on the request, so the session store and every login share one definition.

HttpOnly keeps the session out of reach of script. The panel renders operator-supplied strings in a number of places, and without it any one of them turning into an XSS hands the session over outright. Nothing in this frontend reads the cookie -- the router has never consulted it, unlike upstream's -- so this costs nothing here.

SameSite has nothing to do with TLS and is safe in HTTP mode too. It is the half of the CSRF answer that does not depend on the panel checking anything: the browser refuses to attach the session to a cross-site POST, which is the shape of the attack.

Lax rather than Strict. The two differ only on a top-level navigation the user performed themselves -- following a link to the panel from a chat message, a wiki, an email -- and Strict withholds the cookie there too, so the operator lands on the login form despite a live session and has to reload to get past it. That reads as "the panel logged me out" and buys nothing: Lax already withholds the cookie from every cross-site POST, and middleware.SameOrigin answers the rest.

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)

func SetLoginUser

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

func SetMaxAge

func SetMaxAge(c *gin.Context) error

func WsHandler added in v1.6.3

func WsHandler(c *gin.Context)

WsHandler upgrades the panel's push channel. It is registered directly on the engine as a static sibling of the api group — putting it inside the group would conflict with the GET /:getAction wildcard and panic at startup.

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) *APIv2Handler

func (*APIv2Handler) ReloadTokens

func (a *APIv2Handler) ReloadTokens()

type ApiService

func (*ApiService) AddToken

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

func (*ApiService) AdoptInbounds added in v1.6.0

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

func (*ApiService) ApplyClusterBans added in v1.8.3

func (a *ApiService) ApplyClusterBans(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) CheckNginxProxy added in v1.6.2

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

CheckNginxProxy is SyncNginxProxy's read-only twin: same form, same questions, but it writes nothing and never reloads nginx. The frontend calls it in the two places where writing is not an option — before saving while the proxy is already on, and when the settings page loads, to report drift. See service.CheckVhosts.

func (*ApiService) CloseSessions added in v1.9.0

func (a *ApiService) CloseSessions(c *gin.Context, cluster bool)

CloseSessions disconnects one client without disabling it. cluster has the same meaning as for GetSessions.

func (*ApiService) DeleteCert added in v1.6.1

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

DeleteCert 删除一张证书。面板或订阅正在用它时拒绝——那两个服务重启时会去读这两个 文件,删掉就起不来了,而此时用户多半已经离开这个页面,很难把两件事联系起来。

手动登记的只从库里移除登记,绝不碰文件本身:那是用户自己的证书,多半还被别的服务 用着。只有 acme.sh 托管的才走 RemoveCert(停止续期 + 删它自己产出的副本)。

func (*ApiService) DeleteToken

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

func (*ApiService) DetectNginx added in v1.4.7

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

func (*ApiService) GetCertPing added in v1.5.4

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

func (*ApiService) GetCerts added in v1.6.1

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

GetCerts 列出「域名与证书」页面上的全部证书:acme.sh 托管的 + 手动登记的。

func (*ApiService) GetCheckOutbound

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

func (*ApiService) GetClusterIps added in v1.8.3

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

func (*ApiService) GetClusterOnlines added in v1.8.3

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

func (*ApiService) GetDb

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

func (*ApiService) GetKeypairs

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

func (*ApiService) GetLogs

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

func (*ApiService) GetNodeInbounds added in v1.6.0

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

func (*ApiService) GetOnlineIps added in v1.7.0

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

GetOnlineIps lists one client's live source IPs. Kept apart from GetOnlines rather than added to it as a query parameter: that endpoint returns three tag lists, and switching its shape on a parameter would break every caller that does not pass one.

func (*ApiService) GetOnlines

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

func (*ApiService) GetSessions added in v1.9.0

func (a *ApiService) GetSessions(c *gin.Context, cluster bool)

GetSessions lists live connections (resource=user|inbound|outbound, tag). cluster adds what the nodes a client is online on hold for it, which only the SPA asks for: apiv2 answers with this panel's own list, so a node never hands its master a list that already includes the master's.

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) GetUsers

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

func (*ApiService) ImportDb

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

func (*ApiService) IssueCert added in v1.4.7

func (a *ApiService) IssueCert(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) ReconcileNode added in v1.6.0

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

func (*ApiService) ResetTraffic added in v1.5.4

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

func (*ApiService) RestartApp

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

func (*ApiService) RestartSb

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

func (*ApiService) Save

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

Save handles POST api/save. fanout triggers an immediate node reconcile for client/inbound changes (v1 always; v2 with sync=true). It affects latency only — the hourly ReconcileAllOnline pushes state regardless — and is not what prevents mutual-master ping-pong: a pushed client references the receiving panel's own inbounds, so expectedClients' node_id scoping keeps it out of every outgoing push. hostname feeds generated links; callers pick the canonical value (v2 prefers the configured web domain over the request Host).

func (*ApiService) SaveManualCert added in v1.6.1

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

SaveManualCert 登记或改写一份自带的证书(Cloudflare 源证书、公司内部 CA 签发的 那类)。acme.sh 已经在管这个域名时拒绝:两份记录指向同一域名,页面上说不清到底 哪份在生效,而且用户多半是想改路径、其实该去续期。

func (*ApiService) SetMaintenance added in v1.8.2

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

SetMaintenance stops the core and keeps it stopped, or puts it back.

The two directions answer with different messages rather than one "maintenance": the panel turns the message into the success toast, and a toast that reads the same whichever way the switch went is no confirmation at all.

func (*ApiService) SubConvert

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

func (*ApiService) SyncNginxProxy added in v1.6.1

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

SyncNginxProxy syncs the auto-generated reverse-proxy configs with the current form values. The frontend calls it before saving when the proxy is switched ON or adjusted: only once this succeeds is it safe to move the panel/subscription to plaintext HTTP. Switching the panel side OFF never comes through here — see app.syncNginxProxy for why that has to wait until after the restart.

func (*ApiService) TestAcme

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

func (*ApiService) TestNode added in v1.6.0

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

func (*ApiService) TestNotify added in v1.8.0

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

TestNotify sends one message through every configured notification channel.

It answers with the failure text rather than a translated action name, following TestAcme: "telegram: chat not found" is the entire value of pressing the button, and an i18n key cannot carry it.

It tests what is saved, not what is on screen. The credentials are write-only (GetAllSetting strips them), so the form has no token to submit.

func (*ApiService) TwoFaDisable added in v1.7.1

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

func (*ApiService) TwoFaEnable added in v1.7.1

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

func (*ApiService) TwoFaSetup added in v1.7.1

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

TwoFaSetup mints a candidate secret and returns the otpauth:// URI the QR code encodes. Nothing is stored yet: the secret only becomes the account's once TwoFaEnable has seen a working code from it, so an enrolment abandoned halfway leaves no trace and cannot lock anyone out.

func (*ApiService) UpdateInfo added in v1.5.6

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

func (*ApiService) UpdatePanel added in v1.5.6

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

func (*ApiService) UpdateStatus added in v1.5.6

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

type Msg

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

type TokenInMemory

type TokenInMemory struct {
	Token    string
	Expiry   int64
	Username string
}

Jump to

Keyboard shortcuts

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