Browse Source

fix handling of nil session in reattach code

tags/v1.1.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
278e4acf57
2 changed files with 5 additions and 2 deletions
  1. 4
    1
      irc/accounts.go
  2. 1
    1
      irc/client_lookup_set.go

+ 4
- 1
irc/accounts.go View File

@@ -238,7 +238,10 @@ func (am *AccountManager) BouncerAllowed(account string, session *Session) bool
238 238
 	if !config.Accounts.Bouncer.Enabled {
239 239
 		return false
240 240
 	}
241
-	return config.Accounts.Bouncer.AllowedByDefault || session.capabilities.Has(caps.Bouncer)
241
+	if config.Accounts.Bouncer.AllowedByDefault {
242
+		return true
243
+	}
244
+	return session != nil && session.capabilities.Has(caps.Bouncer)
242 245
 }
243 246
 
244 247
 // Looks up the enforcement method stored in the database for an account

+ 1
- 1
irc/client_lookup_set.go View File

@@ -152,7 +152,7 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
152 152
 
153 153
 	currentClient := clients.byNick[newcfnick]
154 154
 	// the client may just be changing case
155
-	if currentClient != nil && currentClient != client {
155
+	if currentClient != nil && currentClient != client && session != nil {
156 156
 		// these conditions forbid reattaching to an existing session:
157 157
 		if client.Registered() || !bouncerAllowed || account == "" || account != currentClient.Account() || client.isTor != currentClient.isTor || client.HasMode(modes.TLS) != currentClient.HasMode(modes.TLS) {
158 158
 			return errNicknameInUse

Loading…
Cancel
Save