fix: implement CloseByUUID and move v1 token from URL to POST body
CI / Test (push) Has been cancelled
CI / Build (amd64, linux) (push) Has been cancelled
CI / Build (arm64, linux) (push) Has been cancelled
CI / Build & Push Docker Image (push) Has been cancelled
CI / Release (push) Has been cancelled

CloseByUUID: add UUID→connIDs reverse index so ban-user actually
tears down existing TCP connections immediately instead of no-op.

v1 token: change config/user fetches from GET (token in URL, leaks
to logs) to POST (token in JSON body). Panel routes updated to any().
This commit is contained in:
will
2026-08-14 10:59:05 +09:00
parent 0e1f97ee03
commit 4bab53f20f
2 changed files with 45 additions and 10 deletions
+6 -2
View File
@@ -200,6 +200,10 @@ func decodeWeakRaw(input map[string]interface{}, output interface{}) error {
// configPath returns the API path for config fetching.
// Machine mode uses the v2 endpoint; legacy mode uses the v1 UniProxy endpoint.
// fetchMethod returns POST for all API calls (token stays in body, not URL).
// v2 already used POST; v1 legacy endpoints need panel route update to match.
func (c *Client) fetchMethod() string { return "POST" }
func (c *Client) configPath() string {
if c.machineID > 0 {
return "/api/v2/server/config"
@@ -217,7 +221,7 @@ func (c *Client) userPath() string {
// GetConfig fetches node configuration. Returns nil if not modified (304).
func (c *Client) GetConfig() (*NodeConfig, error) {
resp, err := c.doRequest("GET", c.configPath(), nil, c.configETag)
resp, err := c.doRequest(c.fetchMethod(), c.configPath(), nil, c.configETag)
if err != nil {
return nil, fmt.Errorf("get config: %w", err)
}
@@ -255,7 +259,7 @@ func (c *Client) GetConfig() (*NodeConfig, error) {
// GetUsers fetches available users. Returns nil if not modified (304).
func (c *Client) GetUsers() ([]User, error) {
resp, err := c.doRequest("GET", c.userPath(), nil, c.userETag)
resp, err := c.doRequest(c.fetchMethod(), c.userPath(), nil, c.userETag)
if err != nil {
return nil, fmt.Errorf("get users: %w", err)
}