Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master' into passhashing.2

tags/v0.12.0
Shivaram Lingamneni 5 gadus atpakaļ
vecāks
revīzija
cbc2b07d35
14 mainītis faili ar 149 papildinājumiem un 128 dzēšanām
  1. 58
    16
      Gopkg.lock
  2. 0
    4
      Gopkg.toml
  3. 1
    1
      irc/channelreg.go
  4. 3
    0
      irc/chanserv.go
  5. 11
    11
      irc/client.go
  6. 4
    13
      irc/config.go
  7. 2
    6
      irc/handlers.go
  8. 3
    8
      irc/logger/logger.go
  9. 9
    8
      irc/nickserv.go
  10. 24
    28
      irc/server.go
  11. 33
    2
      irc/services.go
  12. 0
    15
      oragono.go
  13. 0
    15
      oragono.yaml
  14. 1
    1
      vendor

+ 58
- 16
Gopkg.lock Parādīt failu

@@ -2,132 +2,157 @@
2 2
 
3 3
 
4 4
 [[projects]]
5
+  digest = "1:1bd4d273de93fce29ca3636145ccfcb932754f56e4c099297319e677e89f658d"
5 6
   name = "code.cloudfoundry.org/bytefmt"
6 7
   packages = ["."]
8
+  pruneopts = ""
7 9
   revision = "cbe033486cf0620d3bb77d8ef7f22ab346ad3628"
8 10
 
9 11
 [[projects]]
10 12
   branch = "master"
13
+  digest = "1:20da7140359cab99772431cbeb195bd8cbe76312fcf6509fd8125cf91ab2847b"
11 14
   name = "github.com/docopt/docopt-go"
12 15
   packages = ["."]
16
+  pruneopts = ""
13 17
   revision = "ee0de3bc6815ee19d4a46c7eb90f829db0e014b1"
14 18
 
15 19
 [[projects]]
16 20
   branch = "master"
21
+  digest = "1:5d1f0cdebbc2a5237b572fa539bdb0aefea36780cdc1dbeda3b2f5d39f8f375d"
17 22
   name = "github.com/goshuirc/e-nfa"
18 23
   packages = ["."]
24
+  pruneopts = ""
19 25
   revision = "7071788e394065e6456458a5e9cb503cad545154"
20 26
 
21 27
 [[projects]]
22 28
   branch = "master"
29
+  digest = "1:d7ff716c49f33735c9e25e11b67e70f9eac7eb6c21b9806b0552b52541a568f5"
23 30
   name = "github.com/goshuirc/irc-go"
24 31
   packages = [
25 32
     "ircfmt",
26 33
     "ircmatch",
27
-    "ircmsg"
34
+    "ircmsg",
28 35
   ]
36
+  pruneopts = ""
29 37
   revision = "8d136c4f92871c1c132bf702022363add479291b"
30 38
 
31 39
 [[projects]]
32 40
   branch = "master"
41
+  digest = "1:5be6259a2ab7350284d8c25b8df78153dcca360247be48ea7c55be37689802f4"
33 42
   name = "github.com/mattn/go-colorable"
34 43
   packages = ["."]
44
+  pruneopts = ""
35 45
   revision = "7dc3415be66d7cc68bf0182f35c8d31f8d2ad8a7"
36 46
 
37 47
 [[projects]]
48
+  digest = "1:78229b46ddb7434f881390029bd1af7661294af31f6802e0e1bedaad4ab0af3c"
38 49
   name = "github.com/mattn/go-isatty"
39 50
   packages = ["."]
51
+  pruneopts = ""
40 52
   revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
41 53
   version = "v0.0.3"
42 54
 
43 55
 [[projects]]
44 56
   branch = "master"
57
+  digest = "1:50416da10e189bc201e122e20078fb8e680a439cbdd24aaece06c434b4415b60"
45 58
   name = "github.com/mgutz/ansi"
46 59
   packages = ["."]
60
+  pruneopts = ""
47 61
   revision = "9520e82c474b0a04dd04f8a40959027271bab992"
48 62
 
49 63
 [[projects]]
50 64
   branch = "master"
65
+  digest = "1:2251e6a17ea4a6eaa708882a1cda837aae3e425edbb190ef39b761ecf15a5c3d"
51 66
   name = "github.com/oragono/go-ident"
52 67
   packages = ["."]
68
+  pruneopts = ""
53 69
   revision = "337fed0fd21ad538725cfcb55053ea4cf8056abc"
54 70
 
55 71
 [[projects]]
56 72
   branch = "master"
57
-  name = "github.com/stackimpact/stackimpact-go"
58
-  packages = [
59
-    ".",
60
-    "internal",
61
-    "internal/pprof/profile"
62
-  ]
63
-  revision = "8b5b02c181e477dafcf505342d8a79b5c8241da7"
64
-
65
-[[projects]]
66
-  branch = "master"
73
+  digest = "1:b28f2f9253cbb1bf2bcb3c0ab7421d2f88a245386199a6668b0a66eb09ce3e1f"
67 74
   name = "github.com/tidwall/btree"
68 75
   packages = ["."]
76
+  pruneopts = ""
69 77
   revision = "9876f1454cf0993a53d74c27196993e345f50dd1"
70 78
 
71 79
 [[projects]]
80
+  digest = "1:18342f164260096848ceff7c53cf797dbc1556d8161ad51cfc22281916209a5a"
72 81
   name = "github.com/tidwall/buntdb"
73 82
   packages = ["."]
83
+  pruneopts = ""
74 84
   revision = "2da7c106683f522198cdf55ed8db42b374de50d7"
75 85
   version = "v1.0.0"
76 86
 
77 87
 [[projects]]
88
+  digest = "1:82fa3d995465f05e4c5e7f44a94d084b84a547ad77e41458fe9ec0877d04dced"
78 89
   name = "github.com/tidwall/gjson"
79 90
   packages = ["."]
91
+  pruneopts = ""
80 92
   revision = "87033efcaec6215741137e8ca61952c53ef2685d"
81 93
   version = "v1.0.6"
82 94
 
83 95
 [[projects]]
84 96
   branch = "master"
97
+  digest = "1:bf59f997bab72b8ecd044aed35d706edb6abd6128afe0502c94398b2374f1f3f"
85 98
   name = "github.com/tidwall/grect"
86 99
   packages = ["."]
100
+  pruneopts = ""
87 101
   revision = "ba9a043346eba55344e40d66a5e74cfda3a9d293"
88 102
 
89 103
 [[projects]]
90 104
   branch = "master"
105
+  digest = "1:4db4f92bb9cb04cfc4fccb36aba2598b02a988008c4cc0692b241214ad8ac96e"
91 106
   name = "github.com/tidwall/match"
92 107
   packages = ["."]
108
+  pruneopts = ""
93 109
   revision = "1731857f09b1f38450e2c12409748407822dc6be"
94 110
 
95 111
 [[projects]]
96 112
   branch = "master"
113
+  digest = "1:5d9d865e55b95f001e52a7f5d1f812e8a80f0f05d5b04ede006f24206ebba33c"
97 114
   name = "github.com/tidwall/rtree"
98 115
   packages = [
99 116
     ".",
100
-    "base"
117
+    "base",
101 118
   ]
119
+  pruneopts = ""
102 120
   revision = "6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3"
103 121
 
104 122
 [[projects]]
105 123
   branch = "master"
124
+  digest = "1:261a5770e68d10884a6d334396842d69ddb57ac5ecef60057eb5bce6f4bc7512"
106 125
   name = "github.com/tidwall/tinyqueue"
107 126
   packages = ["."]
127
+  pruneopts = ""
108 128
   revision = "1feaf062ef04a231c9126f99a68eaa579fd0e390"
109 129
 
110 130
 [[projects]]
111 131
   branch = "master"
132
+  digest = "1:295363031beef7eb063d53138806b43f26c38d8a3e2543324ce2af3c766069de"
112 133
   name = "golang.org/x/crypto"
113 134
   packages = [
114 135
     "bcrypt",
115 136
     "blowfish",
116
-    "ssh/terminal"
137
+    "ssh/terminal",
117 138
   ]
139
+  pruneopts = ""
118 140
   revision = "5119cf507ed5294cc409c092980c7497ee5d6fd2"
119 141
 
120 142
 [[projects]]
121 143
   branch = "master"
144
+  digest = "1:407b5f905024dd94ee08c1777fabb380fb3d380f92a7f7df2592be005337eeb3"
122 145
   name = "golang.org/x/sys"
123 146
   packages = [
124 147
     "unix",
125
-    "windows"
148
+    "windows",
126 149
   ]
150
+  pruneopts = ""
127 151
   revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
128 152
 
129 153
 [[projects]]
130 154
   branch = "master"
