diff --git a/haproxy/config.go b/haproxy/config.go index 4412408..6ce99e0 100644 --- a/haproxy/config.go +++ b/haproxy/config.go @@ -1,6 +1,8 @@ package haproxy import ( + "crypto/rand" + "encoding/base64" "io/ioutil" "os" "path" @@ -14,9 +16,10 @@ import ( const ( dataplaneUser = "haproxy" - dataplanePass = "pass" ) +var dataplanePass string + var baseCfgTmpl = ` global master-worker @@ -105,6 +108,8 @@ func newHaConfig(baseDir string, sd *lib.Shutdown) (*haConfig, error) { } defer cfgFile.Close() + dataplanePass = createRandomString() + err = tmpl.Execute(cfgFile, baseParams{ NbThread: runtime.GOMAXPROCS(0), SocketPath: cfg.StatsSock, @@ -131,3 +136,9 @@ func newHaConfig(baseDir string, sd *lib.Shutdown) (*haConfig, error) { return cfg, nil } + +func createRandomString() string { + randBytes := make([]byte, 32) + _, _ = rand.Read(randBytes) + return base64.URLEncoding.EncodeToString(randBytes) +}