Merge remote-tracking branch 'upstream/develop' into BigRefactor
This commit is contained in:
commit
a8dfa19b3a
9 changed files with 43 additions and 10 deletions
|
|
@ -109,6 +109,17 @@ func New(logger *logrus.Logger, version string) *Agent {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var natsProxyPath, natsProxyPort string
|
||||||
|
if ac.NatsProxyPath == "" {
|
||||||
|
natsProxyPath = "natsws"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ac.NatsProxyPort == "" {
|
||||||
|
natsProxyPort = "443"
|
||||||
|
}
|
||||||
|
|
||||||
|
natsServer := fmt.Sprintf("wss://%s:%s", ac.APIURL, natsProxyPort)
|
||||||
|
|
||||||
return &Agent{
|
return &Agent{
|
||||||
Hostname: info.Hostname,
|
Hostname: info.Hostname,
|
||||||
BaseURL: ac.BaseURL,
|
BaseURL: ac.BaseURL,
|
||||||
|
|
@ -133,6 +144,9 @@ func New(logger *logrus.Logger, version string) *Agent {
|
||||||
Platform: runtime.GOOS,
|
Platform: runtime.GOOS,
|
||||||
GoArch: runtime.GOARCH,
|
GoArch: runtime.GOARCH,
|
||||||
ServiceConfig: svcConf,
|
ServiceConfig: svcConf,
|
||||||
|
NatsServer: natsServer,
|
||||||
|
NatsProxyPath: natsProxyPath,
|
||||||
|
NatsProxyPort: natsProxyPort,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,6 +327,7 @@ func (a *Agent) setupNatsOptions() []nats.Option {
|
||||||
opts = append(opts, nats.RetryOnFailedConnect(true))
|
opts = append(opts, nats.RetryOnFailedConnect(true))
|
||||||
opts = append(opts, nats.MaxReconnects(-1))
|
opts = append(opts, nats.MaxReconnects(-1))
|
||||||
opts = append(opts, nats.ReconnectBufSize(-1))
|
opts = append(opts, nats.ReconnectBufSize(-1))
|
||||||
|
opts = append(opts, nats.ProxyPath("natsws"))
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,6 +353,7 @@ func (a *Agent) CleanupAgentUpdates() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// winagent-v* is deprecated
|
||||||
files, err := filepath.Glob("winagent-v*.exe")
|
files, err := filepath.Glob("winagent-v*.exe")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
|
|
@ -345,6 +361,13 @@ func (a *Agent) CleanupAgentUpdates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
agents, err := filepath.Glob("tacticalagent-v*.exe")
|
||||||
|
if err == nil {
|
||||||
|
for _, f := range agents {
|
||||||
|
os.Remove(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cderr = os.Chdir(os.Getenv("TMP"))
|
cderr = os.Chdir(os.Getenv("TMP"))
|
||||||
if cderr != nil {
|
if cderr != nil {
|
||||||
a.Logger.Errorln(cderr)
|
a.Logger.Errorln(cderr)
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ func NewAgentConfig() *rmm.AgentConfig {
|
||||||
Cert: viper.GetString("cert"),
|
Cert: viper.GetString("cert"),
|
||||||
Proxy: viper.GetString("proxy"),
|
Proxy: viper.GetString("proxy"),
|
||||||
CustomMeshDir: viper.GetString("meshdir"),
|
CustomMeshDir: viper.GetString("meshdir"),
|
||||||
|
NatsProxyPath: viper.GetString("natsproxypath"),
|
||||||
|
NatsProxyPort: viper.GetString("natsproxyport"),
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ func NewAgentConfig() *rmm.AgentConfig {
|
||||||
cert, _, _ := k.GetStringValue("Cert")
|
cert, _, _ := k.GetStringValue("Cert")
|
||||||
proxy, _, _ := k.GetStringValue("Proxy")
|
proxy, _, _ := k.GetStringValue("Proxy")
|
||||||
customMeshDir, _, _ := k.GetStringValue("MeshDir")
|
customMeshDir, _, _ := k.GetStringValue("MeshDir")
|
||||||
|
natsProxyPath, _, _ := k.GetStringValue("NatsProxyPath")
|
||||||
|
natsProxyPort, _, _ := k.GetStringValue("NatsProxyPort")
|
||||||
|
|
||||||
return &rmm.AgentConfig{
|
return &rmm.AgentConfig{
|
||||||
BaseURL: baseurl,
|
BaseURL: baseurl,
|
||||||
|
|
@ -72,6 +74,8 @@ func NewAgentConfig() *rmm.AgentConfig {
|
||||||
Cert: cert,
|
Cert: cert,
|
||||||
Proxy: proxy,
|
Proxy: proxy,
|
||||||
CustomMeshDir: customMeshDir,
|
CustomMeshDir: customMeshDir,
|
||||||
|
NatsProxyPath: natsProxyPath,
|
||||||
|
NatsProxyPort: natsProxyPort,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,7 +639,7 @@ func (a *Agent) AgentUninstall(code string) {
|
||||||
func (a *Agent) addDefenderExlusions() {
|
func (a *Agent) addDefenderExlusions() {
|
||||||
code := `
|
code := `
|
||||||
Add-MpPreference -ExclusionPath 'C:\Program Files\TacticalAgent\*'
|
Add-MpPreference -ExclusionPath 'C:\Program Files\TacticalAgent\*'
|
||||||
Add-MpPreference -ExclusionPath 'C:\Windows\Temp\winagent-v*.exe'
|
Add-MpPreference -ExclusionPath 'C:\Windows\Temp\tacticalagent-v*.exe'
|
||||||
Add-MpPreference -ExclusionPath 'C:\Windows\Temp\trmm\*'
|
Add-MpPreference -ExclusionPath 'C:\Windows\Temp\trmm\*'
|
||||||
Add-MpPreference -ExclusionPath 'C:\Program Files\Mesh Agent\*'
|
Add-MpPreference -ExclusionPath 'C:\Program Files\Mesh Agent\*'
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ https://license.tacticalrmm.com
|
||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -78,8 +77,7 @@ func (a *Agent) NatsMessage(nc *nats.Conn, mode string) {
|
||||||
|
|
||||||
func (a *Agent) DoNatsCheckIn() {
|
func (a *Agent) DoNatsCheckIn() {
|
||||||
opts := a.setupNatsOptions()
|
opts := a.setupNatsOptions()
|
||||||
server := fmt.Sprintf("tls://%s:4222", a.ApiURL)
|
nc, err := nats.Connect(a.NatsServer, opts...)
|
||||||
nc, err := nats.Connect(server, opts...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Logger.Errorln(err)
|
a.Logger.Errorln(err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,16 @@ func (a *Agent) KillHungUpdates() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// winagent-v* is deprecated
|
||||||
if strings.Contains(p.Exe, "winagent-v") {
|
if strings.Contains(p.Exe, "winagent-v") {
|
||||||
a.Logger.Debugln("killing process", p.Exe)
|
a.Logger.Debugln("killing process", p.Exe)
|
||||||
KillProc(int32(p.PID))
|
KillProc(int32(p.PID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(p.Exe, "tacticalagent-v") {
|
||||||
|
a.Logger.Debugln("killing process", p.Exe)
|
||||||
|
KillProc(int32(p.PID))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,7 @@ func (a *Agent) RunRPC() {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
opts := a.setupNatsOptions()
|
opts := a.setupNatsOptions()
|
||||||
server := fmt.Sprintf("tls://%s:4222", a.ApiURL)
|
nc, err := nats.Connect(a.NatsServer, opts...)
|
||||||
nc, err := nats.Connect(server, opts...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Logger.Fatalln("RunRPC() nats.Connect()", err)
|
a.Logger.Fatalln("RunRPC() nats.Connect()", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ https://license.tacticalrmm.com
|
||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -38,8 +37,7 @@ func (a *Agent) AgentSvc() {
|
||||||
time.Sleep(time.Duration(sleepDelay) * time.Second)
|
time.Sleep(time.Duration(sleepDelay) * time.Second)
|
||||||
|
|
||||||
opts := a.setupNatsOptions()
|
opts := a.setupNatsOptions()
|
||||||
server := fmt.Sprintf("tls://%s:4222", a.ApiURL)
|
nc, err := nats.Connect(a.NatsServer, opts...)
|
||||||
nc, err := nats.Connect(server, opts...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Logger.Fatalln("AgentSvc() nats.Connect()", err)
|
a.Logger.Fatalln("AgentSvc() nats.Connect()", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -201,6 +201,6 @@ func installUsage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUsage() {
|
func updateUsage() {
|
||||||
u := `Usage: tacticalrmm.exe -m update -updateurl https://example.com/winagent-vX.X.X.exe -inno winagent-vX.X.X.exe -updatever 1.1.1`
|
u := `Usage: tacticalrmm.exe -m update -updateurl https://example.com/tacticalagent-vX.X.X.exe -inno tacticalagent-vX.X.X.exe -updatever 1.1.1`
|
||||||
fmt.Println(u)
|
fmt.Println(u)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ type AgentConfig struct {
|
||||||
Cert string
|
Cert string
|
||||||
Proxy string
|
Proxy string
|
||||||
CustomMeshDir string
|
CustomMeshDir string
|
||||||
|
NatsProxyPath string
|
||||||
|
NatsProxyPort string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RunScriptResp struct {
|
type RunScriptResp struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue