Allow temperature proxy to authorize standalone nodes
This commit is contained in:
parent
7fa39467c0
commit
b807fe8773
1 changed files with 19 additions and 22 deletions
|
|
@ -113,11 +113,7 @@ func extractHostPart(raw string) string {
|
||||||
return strings.TrimSpace(host)
|
return strings.TrimSpace(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildAuthorizedNodeList(instance *config.PVEInstance) []authorizedNode {
|
func buildAuthorizedNodeList(instances []config.PVEInstance) []authorizedNode {
|
||||||
if instance == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes := make([]authorizedNode, 0)
|
nodes := make([]authorizedNode, 0)
|
||||||
seen := make(map[string]struct{})
|
seen := make(map[string]struct{})
|
||||||
add := func(name, ip string) {
|
add := func(name, ip string) {
|
||||||
|
|
@ -134,21 +130,23 @@ func buildAuthorizedNodeList(instance *config.PVEInstance) []authorizedNode {
|
||||||
nodes = append(nodes, authorizedNode{Name: name, IP: ip})
|
nodes = append(nodes, authorizedNode{Name: name, IP: ip})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base instance host/name
|
for i := range instances {
|
||||||
add(instance.Name, extractHostPart(instance.Host))
|
instance := &instances[i]
|
||||||
add(instance.Name, extractHostPart(instance.GuestURL))
|
add(instance.Name, extractHostPart(instance.Host))
|
||||||
|
add(instance.Name, extractHostPart(instance.GuestURL))
|
||||||
|
|
||||||
if instance.ClusterEndpoints != nil {
|
if instance.ClusterEndpoints != nil {
|
||||||
for _, ep := range instance.ClusterEndpoints {
|
for _, ep := range instance.ClusterEndpoints {
|
||||||
name := ep.NodeName
|
name := ep.NodeName
|
||||||
ip := ep.IP
|
ip := ep.IP
|
||||||
if ip == "" {
|
if ip == "" {
|
||||||
ip = extractHostPart(ep.Host)
|
ip = extractHostPart(ep.Host)
|
||||||
|
}
|
||||||
|
if name == "" {
|
||||||
|
name = ep.Host
|
||||||
|
}
|
||||||
|
add(name, ip)
|
||||||
}
|
}
|
||||||
if name == "" {
|
|
||||||
name = ep.Host
|
|
||||||
}
|
|
||||||
add(name, ip)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -292,7 +290,7 @@ func (h *TemperatureProxyHandlers) HandleRegister(w http.ResponseWriter, r *http
|
||||||
Str("pve_instance", matchedInstance.Name).
|
Str("pve_instance", matchedInstance.Name).
|
||||||
Msg("Temperature proxy registered successfully")
|
Msg("Temperature proxy registered successfully")
|
||||||
|
|
||||||
allowed := buildAuthorizedNodeList(matchedInstance)
|
allowed := buildAuthorizedNodeList(nodesConfig.PVEInstances)
|
||||||
resp := map[string]any{
|
resp := map[string]any{
|
||||||
"success": true,
|
"success": true,
|
||||||
"token": authToken,
|
"token": authToken,
|
||||||
|
|
@ -371,9 +369,8 @@ func (h *TemperatureProxyHandlers) HandleAuthorizedNodes(w http.ResponseWriter,
|
||||||
refreshInterval = refreshFromProxy
|
refreshInterval = refreshFromProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes := buildAuthorizedNodeList(matched)
|
nodes := buildAuthorizedNodeList(nodesConfig.PVEInstances)
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 && matched != nil {
|
||||||
// Always include at least the base instance name/host
|
|
||||||
nodes = append(nodes, authorizedNode{Name: matched.Name, IP: extractHostPart(matched.Host)})
|
nodes = append(nodes, authorizedNode{Name: matched.Name, IP: extractHostPart(matched.Host)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue