Go: add soft fingerprint framework (#17837)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-08-05 13:54:09 +08:00
committed by GitHub
parent f057544e31
commit 1e78789448
8 changed files with 191 additions and 0 deletions

View File

@@ -808,6 +808,27 @@ func (c *CLI) AdminSetLicenseCommand(cmd *Command) (ResponseIf, error) {
return HandleCommonDataResponse(resp, "set license")
}
func (c *CLI) AdminSetSoftFingerprintCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode || c.AdminServerClient.LoginToken == nil {
return nil, fmt.Errorf("this command is only allowed in ADMIN mode or already login")
}
softFingerprint, ok := cmd.Params["soft_fingerprint"].(string)
if !ok {
return nil, fmt.Errorf("soft_fingerprint not provided")
}
payload := map[string]interface{}{
"fingerprint": softFingerprint,
}
resp, err := c.AdminServerClient.Request("POST", "/admin/system/soft-fingerprint", "admin", nil, payload)
if err != nil {
return nil, fmt.Errorf("failed to set soft fingerprint: %w", err)
}
return HandleSimpleResponse(resp, "set soft fingerprint")
}
func (c *CLI) AdminSetLicenseConfigCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode || c.AdminServerClient.LoginToken == nil {
return nil, fmt.Errorf("this command is only allowed in ADMIN mode or already login")
@@ -1348,6 +1369,22 @@ func (c *CLI) AdminShowFingerprintCommand(cmd *Command) (ResponseIf, error) {
return HandleCommonDataResponse(resp, "show fingerprint")
}
// AdminShowSoftFingerprintCommand show soft fingerprint command (admin mode only)
func (c *CLI) AdminShowSoftFingerprintCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode || c.AdminServerClient.LoginToken == nil {
return nil, fmt.Errorf("this command is only allowed in ADMIN mode or already login")
}
apiURL := fmt.Sprintf("/admin/system/soft-fingerprint")
resp, err := c.AdminServerClient.Request("GET", apiURL, "admin", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to show soft fingerprint: %w", err)
}
return HandleCommonDataResponse(resp, "show soft fingerprint")
}
// AdminShowLicenseCommand show license command (admin mode only)
func (c *CLI) AdminShowLicenseCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode || c.AdminServerClient.LoginToken == nil {
@@ -2826,6 +2863,23 @@ func (c *CLI) AdminDeleteModelsCommand(cmd *Command) (ResponseIf, error) {
return HandleCommonDataResponse(resp, fmt.Sprintf("remove model %s", modelNames))
}
// AdminDeleteSoftFingerprintCommand delete soft fingerprint
func (c *CLI) AdminDeleteSoftFingerprintCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode || c.AdminServerClient.LoginToken == nil {
return nil, fmt.Errorf("this command is only allowed in ADMIN mode or already login")
}
apiURL := fmt.Sprintf("/admin/system/soft-fingerprint")
resp, err := c.AdminServerClient.Request("DELETE", apiURL, "admin", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to remove soft fingerprint: %w", err)
}
return HandleSimpleResponse(resp, fmt.Sprintf("remove soft fingerprint"))
}
func (c *CLI) AdminShowLogLevelCommand(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode {