Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion haproxy/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package haproxy

import (
"crypto/rand"
"encoding/base64"
"io/ioutil"
"os"
"path"
Expand All @@ -14,9 +16,10 @@ import (

const (
dataplaneUser = "haproxy"
dataplanePass = "pass"
)

var dataplanePass string

var baseCfgTmpl = `
global
master-worker
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}