mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-26 17:18:09 -07:00
review fixes
This commit is contained in:
@@ -731,6 +731,11 @@ func LoadConfig(filename string) (config *Config, err error) {
|
||||
}
|
||||
|
||||
config.Server.Cloaks.Initialize()
|
||||
if config.Server.Cloaks.Enabled {
|
||||
if config.Server.Cloaks.Secret == "" || config.Server.Cloaks.Secret == "siaELnk6Kaeo65K3RCrwJjlWaZ-Bt3WuZ2L8MXLbNb4" {
|
||||
return nil, fmt.Errorf("You must generate a new value of ip-cloaking.secret to enable cloaking")
|
||||
}
|
||||
}
|
||||
|
||||
for _, listenAddress := range config.Server.TorListeners.Listeners {
|
||||
found := false
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/subtle"
|
||||
"encoding/base32"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -37,3 +38,10 @@ func SecretTokensMatch(storedToken string, suppliedToken string) bool {
|
||||
|
||||
return subtle.ConstantTimeCompare([]byte(storedToken), []byte(suppliedToken)) == 1
|
||||
}
|
||||
|
||||
// generate a 256-bit secret key that can be written into a config file
|
||||
func GenerateSecretKey() string {
|
||||
var buf [32]byte
|
||||
rand.Read(buf[:])
|
||||
return base64.RawURLEncoding.EncodeToString(buf[:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user