Files
1Panel/core/utils/mcp/website_proxy.go
T
蘭 d32cbb40f6 feat(mcp): add Panel MCP task configuration and website binding structures (#14229)
* feat(mcp): add Panel MCP task configuration and website binding structures

* fix(mcp): correct variable assignment in mcpWebsiteDomain function
2026-10-28 14:04:38 +08:00

26 lines
635 B
Go

package mcp
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"errors"
"github.com/google/uuid"
)
const (
WebsiteProxyKeyHeader = "X-Panel-MCP-Website-Key"
WebsiteProxyPeerHeader = "X-Panel-MCP-Website-Peer"
)
func WebsiteProxyKey(masterKey, bindingID string) (string, error) {
id, err := uuid.Parse(bindingID)
if masterKey == "" || err != nil || id == uuid.Nil || id.String() != bindingID {
return "", errors.New("MCP website proxy identity is unavailable")
}
mac := hmac.New(sha256.New, []byte(masterKey))
mac.Write([]byte("1panel-mcp-website:v1:" + bindingID))
return hex.EncodeToString(mac.Sum(nil)), nil
}