api

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 22 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)

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