From 29e6f8cfbfd510f0c49cdfb57d1f9667ead92eba Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 15 Oct 2020 12:55:21 -0700 Subject: [PATCH] add regexp for salt-master if using ip:port --- agent/install_windows.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/agent/install_windows.go b/agent/install_windows.go index 1d3c88e..f73419c 100644 --- a/agent/install_windows.go +++ b/agent/install_windows.go @@ -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)