mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: update
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
const (
|
||||
KeychainTypeUserPass = "user"
|
||||
KeychainTypePVE = "pve"
|
||||
KeychainTypeRSA = "rsa"
|
||||
KeychainTypeCertificate = "cert"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user