mirror of https://github.com/wh1te909/rmmagent.git
add regexp for salt-master if using ip:port
This commit is contained in:
parent
7a3d895368
commit
29e6f8cfbf
|
@ -7,6 +7,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -51,6 +52,16 @@ func (a *WindowsAgent) Install(i *Installer) {
|
|||
a.installerMsg("Invalid URL (must contain https or http)", "error")
|
||||
}
|
||||
|
||||
// will match either ipv4 , or ipv4:port
|
||||
var ipPort = regexp.MustCompile(`[0-9]+(?:\.[0-9]+){3}(:[0-9]+)?`)
|
||||
|
||||
// if ipv4:port, strip the port to get ip for salt master
|
||||
if ipPort.MatchString(u.Host) && strings.Contains(u.Host, ":") {
|
||||
i.SaltMaster = strings.Split(u.Host, ":")[0]
|
||||
} else {
|
||||
i.SaltMaster = u.Host
|
||||
}
|
||||
|
||||
i.SaltMaster = u.Host
|
||||
a.Logger.Debugln("Salt Master:", i.SaltMaster)
|
||||
|
||||
|
|
Loading…
Reference in New Issue