Преглед на файлове

review fixes

tags/v1.1.0-rc1
Shivaram Lingamneni преди 5 години
родител
ревизия
11076be0ee
променени са 4 файла, в които са добавени 18 реда и са изтрити 2 реда
  1. 5
    0
      irc/config.go
  2. 8
    0
      irc/utils/crypto.go
  3. 4
    0
      oragono.go
  4. 1
    2
      oragono.yaml

+ 5
- 0
irc/config.go Целия файл

731
 	}
731
 	}
732
 
732
 
733
 	config.Server.Cloaks.Initialize()
733
 	config.Server.Cloaks.Initialize()
734
+	if config.Server.Cloaks.Enabled {
735
+		if config.Server.Cloaks.Secret == "" || config.Server.Cloaks.Secret == "siaELnk6Kaeo65K3RCrwJjlWaZ-Bt3WuZ2L8MXLbNb4" {
736
+			return nil, fmt.Errorf("You must generate a new value of ip-cloaking.secret to enable cloaking")
737
+		}
738
+	}
734
 
739
 
735
 	for _, listenAddress := range config.Server.TorListeners.Listeners {
740
 	for _, listenAddress := range config.Server.TorListeners.Listeners {
736
 		found := false
741
 		found := false

+ 8
- 0
irc/utils/crypto.go Целия файл

7
 	"crypto/rand"
7
 	"crypto/rand"
8
 	"crypto/subtle"
8
 	"crypto/subtle"
9
 	"encoding/base32"
9
 	"encoding/base32"
10
+	"encoding/base64"
10
 )
11
 )
11
 
12
 
12
 var (
13
 var (
37
 
38
 
38
 	return subtle.ConstantTimeCompare([]byte(storedToken), []byte(suppliedToken)) == 1
39
 	return subtle.ConstantTimeCompare([]byte(storedToken), []byte(suppliedToken)) == 1
39
 }
40
 }
41
+
42
+// generate a 256-bit secret key that can be written into a config file
43
+func GenerateSecretKey() string {
44
+	var buf [32]byte
45
+	rand.Read(buf[:])
46
+	return base64.RawURLEncoding.EncodeToString(buf[:])
47
+}

+ 4
- 0
oragono.go Целия файл

17
 	"github.com/oragono/oragono/irc"
17
 	"github.com/oragono/oragono/irc"
18
 	"github.com/oragono/oragono/irc/logger"
18
 	"github.com/oragono/oragono/irc/logger"
19
 	"github.com/oragono/oragono/irc/mkcerts"
19
 	"github.com/oragono/oragono/irc/mkcerts"
20
+	"github.com/oragono/oragono/irc/utils"
20
 	"golang.org/x/crypto/bcrypt"
21
 	"golang.org/x/crypto/bcrypt"
21
 	"golang.org/x/crypto/ssh/terminal"
22
 	"golang.org/x/crypto/ssh/terminal"
22
 )
23
 )
46
 	oragono upgradedb [--conf <filename>] [--quiet]
47
 	oragono upgradedb [--conf <filename>] [--quiet]
47
 	oragono genpasswd [--conf <filename>] [--quiet]
48
 	oragono genpasswd [--conf <filename>] [--quiet]
48
 	oragono mkcerts [--conf <filename>] [--quiet]
49
 	oragono mkcerts [--conf <filename>] [--quiet]
50
+	oragono mksecret [--conf <filename>] [--quiet]
49
 	oragono run [--conf <filename>] [--quiet]
51
 	oragono run [--conf <filename>] [--quiet]
50
 	oragono -h | --help
52
 	oragono -h | --help
51
 	oragono --version
53
 	oragono --version
128
 				log.Fatal("  Could not create certificate:", err.Error())
130
 				log.Fatal("  Could not create certificate:", err.Error())
129
 			}
131
 			}
130
 		}
132
 		}
133
+	} else if arguments["mksecret"].(bool) {
134
+		fmt.Println(utils.GenerateSecretKey())
131
 	} else if arguments["run"].(bool) {
135
 	} else if arguments["run"].(bool) {
132
 		if !arguments["--quiet"].(bool) {
136
 		if !arguments["--quiet"].(bool) {
133
 			logman.Info("server", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
137
 			logman.Info("server", fmt.Sprintf("Oragono v%s starting", irc.SemVer))

+ 1
- 2
oragono.yaml Целия файл

204
         # secret key to prevent dictionary attacks against cloaked IPs
204
         # secret key to prevent dictionary attacks against cloaked IPs
205
         # any high-entropy secret is valid for this purpose:
205
         # any high-entropy secret is valid for this purpose:
206
         # you MUST generate a new one for your installation.
206
         # you MUST generate a new one for your installation.
207
-        # suggestion: use the output of this command:
208
-        # python3 -c "import secrets; print(secrets.token_urlsafe())"
207
+        # suggestion: use the output of `oragono mksecret`
209
         # note that rotating this key will invalidate all existing ban masks.
208
         # note that rotating this key will invalidate all existing ban masks.
210
         secret: "siaELnk6Kaeo65K3RCrwJjlWaZ-Bt3WuZ2L8MXLbNb4"
209
         secret: "siaELnk6Kaeo65K3RCrwJjlWaZ-Bt3WuZ2L8MXLbNb4"
211
 
210
 

Loading…
Отказ
Запис