fix converting hostPort
This commit is contained in:
parent
2bd59fe847
commit
9091c1cd41
1 changed files with 13 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ type VncConfig struct {
|
|||
}
|
||||
|
||||
func (v *VncConfig) GetVncUrl() string {
|
||||
return fmt.Sprintf("wss://%s:%s/api2/json/nodes/%s/qemu/%s/vncwebsocket?port=%s&vncticket=%s", v.NodeUrl, v.NodePort, v.NodeName, v.VmID, v.VncProxyPort, url.QueryEscape(v.VncProxyTicket))
|
||||
return fmt.Sprintf("wss://%s:%s/api2/json/nodes/%s/qemu/%s/vncwebsocket?port=%s&vncticket=%s", v.NodeUrl, convertToString(v.NodePort), v.NodeName, v.VmID, v.VncProxyPort, url.QueryEscape(v.VncProxyTicket))
|
||||
}
|
||||
|
||||
func (v *VncConfig) GenerateApiTicket() {
|
||||
|
|
@ -33,7 +33,7 @@ func (v *VncConfig) GenerateApiTicket() {
|
|||
if os.Getenv("PVE_IGNORE_SSL") == "true" {
|
||||
client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
||||
}
|
||||
client.SetBaseURL(fmt.Sprintf("https://%s:%s/", v.NodeUrl, v.NodePort))
|
||||
client.SetBaseURL(fmt.Sprintf("https://%s:%s/", v.NodeUrl, convertToString(v.NodePort)))
|
||||
resp, err := client.R().SetFormData(map[string]string{
|
||||
"username": v.NodeUser,
|
||||
"password": v.NodePassword,
|
||||
|
|
@ -45,3 +45,14 @@ func (v *VncConfig) GenerateApiTicket() {
|
|||
v.ApiTicket = resp.Result().(*PveLoginResponse).Data.Ticket
|
||||
v.CSRFPreventionToken = resp.Result().(*PveLoginResponse).Data.CSRFPreventionToken
|
||||
}
|
||||
|
||||
func convertToString(v any) string {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
return v
|
||||
case float64:
|
||||
return fmt.Sprintf("%.0f", v) // Convert int to string
|
||||
default:
|
||||
return "unsupported type"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue