feat: update

This commit is contained in:
2024-11-09 14:37:09 +00:00
parent 3ef0c93c8f
commit b50abccae0
26 changed files with 728 additions and 254 deletions
+24
View File
@@ -18,6 +18,7 @@ type Host struct {
Label string `json:"label"`
Host string `json:"host" gorm:"type:varchar(64)"`
Port int `json:"port" gorm:"type:smallint"`
OS string `json:"os" gorm:"type:varchar(32)"`
Metadata datatypes.JSONMap `json:"metadata"`
ParentID *string `json:"parentId" gorm:"index:hosts_parent_id_idx;type:varchar(26)"`
@@ -30,3 +31,26 @@ type Host struct {
Timestamps
SoftDeletes
}
type HostDecrypted struct {
Host
Key map[string]interface{}
AltKey map[string]interface{}
}
func (h *Host) DecryptKeys() (*HostDecrypted, error) {
res := &HostDecrypted{Host: *h}
if h.Key.Data != "" {
if err := h.Key.DecryptData(&res.Key); err != nil {
return nil, err
}
}
if h.AltKey.Data != "" {
if err := h.AltKey.DecryptData(&res.AltKey); err != nil {
return nil, err
}
}
return res, nil
}
+1
View File
@@ -8,6 +8,7 @@ import (
const (
KeychainTypeUserPass = "user"
KeychainTypePVE = "pve"
KeychainTypeRSA = "rsa"
KeychainTypeCertificate = "cert"
)