155
+  digest = "1:31985a0ed491dba5ba7fe92e18be008acd92ca9435ed9b35b06f3e6c00fd82cb"
131 156
   name = "golang.org/x/text"
132 157
   packages = [
133 158
     "cases",
@@ -148,19 +173,36 @@
148 173
     "unicode/cldr",
149 174
     "unicode/norm",
150 175
     "unicode/rangetable",
151
-    "width"
176
+    "width",
152 177
   ]
178
+  pruneopts = ""
153 179
   revision = "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1"
154 180
 
155 181
 [[projects]]
156 182
   branch = "v2"
183
+  digest = "1:4b4e5848dfe7f316f95f754df071bebfb40cf4482da62e17e7e1aebdf11f4918"
157 184
   name = "gopkg.in/yaml.v2"
158 185
   packages = ["."]
186
+  pruneopts = ""
159 187
   revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4"
160 188
 
161 189
 [solve-meta]
162 190
   analyzer-name = "dep"
163 191
   analyzer-version = 1
164
-  inputs-digest = "1f6e6db999e9e75b04aee6f0018be1557848f8248a28cf21783188fdeb866718"
192
+  input-imports = [
193
+    "code.cloudfoundry.org/bytefmt",
194
+    "github.com/docopt/docopt-go",
195
+    "github.com/goshuirc/irc-go/ircfmt",
196
+    "github.com/goshuirc/irc-go/ircmatch",
197
+    "github.com/goshuirc/irc-go/ircmsg",
198
+    "github.com/mattn/go-colorable",
199
+    "github.com/mgutz/ansi",
200
+    "github.com/oragono/go-ident",
201
+    "github.com/tidwall/buntdb",
202
+    "golang.org/x/crypto/bcrypt",
203
+    "golang.org/x/crypto/ssh/terminal",
204
+    "golang.org/x/text/secure/precis",
205
+    "gopkg.in/yaml.v2",
206
+  ]
165 207
   solver-name = "gps-cdcl"
166 208
   solver-version = 1

+ 0
- 4
Gopkg.toml Parādīt failu

@@ -75,10 +75,6 @@
75 75
   branch = "master"
76 76
   name = "github.com/mgutz/ansi"
77 77
 
78
-[[dependencies]]
79
-  branch = "master"
80
-  name = "github.com/stackimpact/stackimpact-go"
81
-
82 78
 [[dependencies]]
83 79
   branch = "master"
84 80
   name = "github.com/tidwall/buntdb"

+ 1
- 1
irc/channelreg.go Parādīt failu

@@ -250,7 +250,7 @@ func (reg *ChannelRegistry) deleteChannel(tx *buntdb.Tx, key string, info Regist
250 250
 		founder, _ := tx.Get(fmt.Sprintf(keyChannelFounder, key))
251 251
 
252 252
 		// to see if we're deleting the right channel, confirm the founder and the registration time
253
-		if founder == info.Founder && registeredAt == info.RegisteredAt {
253
+		if founder == info.Founder && registeredAt.Unix() == info.RegisteredAt.Unix() {
254 254
 			for _, keyFmt := range channelKeyStrings {
255 255
 				tx.Delete(fmt.Sprintf(keyFmt, key))
256 256
 			}

+ 3
- 0
irc/chanserv.go Parādīt failu

@@ -63,6 +63,9 @@ invoking the command without a code will display the necessary code.`,
63 63
 			helpShort: `$bUNREGISTER$b deletes a channel registration.`,
64 64
 			enabled:   chanregEnabled,
65 65
 		},
66
+		"drop": {
67
+			aliasOf: "unregister",
68
+		},
66 69
 		"amode": {
67 70
 			handler: csAmodeHandler,
68 71
 			help: `Syntax: $bAMODE #channel [mode change] [account]$b

+ 11
- 11
irc/client.go Parādīt failu

@@ -7,7 +7,6 @@ package irc
7 7
 
8 8
 import (
9 9
 	"fmt"
10
-	"log"
11 10
 	"net"
12 11
 	"runtime/debug"
13 12
 	"strconv"
@@ -82,8 +81,8 @@ type Client struct {
82 81
 	vhost              string
83 82
 }
84 83
 
85
-// NewClient returns a client with all the appropriate info setup.
86
-func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
84
+// NewClient sets up a new client and starts its goroutine.
85
+func NewClient(server *Server, conn net.Conn, isTLS bool) {
87 86
 	now := time.Now()
88 87
 	config := server.Config()
89 88
 	fullLineLenLimit := config.Limits.LineLen.Tags + config.Limits.LineLen.Rest
@@ -114,15 +113,17 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
114 113
 	}
115 114
 	if config.Server.CheckIdent && !utils.AddrIsUnix(conn.RemoteAddr()) {
116 115
 		_, serverPortString, err := net.SplitHostPort(conn.LocalAddr().String())
117
-		serverPort, _ := strconv.Atoi(serverPortString)
118 116
 		if err != nil {
119
-			log.Fatal(err)
117
+			server.logger.Error("internal", "bad server address", err.Error())
118
+			return
120 119
 		}
120
+		serverPort, _ := strconv.Atoi(serverPortString)
121 121
 		clientHost, clientPortString, err := net.SplitHostPort(conn.RemoteAddr().String())
122
-		clientPort, _ := strconv.Atoi(clientPortString)
123 122
 		if err != nil {
124
-			log.Fatal(err)
123
+			server.logger.Error("internal", "bad client address", err.Error())
124
+			return
125 125
 		}
126
+		clientPort, _ := strconv.Atoi(clientPortString)
126 127
 
127 128
 		client.Notice(client.t("*** Looking up your username"))
128 129
 		resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
@@ -141,8 +142,6 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
141 142
 		}
142 143
 	}
143 144
 	go client.run()
144
-
145
-	return client
146 145
 }
147 146
 
148 147
 func (client *Client) resetFakelag() {
@@ -766,11 +765,12 @@ func (client *Client) destroy(beingResumed bool) {
766 765
 
767 766
 	// send quit messages to friends
768 767
 	if !beingResumed {
769
-		client.server.stats.ChangeTotal(-1)
768
+		if client.Registered() {
769
+			client.server.stats.ChangeTotal(-1)
770
+		}
770 771
 		if client.HasMode(modes.Invisible) {
771 772
 			client.server.stats.ChangeInvisible(-1)
772 773
 		}
773
-
774 774
 		if client.HasMode(modes.Operator) || client.HasMode(modes.LocalOperator) {
775 775
 			client.server.stats.ChangeOperators(-1)
776 776
 		}

+ 4
- 13
irc/config.go Parādīt failu

@@ -81,8 +81,7 @@ type AccountRegistrationConfig struct {
81 81
 			VerifyMessage        string `yaml:"verify-message"`
82 82
 		}
83 83
 	}
84
-	AllowMultiplePerConnection bool `yaml:"allow-multiple-per-connection"`
85
-	BcryptCost                 uint `yaml:"bcrypt-cost"`
84
+	BcryptCost uint `yaml:"bcrypt-cost"`
86 85
 }
87 86
 
88 87
 type VHostConfig struct {
@@ -193,13 +192,6 @@ func (sts *STSConfig) Value() string {
193 192
 	return val
194 193
 }
195 194
 
196
-// StackImpactConfig is the config used for StackImpact's profiling.
197
-type StackImpactConfig struct {
198
-	Enabled  bool
199
-	AgentKey string `yaml:"agent-key"`
200
-	AppName  string `yaml:"app-name"`
201
-}
202
-
203 195
 type FakelagConfig struct {
204 196
 	Enabled           bool
205 197
 	Window            time.Duration
@@ -266,7 +258,6 @@ type Config struct {
266 258
 	Debug struct {
267 259
 		RecoverFromErrors *bool   `yaml:"recover-from-errors"`
268 260
 		PprofListener     *string `yaml:"pprof-listener"`
269
-		StackImpact       StackImpactConfig
270 261
 	}
271 262
 
272 263
 	Limits Limits
@@ -406,17 +397,17 @@ func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error
406 397
 }
407 398
 
408 399
 // TLSListeners returns a list of TLS listeners and their configs.
409
-func (conf *Config) TLSListeners() map[string]*tls.Config {
400
+func (conf *Config) TLSListeners() (map[string]*tls.Config, error) {
410 401
 	tlsListeners := make(map[string]*tls.Config)
411 402
 	for s, tlsListenersConf := range conf.Server.TLSListeners {
412 403
 		config, err := tlsListenersConf.Config()
413 404
 		if err != nil {
414
-			log.Fatal(err)
405
+			return nil, err
415 406
 		}
416 407
 		config.ClientAuth = tls.RequestClientCert
417 408
 		tlsListeners[s] = config
418 409
 	}
419
-	return tlsListeners
410
+	return tlsListeners, nil
420 411
 }
421 412
 
422 413
 // LoadConfig loads the given YAML configuration file.

+ 2
- 6
irc/handlers.go Parādīt failu

@@ -84,12 +84,8 @@ func parseCallback(spec string, config *AccountConfig) (callbackNamespace string
84 84
 func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
85 85
 	// clients can't reg new accounts if they're already logged in
86 86
 	if client.LoggedIntoAccount() {
87
-		if server.AccountConfig().Registration.AllowMultiplePerConnection {
88
-			server.accounts.Logout(client)
89
-		} else {
90
-			rb.Add(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", client.t("You're already logged into an account"))
91
-			return false
92
-		}
87
+		rb.Add(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", client.t("You're already logged into an account"))
88
+		return false
93 89
 	}
94 90
 
95 91
 	// get and sanitise account name

+ 3
- 8
irc/logger/logger.go Parādīt failu

@@ -124,7 +124,9 @@ func (logger *Manager) ApplyConfig(config []LoggingConfig) error {
124 124
 			stdoutWriteLock: &logger.stdoutWriteLock,
125 125
 			fileWriteLock:   &logger.fileWriteLock,
126 126
 		}
127
-		if typeMap["userinput"] || typeMap["useroutput"] || (typeMap["*"] && !(excludedTypeMap["userinput"] && excludedTypeMap["useroutput"])) {
127
+		ioEnabled := typeMap["userinput"] || typeMap["useroutput"] || (typeMap["*"] && !(excludedTypeMap["userinput"] && excludedTypeMap["useroutput"]))
128
+		// raw I/O is only logged at level debug;
129
+		if ioEnabled && logConfig.Level == LogDebug {
128 130
 			atomic.StoreUint32(&logger.loggingRawIO, 1)
129 131
 		}
130 132
 		if sLogger.MethodFile.Enabled {
@@ -177,13 +179,6 @@ func (logger *Manager) Error(logType string, messageParts ...string) {
177 179
 	logger.Log(LogError, logType, messageParts...)
178 180
 }
179 181
 
180
-// Fatal logs the given message as an error message, then exits.
181
-func (logger *Manager) Fatal(logType string, messageParts ...string) {
182
-	logger.Error(logType, messageParts...)
183
-	logger.Error("FATAL", "Fatal error encountered, application exiting")
184
-	os.Exit(1)
185
-}
186
-
187 182
 type fileMethod struct {
188 183
 	Enabled  bool
189 184
 	Filename string

+ 9
- 8
irc/nickserv.go Parādīt failu

@@ -20,6 +20,11 @@ func servCmdRequiresAuthEnabled(server *Server) bool {
20 20
 	return server.AccountConfig().AuthenticationEnabled
21 21
 }
22 22
 
23
+func nsGroupEnabled(server *Server) bool {
24
+	conf := server.Config()
25
+	return conf.Accounts.AuthenticationEnabled && conf.Accounts.NickReservation.Enabled
26
+}
27
+
23 28
 const nickservHelp = `NickServ lets you register and login to an account.
24 29
 
25 30
 To see in-depth help for a specific NickServ command, try:
@@ -55,7 +60,7 @@ same user account, letting you reclaim your nickname.`,
55 60
 GROUP links your current nickname with your logged-in account, preventing other
56 61
 users from changing to it (or forcing them to rename).`,
57 62
 			helpShort:    `$bGROUP$b links your current nickname to your user account.`,
58
-			enabled:      servCmdRequiresAccreg,
63
+			enabled:      nsGroupEnabled,
59 64
 			authRequired: true,
60 65
 		},
61 66
 
@@ -94,7 +99,7 @@ certificate (and you will need to use that certificate to login in future).`,
94 99
 
95 100
 SADROP forcibly de-links the given nickname from the attached user account.`,
96 101
 			helpShort: `$bSADROP$b forcibly de-links the given nickname from its user account.`,
97
-			capabs:    []string{"unregister"},
102
+			capabs:    []string{"accreg"},
98 103
 			enabled:   servCmdRequiresAccreg,
99 104
 		},
100 105
 		"unregister": {
@@ -259,12 +264,8 @@ func nsRegisterHandler(server *Server, client *Client, command, params string, r
259 264
 	}
260 265
 
261 266
 	if client.LoggedIntoAccount() {
262
-		if server.AccountConfig().Registration.AllowMultiplePerConnection {
263
-			server.accounts.Logout(client)
264
-		} else {
265
-			nsNotice(rb, client.t("You're already logged into an account"))
266
-			return
267
-		}
267
+		nsNotice(rb, client.t("You're already logged into an account"))
268
+		return
268 269
 	}
269 270
 
270 271
 	config := server.AccountConfig()

+ 24
- 28
irc/server.go Parādīt failu

@@ -9,7 +9,6 @@ import (
9 9
 	"bufio"
10 10
 	"crypto/tls"
11 11
 	"fmt"
12
-	"log"
13 12
 	"math/rand"
14 13
 	"net"
15 14
 	"net/http"
@@ -143,22 +142,6 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
143 142
 		return nil, err
144 143
 	}
145 144
 
146
-	// confirm help entries for ChanServ exist.
147
-	// this forces people to write help entries for every single CS command.
148
-	for commandName, commandInfo := range chanservCommands {
149
-		if commandInfo.help == "" || commandInfo.helpShort == "" {
150
-			return nil, fmt.Errorf("Help entry does not exist for ChanServ command %s", commandName)
151
-		}
152
-	}
153
-
154
-	// confirm help entries for NickServ exist.
155
-	// this forces people to write help entries for every single NS command.
156
-	for commandName, commandInfo := range nickservCommands {
157
-		if commandInfo.help == "" || commandInfo.helpShort == "" {
158
-			return nil, fmt.Errorf("Help entry does not exist for NickServ command %s", commandName)
159
-		}
160
-	}
161
-
162 145
 	// Attempt to clean up when receiving these signals.
163 146
 	signal.Notify(server.signals, ServerExitSignals...)
164 147
 	signal.Notify(server.rehashSignal, syscall.SIGHUP)
@@ -325,8 +308,8 @@ func (server *Server) checkBans(ipaddr net.IP) (banned bool, message string) {
325 308
 // IRC protocol listeners
326 309
 //
327 310
 
328
-// createListener starts the given listeners.
329
-func (server *Server) createListener(addr string, tlsConfig *tls.Config) *ListenerWrapper {
311
+// createListener starts a given listener.
312
+func (server *Server) createListener(addr string, tlsConfig *tls.Config) (*ListenerWrapper, error) {
330 313
 	// make listener
331 314
 	var listener net.Listener
332 315
 	var err error
@@ -339,7 +322,7 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen
339 322
 		listener, err = net.Listen("tcp", addr)
340 323
 	}
341 324
 	if err != nil {
342
-		log.Fatal(server, "listen error: ", err)
325
+		return nil, err
343 326
 	}
344 327
 
345 328
 	// throw our details to the server so we can be modified/killed later
@@ -382,7 +365,7 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen
382 365
 		}
383 366
 	}()
384 367
 
385
-	return &wrapper
368
+	return &wrapper, nil
386 369
 }
387 370
 
388 371
 // generateMessageID returns a network-unique message ID.
@@ -896,7 +879,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
896 879
 	}
897 880
 
898 881
 	// we are now open for business
899
-	server.setupListeners(config)
882
+	err = server.setupListeners(config)
900 883
 
901 884
 	if !initial {
902 885
 		// push new info to all of our clients
@@ -911,7 +894,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
911 894
 		}
912 895
 	}
913 896
 
914
-	return nil
897
+	return err
915 898
 }
916 899
 
917 900
 func (server *Server) setupPprofListener(config *Config) {
@@ -1000,15 +983,20 @@ func (server *Server) loadDatastore(config *Config) error {
1000 983
 	return nil
1001 984
 }
1002 985
 
1003
-func (server *Server) setupListeners(config *Config) {
986
+func (server *Server) setupListeners(config *Config) (err error) {
1004 987
 	logListener := func(addr string, tlsconfig *tls.Config) {
1005 988
 		server.logger.Info("listeners",
1006 989
 			fmt.Sprintf("now listening on %s, tls=%t.", addr, (tlsconfig != nil)),
1007 990
 		)
1008 991
 	}
1009 992
 
993
+	tlsListeners, err := config.TLSListeners()
994
+	if err != nil {
995
+		server.logger.Error("rehash", "failed to reload TLS certificates, aborting rehash", err.Error())
996
+		return
997
+	}
998
+
1010 999
 	// update or destroy all existing listeners
1011
-	tlsListeners := config.TLSListeners()
1012 1000
 	for addr := range server.listeners {
1013 1001
 		currentListener := server.listeners[addr]
1014 1002
 		var stillConfigured bool
@@ -1044,7 +1032,13 @@ func (server *Server) setupListeners(config *Config) {
1044 1032
 		if !exists {
1045 1033
 			// make new listener
1046 1034
 			tlsConfig := tlsListeners[newaddr]
1047
-			server.listeners[newaddr] = server.createListener(newaddr, tlsConfig)
1035
+			listener, listenerErr := server.createListener(newaddr, tlsConfig)
1036
+			if listenerErr != nil {
1037
+				server.logger.Error("rehash", "couldn't listen on", newaddr, listenerErr.Error())
1038
+				err = listenerErr
1039
+				continue
1040
+			}
1041
+			server.listeners[newaddr] = listener
1048 1042
 			logListener(newaddr, tlsConfig)
1049 1043
 		}
1050 1044
 	}
@@ -1054,8 +1048,8 @@ func (server *Server) setupListeners(config *Config) {
1054 1048
 	}
1055 1049
 
1056 1050
 	var usesStandardTLSPort bool
1057
-	for addr := range config.TLSListeners() {
1058
-		if strings.Contains(addr, "6697") {
1051
+	for addr := range tlsListeners {
1052
+		if strings.HasSuffix(addr, ":6697") {
1059 1053
 			usesStandardTLSPort = true
1060 1054
 			break
1061 1055
 		}
@@ -1063,6 +1057,8 @@ func (server *Server) setupListeners(config *Config) {
1063 1057
 	if 0 < len(tlsListeners) && !usesStandardTLSPort {
1064 1058
 		server.logger.Warning("startup", "Port 6697 is the standard TLS port for IRC. You should (also) expose port 6697 as a TLS port to ensure clients can connect securely")
1065 1059
 	}
1060
+
1061
+	return
1066 1062
 }
1067 1063
 
1068 1064
 // elistMatcher takes and matches ELIST conditions

+ 33
- 2
irc/services.go Parādīt failu

@@ -5,6 +5,7 @@ package irc
5 5
 
6 6
 import (
7 7
 	"fmt"
8
+	"log"
8 9
 	"sort"
9 10
 	"strings"
10 11
 
@@ -25,6 +26,7 @@ type ircService struct {
25 26
 
26 27
 // defines a command associated with a service, e.g., NICKSERV IDENTIFY
27 28
 type serviceCommand struct {
29
+	aliasOf      string   // marks this command as an alias of another
28 30
 	capabs       []string // oper capabs the given user has to have to access this command
29 31
 	handler      func(server *Server, client *Client, command, params string, rb *ResponseBuffer)
30 32
 	help         string
@@ -33,6 +35,24 @@ type serviceCommand struct {
33 35
 	enabled      func(*Server) bool // is this command enabled in the server config?
34 36
 }
35 37
 
38
+// looks up a command in the table of command definitions for a service, resolving aliases
39
+func lookupServiceCommand(commands map[string]*serviceCommand, command string) *serviceCommand {
40
+	maxDepth := 1
41
+	depth := 0
42
+	for depth <= maxDepth {
43
+		result, ok := commands[command]
44
+		if !ok {
45
+			return nil
46
+		} else if result.aliasOf == "" {
47
+			return result
48
+		} else {
49
+			command = result.aliasOf
50
+			depth += 1
51
+		}
52
+	}
53
+	return nil
54
+}
55
+
36 56
 // all services, by lowercase name
37 57
 var OragonoServices = map[string]*ircService{
38 58
 	"nickserv": {
@@ -93,7 +113,7 @@ func servicePrivmsgHandler(service *ircService, server *Server, client *Client,
93 113
 		rb.Add(nil, service.Name, "NOTICE", nick, notice)
94 114
 	}
95 115
 
96
-	cmd := service.Commands[commandName]
116
+	cmd := lookupServiceCommand(service.Commands, commandName)
97 117
 	if cmd == nil {
98 118
 		sendNotice(fmt.Sprintf("%s /%s HELP", client.t("Unknown command. To see available commands, run"), service.ShortName))
99 119
 		return
@@ -140,6 +160,9 @@ func serviceHelpHandler(service *ircService, server *Server, client *Client, par
140 160
 			if 0 < len(commandInfo.capabs) && !client.HasRoleCapabs(commandInfo.capabs...) {
141 161
 				continue
142 162
 			}
163
+			if commandInfo.aliasOf != "" {
164
+				continue // don't show help lines for aliases
165
+			}
143 166
 			if commandInfo.enabled != nil && !commandInfo.enabled(server) {
144 167
 				disabledCommands = true
145 168
 				continue
@@ -164,7 +187,8 @@ func serviceHelpHandler(service *ircService, server *Server, client *Client, par
164 187
 			sendNotice(line)
165 188
 		}
166 189
 	} else {
167
-		commandInfo := service.Commands[strings.ToLower(strings.TrimSpace(params))]
190
+		commandName := strings.ToLower(strings.TrimSpace(params))
191
+		commandInfo := lookupServiceCommand(service.Commands, commandName)
168 192
 		if commandInfo == nil {
169 193
 			sendNotice(client.t(fmt.Sprintf("Unknown command. To see available commands, run /%s HELP", service.ShortName)))
170 194
 		} else {
@@ -196,5 +220,12 @@ func initializeServices() {
196 220
 			Commands[ircCmd] = ircCmdDef
197 221
 			oragonoServicesByCommandAlias[ircCmd] = service
198 222
 		}
223
+
224
+		// force devs to write a help entry for every command
225
+		for commandName, commandInfo := range service.Commands {
226
+			if commandInfo.aliasOf == "" && (commandInfo.help == "" || commandInfo.helpShort == "") {
227
+				log.Fatal(fmt.Sprintf("help entry missing for %s command %s", serviceName, commandName))
228
+			}
229
+		}
199 230
 	}
200 231
 }

+ 0
- 15
oragono.go Parādīt failu

@@ -17,7 +17,6 @@ import (
17 17
 	"github.com/oragono/oragono/irc"
18 18
 	"github.com/oragono/oragono/irc/logger"
19 19
 	"github.com/oragono/oragono/irc/mkcerts"
20
-	stackimpact "github.com/stackimpact/stackimpact-go"
21 20
 	"golang.org/x/crypto/bcrypt"
22 21
 	"golang.org/x/crypto/ssh/terminal"
23 22
 )
@@ -127,20 +126,6 @@ Options:
127 126
 			irc.Ver = fmt.Sprintf("%s-%s", irc.Ver, commit)
128 127
 		}
129 128
 
130
-		// profiling
131
-		if config.Debug.StackImpact.Enabled {
132
-			if config.Debug.StackImpact.AgentKey == "" || config.Debug.StackImpact.AppName == "" {
133
-				logman.Error("startup", "Could not start StackImpact - agent-key or app-name are undefined")
134
-				return
135
-			}
136
-
137
-			agent := stackimpact.NewAgent()
138
-			agent.Start(stackimpact.Options{AgentKey: config.Debug.StackImpact.AgentKey, AppName: config.Debug.StackImpact.AppName})
139
-			defer agent.RecordPanic()
140
-
141
-			logman.Info("startup", fmt.Sprintf("StackImpact profiling started as %s", config.Debug.StackImpact.AppName))
142
-		}
143
-
144 129
 		// warning if running a non-final version
145 130
 		if strings.Contains(irc.SemVer, "unreleased") {
146 131
 			logman.Warning("startup", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.")

+ 0
- 15
oragono.yaml Parādīt failu

@@ -166,10 +166,6 @@ accounts:
166 166
         #         password: ""
167 167
         #         sender: "admin@my.network"
168 168
 
169
-        # allow multiple account registrations per connection
170
-        # this is for testing purposes and shouldn't be allowed on real networks
171
-        allow-multiple-per-connection: false
172
-
173 169
     # is account authentication enabled?
174 170
     authentication-enabled: true
175 171
 
@@ -362,17 +358,6 @@ debug:
362 358
     # set to `null`, "", leave blank, or omit to disable
363 359
     # pprof-listener: "localhost:6060"
364 360
 
365
-    # enabling StackImpact profiling
366
-    stackimpact:
367
-        # whether to use StackImpact
368
-        enabled: false
369
-
370
-        # the AgentKey to use
371
-        agent-key: examplekeyhere
372
-
373
-        # the app name to report
374
-        app-name: Oragono
375
-
376 361
 # datastore configuration
377 362
 datastore:
378 363
     # path to the datastore

+ 1
- 1
vendor

@@ -1 +1 @@
1
-Subproject commit 9dd7467d3dfc045cf5dee2f6f6951465437e2ac5
1
+Subproject commit 77ddc3dbc1ec085c73670510a8fece80599741ce

Notiek ielāde…
Atcelt
Saglabāt