mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-12-03 18:43:15 +00:00
load key from file
This commit is contained in:
@@ -20,7 +20,8 @@ rustdesk:
|
||||
id-server: "192.168.1.66:21116"
|
||||
relay-server: "192.168.1.66:21117"
|
||||
api-server: "http://127.0.0.1:21114"
|
||||
key: "123456789"
|
||||
key: ""
|
||||
key-file: "./conf/data/id_ed25519.pub"
|
||||
personal: 1
|
||||
logger:
|
||||
path: "./runtime/log.txt"
|
||||
|
||||
@@ -63,6 +63,7 @@ func Init(rowVal interface{}) *viper.Viper {
|
||||
if err := v.Unmarshal(rowVal); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
LoadKeyFile(&rowVal.(*Config).Rustdesk)
|
||||
return v
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,30 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type Rustdesk struct {
|
||||
IdServer string `mapstructure:"id-server"`
|
||||
RelayServer string `mapstructure:"relay-server"`
|
||||
ApiServer string `mapstructure:"api-server"`
|
||||
Key string `mapstructure:"key"`
|
||||
KeyFile string `mapstructure:"key-file"`
|
||||
Personal int `mapstructure:"personal"`
|
||||
}
|
||||
|
||||
func LoadKeyFile(rustdesk *Rustdesk) {
|
||||
// Load key file
|
||||
if rustdesk.Key != "" {
|
||||
return
|
||||
}
|
||||
if rustdesk.KeyFile != "" {
|
||||
// Load key from file
|
||||
b, err := os.ReadFile(rustdesk.KeyFile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
rustdesk.Key = string(b)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user