Merge remote-tracking branch 'origin/RefactorDebug' into BigRefactor

This commit is contained in:
redanthrax 2022-06-17 10:21:46 -07:00
commit d6cd817133
5 changed files with 6 additions and 30 deletions

View file

@ -1,11 +1,16 @@
### Tactical RMM Agent
https://github.com/amidaware/tacticalrmm
#### building the agent
#### building the agent - linux
```
env CGO_ENABLED=0 GOOS=<GOOS> GOARCH=<GOARCH> go build -ldflags "-s -w"
```
#### building the agent - windows
```
$env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w"
```
### tests
Navigate to repo directory
```

View file

@ -48,10 +48,6 @@ var (
func NewAgentConfig() *rmm.AgentConfig {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
if shared.TEST {
err = nil
k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
}
if err != nil {
return &rmm.AgentConfig{}
@ -840,11 +836,6 @@ func (a *Agent) InstallService() error {
// skip on first call of inno setup if this is a new install
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
if shared.TEST {
err = nil
k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
}
if err != nil {
return nil
}

View file

@ -23,7 +23,6 @@ import (
"strings"
"time"
"github.com/amidaware/rmmagent/shared"
"github.com/go-resty/resty/v2"
trmm "github.com/wh1te909/trmm-shared"
)
@ -253,15 +252,10 @@ func (a *Agent) Install(i *Installer) {
a.Logger.Infoln("Starting service...")
out := a.ControlService(winSvcName, "start")
if shared.TEST {
goto SKIPSTART;
}
if !out.Success {
a.installerMsg(out.ErrorMsg, "error", i.Silent)
}
SKIPSTART: a.Logger.Infoln("Skipping service start in test.")
a.Logger.Infoln("Adding windows defender exclusions")
a.addDefenderExlusions()

View file

@ -13,7 +13,6 @@ package agent
import (
"log"
"github.com/amidaware/rmmagent/shared"
"github.com/spf13/viper"
)
@ -39,9 +38,6 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
viper.Set("meshdir", meshdir)
viper.SetConfigPermissions(0660)
configLocation := "/etc/tacticalagent"
if shared.TEST {
configLocation = "tacticalagent"
}
err := viper.SafeWriteConfigAs(configLocation)

View file

@ -17,18 +17,12 @@ import (
"os"
"path/filepath"
"github.com/amidaware/rmmagent/shared"
"github.com/gonutz/w32/v2"
"golang.org/x/sys/windows/registry"
)
func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) {
k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
if shared.TEST {
err = nil
k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
}
if err != nil {
log.Fatalln("Error creating registry key:", err)
}
@ -84,10 +78,6 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
func (a *Agent) checkExistingAndRemove(silent bool) {
hasReg := false
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
if shared.TEST {
err = nil
_, err = registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
}
if err == nil {
hasReg = true