|
@@ -330,7 +330,7 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config, isTor b
|
330
|
330
|
// server functionality
|
331
|
331
|
//
|
332
|
332
|
|
333
|
|
-func (server *Server) tryRegister(c *Client, session *Session) {
|
|
333
|
+func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
|
334
|
334
|
// if the session just sent us a RESUME line, try to resume
|
335
|
335
|
if session.resumeDetails != nil {
|
336
|
336
|
session.tryResume()
|
|
@@ -344,11 +344,19 @@ func (server *Server) tryRegister(c *Client, session *Session) {
|
344
|
344
|
|
345
|
345
|
// client MUST send PASS if necessary, or authenticate with SASL if necessary,
|
346
|
346
|
// before completing the other registration commands
|
347
|
|
- config := server.Config()
|
348
|
|
- if !c.isAuthorized(config) {
|
349
|
|
- c.Quit(c.t("Bad password"), nil)
|
350
|
|
- c.destroy(nil)
|
351
|
|
- return
|
|
347
|
+ authOutcome := c.isAuthorized(server.Config())
|
|
348
|
+ var quitMessage string
|
|
349
|
+ switch authOutcome {
|
|
350
|
+ case authFailPass:
|
|
351
|
+ quitMessage = c.t("Password incorrect")
|
|
352
|
+ c.Send(nil, server.name, ERR_PASSWDMISMATCH, "*", quitMessage)
|
|
353
|
+ case authFailSaslRequired, authFailTorSaslRequired:
|
|
354
|
+ quitMessage = c.t("You must log in with SASL to join this server")
|
|
355
|
+ c.Send(nil, c.server.name, "FAIL", "*", "ACCOUNT_REQUIRED", quitMessage)
|
|
356
|
+ }
|
|
357
|
+ if authOutcome != authSuccess {
|
|
358
|
+ c.Quit(quitMessage, nil)
|
|
359
|
+ return true
|
352
|
360
|
}
|
353
|
361
|
|
354
|
362
|
rb := NewResponseBuffer(session)
|
|
@@ -363,8 +371,7 @@ func (server *Server) tryRegister(c *Client, session *Session) {
|
363
|
371
|
isBanned, info := server.klines.CheckMasks(c.AllNickmasks()...)
|
364
|
372
|
if isBanned {
|
365
|
373
|
c.Quit(info.BanMessage(c.t("You are banned from this server (%s)")), nil)
|
366
|
|
- c.destroy(nil)
|
367
|
|
- return
|
|
374
|
+ return true
|
368
|
375
|
}
|
369
|
376
|
|
370
|
377
|
if session.client != c {
|
|
@@ -377,12 +384,13 @@ func (server *Server) tryRegister(c *Client, session *Session) {
|
377
|
384
|
|
378
|
385
|
// registration has succeeded:
|
379
|
386
|
c.SetRegistered()
|
|
387
|
+
|
380
|
388
|
// count new user in statistics
|
381
|
389
|
server.stats.ChangeTotal(1)
|
|
390
|
+ server.monitorManager.AlertAbout(c, true)
|
382
|
391
|
|
383
|
392
|
server.playRegistrationBurst(session)
|
384
|
|
-
|
385
|
|
- server.monitorManager.AlertAbout(c, true)
|
|
393
|
+ return false
|
386
|
394
|
}
|
387
|
395
|
|
388
|
396
|
func (server *Server) playRegistrationBurst(session *Session) {
|