|
@@ -403,28 +403,17 @@ func (am *AccountManager) Register(client *Client, account string, callbackNames
|
403
|
403
|
return errLimitExceeded
|
404
|
404
|
}
|
405
|
405
|
|
406
|
|
- // if nick reservation is enabled, you can only register your current nickname
|
407
|
|
- // as an account; this prevents "land-grab" situations where someone else
|
408
|
|
- // registers your nick out from under you and then NS GHOSTs you
|
409
|
|
- // n.b. client is nil during a SAREGISTER
|
410
|
|
- // n.b. if ForceGuestFormat, then there's no concern, because you can't
|
411
|
|
- // register a guest nickname anyway, and the actual registration system
|
412
|
|
- // will prevent any double-register
|
413
|
|
- if client != nil {
|
414
|
|
- if client.registered {
|
415
|
|
- if config.Accounts.NickReservation.Enabled &&
|
416
|
|
- !config.Accounts.NickReservation.ForceGuestFormat &&
|
417
|
|
- client.NickCasefolded() != casefoldedAccount {
|
418
|
|
- return errAccountMustHoldNick
|
419
|
|
- }
|
420
|
|
- } else {
|
421
|
|
- // XXX this is a REGISTER command from a client who hasn't completed the
|
422
|
|
- // initial handshake ("connection registration"). Do SetNick with dryRun=true,
|
423
|
|
- // testing whether they are able to claim the nick
|
424
|
|
- _, nickAcquireError, _ := am.server.clients.SetNick(client, nil, account, true)
|
425
|
|
- if !(nickAcquireError == nil || nickAcquireError == errNoop) {
|
426
|
|
- return errAccountMustHoldNick
|
427
|
|
- }
|
|
406
|
+ // if nick reservation is enabled, don't let people reserve nicknames
|
|
407
|
+ // that they would not be eligible to take, e.g.,
|
|
408
|
+ // 1. a nickname that someone else is currently holding
|
|
409
|
+ // 2. a nickname confusable with an existing reserved nickname
|
|
410
|
+ // this has a lot of weird edge cases because of force-guest-format
|
|
411
|
+ // and the possibility of registering a nickname on an "unregistered connection"
|
|
412
|
+ // (i.e., pre-handshake).
|
|
413
|
+ if client != nil && config.Accounts.NickReservation.Enabled {
|
|
414
|
+ _, nickAcquireError, _ := am.server.clients.SetNick(client, nil, account, true)
|
|
415
|
+ if !(nickAcquireError == nil || nickAcquireError == errNoop) {
|
|
416
|
+ return errAccountMustHoldNick
|
428
|
417
|
}
|
429
|
418
|
}
|
430
|
419
|
|