refactor and testing
This commit is contained in:
parent
91c9de6e34
commit
c038774f2c
16 changed files with 445 additions and 195 deletions
37
agent/tactical/config/config_windows.go
Normal file
37
agent/tactical/config/config_windows.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func NewAgentConfig() *AgentConfig {
|
||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||
|
||||
if err != nil {
|
||||
return &AgentConfig{}
|
||||
}
|
||||
|
||||
baseurl, _, _ := k.GetStringValue("BaseURL")
|
||||
agentid, _, _ := k.GetStringValue("AgentID")
|
||||
apiurl, _, _ := k.GetStringValue("ApiURL")
|
||||
token, _, _ := k.GetStringValue("Token")
|
||||
agentpk, _, _ := k.GetStringValue("AgentPK")
|
||||
pk, _ := strconv.Atoi(agentpk)
|
||||
cert, _, _ := k.GetStringValue("Cert")
|
||||
proxy, _, _ := k.GetStringValue("Proxy")
|
||||
customMeshDir, _, _ := k.GetStringValue("MeshDir")
|
||||
|
||||
return &AgentConfig{
|
||||
BaseURL: baseurl,
|
||||
AgentID: agentid,
|
||||
APIURL: apiurl,
|
||||
Token: token,
|
||||
AgentPK: agentpk,
|
||||
PK: pk,
|
||||
Cert: cert,
|
||||
Proxy: proxy,
|
||||
CustomMeshDir: customMeshDir,
|
||||
}
|
||||
}
|
||||
13
agent/tactical/config/structs.go
Normal file
13
agent/tactical/config/structs.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package config
|
||||
|
||||
type AgentConfig struct {
|
||||
BaseURL string
|
||||
AgentID string
|
||||
APIURL string
|
||||
Token string
|
||||
AgentPK string
|
||||
PK int
|
||||
Cert string
|
||||
Proxy string
|
||||
CustomMeshDir string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue