Browse Source

rename 'bouncer' to 'multiclient'

tags/v2.0.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
f5ca35ed72
9 changed files with 53 additions and 68 deletions
  1. 0
    6
      gencapdefs.py
  2. 9
    7
      irc/accounts.go
  3. 1
    6
      irc/caps/defs.go
  4. 4
    6
      irc/client_lookup_set.go
  5. 12
    17
      irc/config.go
  6. 2
    2
      irc/database.go
  7. 2
    2
      irc/getters.go
  8. 19
    19
      irc/nickserv.go
  9. 4
    3
      oragono.yaml

+ 0
- 6
gencapdefs.py View File

@@ -135,12 +135,6 @@ CAPDEFS = [
135 135
         url="https://ircv3.net/specs/extensions/userhost-in-names-3.2.html",
136 136
         standard="IRCv3",
137 137
     ),
138
-    CapDef(
139
-        identifier="Bouncer",
140
-        name="oragono.io/bnc",
141
-        url="https://oragono.io/bnc",
142
-        standard="Oragono-specific",
143
-    ),
144 138
     CapDef(
145 139
         identifier="ZNCSelfMessage",
146 140
         name="znc.in/self-message",

+ 9
- 7
irc/accounts.go View File

@@ -77,7 +77,7 @@ func (am *AccountManager) Initialize(server *Server) {
77 77
 }
78 78
 
79 79
 func (am *AccountManager) createAlwaysOnClients(config *Config) {
80
-	if config.Accounts.Bouncer.AlwaysOn == PersistentDisabled {
80
+	if config.Accounts.Multiclient.AlwaysOn == PersistentDisabled {
81 81
 		return
82 82
 	}
83 83
 
@@ -103,7 +103,7 @@ func (am *AccountManager) createAlwaysOnClients(config *Config) {
103 103
 	for _, accountName := range accounts {
104 104
 		account, err := am.LoadAccount(accountName)
105 105
 		if err == nil && account.Verified &&
106
-			persistenceEnabled(config.Accounts.Bouncer.AlwaysOn, account.Settings.AlwaysOn) {
106
+			persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, account.Settings.AlwaysOn) {
107 107
 			am.server.AddAlwaysOnClient(account, am.loadChannels(accountName), am.loadLastSignoff(accountName))
108 108
 		}
109 109
 	}
@@ -1676,12 +1676,12 @@ func (ac *AccountCredentials) RemoveCertfp(certfp string) (err error) {
1676 1676
 	return nil
1677 1677
 }
1678 1678
 
1679
-type BouncerAllowedSetting int
1679
+type MulticlientAllowedSetting int
1680 1680
 
1681 1681
 const (
1682
-	BouncerAllowedServerDefault BouncerAllowedSetting = iota
1683
-	BouncerDisallowedByUser
1684
-	BouncerAllowedByUser
1682
+	MulticlientAllowedServerDefault MulticlientAllowedSetting = iota
1683
+	MulticlientDisallowedByUser
1684
+	MulticlientAllowedByUser
1685 1685
 )
1686 1686
 
1687 1687
 // controls whether/when clients without event-playback support see fake
@@ -1708,10 +1708,12 @@ func replayJoinsSettingFromString(str string) (result ReplayJoinsSetting, err er
1708 1708
 	return
1709 1709
 }
1710 1710
 
1711
+// XXX: AllowBouncer cannot be renamed AllowMulticlient because it is stored in
1712
+// persistent JSON blobs in the database
1711 1713
 type AccountSettings struct {
1712 1714
 	AutoreplayLines  *int
1713 1715
 	NickEnforcement  NickEnforcementMethod
1714
-	AllowBouncer     BouncerAllowedSetting
1716
+	AllowBouncer     MulticlientAllowedSetting
1715 1717
 	ReplayJoins      ReplayJoinsSetting
1716 1718
 	AlwaysOn         PersistentStatus
1717 1719
 	AutoreplayMissed bool

+ 1
- 6
irc/caps/defs.go View File

@@ -7,7 +7,7 @@ package caps
7 7
 
8 8
 const (
9 9
 	// number of recognized capabilities:
10
-	numCapabs = 27
10
+	numCapabs = 26
11 11
 	// length of the uint64 array that represents the bitset:
12 12
 	bitsetLen = 1
13 13
 )
@@ -89,10 +89,6 @@ const (
89 89
 	// https://ircv3.net/specs/extensions/multi-prefix-3.1.html
90 90
 	MultiPrefix Capability = iota
91 91
 
92
-	// Bouncer is the Oragono-specific capability named "oragono.io/bnc":
93
-	// https://oragono.io/bnc
94
-	Bouncer Capability = iota
95
-
96 92
 	// Nope is the Oragono vendor capability named "oragono.io/nope":
97 93
 	// https://oragono.io/nope
98 94
 	Nope Capability = iota
@@ -144,7 +140,6 @@ var (
144 140
 		"labeled-response",
145 141
 		"message-tags",
146 142
 		"multi-prefix",
147
-		"oragono.io/bnc",
148 143
 		"oragono.io/nope",
149 144
 		"sasl",
150 145
 		"server-time",

+ 4
- 6
irc/client_lookup_set.go View File

@@ -142,25 +142,23 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
142 142
 	client.stateMutex.RUnlock()
143 143
 
144 144
 	// recompute this (client.alwaysOn is not set for unregistered clients):
145
-	alwaysOn := account != "" && persistenceEnabled(config.Accounts.Bouncer.AlwaysOn, settings.AlwaysOn)
145
+	alwaysOn := account != "" && persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
146 146
 
147 147
 	if alwaysOn && registered {
148 148
 		return "", errCantChangeNick
149 149
 	}
150 150
 
151 151
 	var bouncerAllowed bool
152
-	if config.Accounts.Bouncer.Enabled {
152
+	if config.Accounts.Multiclient.Enabled {
153 153
 		if alwaysOn {
154 154
 			// ignore the pre-reg nick, force a reattach
155 155
 			newNick = accountName
156 156
 			newcfnick = account
157 157
 			bouncerAllowed = true
158
-		} else if session != nil && session.capabilities.Has(caps.Bouncer) {
159
-			bouncerAllowed = true
160 158
 		} else {
161
-			if config.Accounts.Bouncer.AllowedByDefault && settings.AllowBouncer != BouncerDisallowedByUser {
159
+			if config.Accounts.Multiclient.AllowedByDefault && settings.AllowBouncer != MulticlientDisallowedByUser {
162 160
 				bouncerAllowed = true
163
-			} else if settings.AllowBouncer == BouncerAllowedByUser {
161
+			} else if settings.AllowBouncer == MulticlientAllowedByUser {
164 162
 				bouncerAllowed = true
165 163
 			}
166 164
 		}

+ 12
- 17
irc/config.go View File

@@ -207,6 +207,12 @@ func historyEnabled(serverSetting PersistentStatus, localSetting HistoryStatus)
207 207
 	}
208 208
 }
209 209
 
210
+type MulticlientConfig struct {
211
+	Enabled          bool
212
+	AllowedByDefault bool             `yaml:"allowed-by-default"`
213
+	AlwaysOn         PersistentStatus `yaml:"always-on"`
214
+}
215
+
210 216
 type AccountConfig struct {
211 217
 	Registration          AccountRegistrationConfig
212 218
 	AuthenticationEnabled bool `yaml:"authentication-enabled"`
@@ -223,12 +229,8 @@ type AccountConfig struct {
223 229
 	} `yaml:"login-throttling"`
224 230
 	SkipServerPassword bool                  `yaml:"skip-server-password"`
225 231
 	NickReservation    NickReservationConfig `yaml:"nick-reservation"`
226
-	Bouncer            struct {
227
-		Enabled          bool
228
-		AllowedByDefault bool             `yaml:"allowed-by-default"`
229
-		AlwaysOn         PersistentStatus `yaml:"always-on"`
230
-	}
231
-	VHosts VHostConfig
232
+	Multiclient        MulticlientConfig
233
+	VHosts             VHostConfig
232 234
 }
233 235
 
234 236
 // AccountRegistrationConfig controls account registration.
@@ -878,11 +880,10 @@ func LoadConfig(filename string) (config *Config, err error) {
878 880
 		config.Server.capValues[caps.Multiline] = multilineCapValue
879 881
 	}
880 882
 
881
-	if !config.Accounts.Bouncer.Enabled {
882
-		config.Accounts.Bouncer.AlwaysOn = PersistentDisabled
883
-		config.Server.supportedCaps.Disable(caps.Bouncer)
884
-	} else if config.Accounts.Bouncer.AlwaysOn >= PersistentOptOut {
885
-		config.Accounts.Bouncer.AllowedByDefault = true
883
+	if !config.Accounts.Multiclient.Enabled {
884
+		config.Accounts.Multiclient.AlwaysOn = PersistentDisabled
885
+	} else if config.Accounts.Multiclient.AlwaysOn >= PersistentOptOut {
886
+		config.Accounts.Multiclient.AllowedByDefault = true
886 887
 	}
887 888
 
888 889
 	var newLogConfigs []logger.LoggingConfig
@@ -1148,12 +1149,6 @@ func (config *Config) Diff(oldConfig *Config) (addedCaps, removedCaps *caps.Set)
1148 1149
 		removedCaps.Add(caps.SASL)
1149 1150
 	}
1150 1151
 
1151
-	if !oldConfig.Accounts.Bouncer.Enabled && config.Accounts.Bouncer.Enabled {
1152
-		addedCaps.Add(caps.Bouncer)
1153
-	} else if oldConfig.Accounts.Bouncer.Enabled && !config.Accounts.Bouncer.Enabled {
1154
-		removedCaps.Add(caps.Bouncer)
1155
-	}
1156
-
1157 1152
 	if oldConfig.Limits.Multiline.MaxBytes != 0 && config.Limits.Multiline.MaxBytes == 0 {
1158 1153
 		removedCaps.Add(caps.Multiline)
1159 1154
 	} else if oldConfig.Limits.Multiline.MaxBytes == 0 && config.Limits.Multiline.MaxBytes != 0 {

+ 2
- 2
irc/database.go View File

@@ -487,14 +487,14 @@ func schemaChangeV6ToV7(config *Config, tx *buntdb.Tx) error {
487 487
 type accountSettingsLegacyV7 struct {
488 488
 	AutoreplayLines *int
489 489
 	NickEnforcement NickEnforcementMethod
490
-	AllowBouncer    BouncerAllowedSetting
490
+	AllowBouncer    MulticlientAllowedSetting
491 491
 	AutoreplayJoins bool
492 492
 }
493 493
 
494 494
 type accountSettingsLegacyV8 struct {
495 495
 	AutoreplayLines *int
496 496
 	NickEnforcement NickEnforcementMethod
497
-	AllowBouncer    BouncerAllowedSetting
497
+	AllowBouncer    MulticlientAllowedSetting
498 498
 	ReplayJoins     ReplayJoinsSetting
499 499
 }
500 500
 

+ 2
- 2
irc/getters.go View File

@@ -287,7 +287,7 @@ func (client *Client) AccountName() string {
287 287
 }
288 288
 
289 289
 func (client *Client) Login(account ClientAccount) {
290
-	alwaysOn := persistenceEnabled(client.server.Config().Accounts.Bouncer.AlwaysOn, account.Settings.AlwaysOn)
290
+	alwaysOn := persistenceEnabled(client.server.Config().Accounts.Multiclient.AlwaysOn, account.Settings.AlwaysOn)
291 291
 	client.stateMutex.Lock()
292 292
 	defer client.stateMutex.Unlock()
293 293
 	client.account = account.NameCasefolded
@@ -329,7 +329,7 @@ func (client *Client) AccountSettings() (result AccountSettings) {
329 329
 }
330 330
 
331 331
 func (client *Client) SetAccountSettings(settings AccountSettings) {
332
-	alwaysOn := persistenceEnabled(client.server.Config().Accounts.Bouncer.AlwaysOn, settings.AlwaysOn)
332
+	alwaysOn := persistenceEnabled(client.server.Config().Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
333 333
 	client.stateMutex.Lock()
334 334
 	client.accountSettings = settings
335 335
 	if client.registered {

+ 19
- 19
irc/nickserv.go View File

@@ -31,7 +31,7 @@ func servCmdRequiresNickRes(config *Config) bool {
31 31
 }
32 32
 
33 33
 func servCmdRequiresBouncerEnabled(config *Config) bool {
34
-	return config.Accounts.Bouncer.Enabled
34
+	return config.Accounts.Multiclient.Enabled
35 35
 }
36 36
 
37 37
 const (
@@ -147,7 +147,7 @@ an administrator can set use this command to set up user accounts.`,
147 147
 			help: `Syntax: $bSESSIONS [nickname]$b
148 148
 
149 149
 SESSIONS lists information about the sessions currently attached, via
150
-the server's bouncer functionality, to your nickname. An administrator
150
+the server's multiclient functionality, to your nickname. An administrator
151 151
 can use this command to list another user's sessions.`,
152 152
 			helpShort: `$bSESSIONS$b lists the sessions attached to a nickname.`,
153 153
 			enabled:   servCmdRequiresBouncerEnabled,
@@ -228,8 +228,8 @@ nicknames. Your options are:
228 228
 3. 'strict'  [you must already be authenticated to use the nick]
229 229
 4. 'default' [use the server default]`,
230 230
 
231
-				`$bBOUNCER$b
232
-If 'bouncer' is enabled and you are already logged in and using a nick, a
231
+				`$bMULTICLIENT$b
232
+If 'multiclient' is enabled and you are already logged in and using a nick, a
233 233
 second client of yours that authenticates with SASL and requests the same nick
234 234
 is allowed to attach to the nick as well (this is comparable to the behavior
235 235
 of IRC "bouncers" like ZNC). Your options are 'on' (allow this behavior),
@@ -348,21 +348,21 @@ func displaySetting(settingName string, settings AccountSettings, client *Client
348 348
 		case ReplayJoinsNever:
349 349
 			nsNotice(rb, client.t("You will not see JOINs and PARTs in /HISTORY output or in autoreplay"))
350 350
 		}
351
-	case "bouncer":
352
-		if !config.Accounts.Bouncer.Enabled {
351
+	case "multiclient":
352
+		if !config.Accounts.Multiclient.Enabled {
353 353
 			nsNotice(rb, client.t("This feature has been disabled by the server administrators"))
354 354
 		} else {
355 355
 			switch settings.AllowBouncer {
356
-			case BouncerAllowedServerDefault:
357
-				if config.Accounts.Bouncer.AllowedByDefault {
358
-					nsNotice(rb, client.t("Bouncer functionality is currently enabled for your account, but you can opt out"))
356
+			case MulticlientAllowedServerDefault:
357
+				if config.Accounts.Multiclient.AllowedByDefault {
358
+					nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account, but you can opt out"))
359 359
 				} else {
360
-					nsNotice(rb, client.t("Bouncer functionality is currently disabled for your account, but you can opt in"))
360
+					nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account, but you can opt in"))
361 361
 				}
362
-			case BouncerDisallowedByUser:
363
-				nsNotice(rb, client.t("Bouncer functionality is currently disabled for your account"))
364
-			case BouncerAllowedByUser:
365
-				nsNotice(rb, client.t("Bouncer functionality is currently enabled for your account"))
362
+			case MulticlientDisallowedByUser:
363
+				nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account"))
364
+			case MulticlientAllowedByUser:
365
+				nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account"))
366 366
 			}
367 367
 		}
368 368
 	case "always-on":
@@ -440,17 +440,17 @@ func nsSetHandler(server *Server, client *Client, command string, params []strin
440 440
 			out.AutoreplayLines = newValue
441 441
 			return
442 442
 		}
443
-	case "bouncer":
444
-		var newValue BouncerAllowedSetting
443
+	case "multiclient":
444
+		var newValue MulticlientAllowedSetting
445 445
 		if strings.ToLower(params[1]) == "default" {
446
-			newValue = BouncerAllowedServerDefault
446
+			newValue = MulticlientAllowedServerDefault
447 447
 		} else {
448 448
 			var enabled bool
449 449
 			enabled, err = utils.StringToBool(params[1])
450 450
 			if enabled {
451
-				newValue = BouncerAllowedByUser
451
+				newValue = MulticlientAllowedByUser
452 452
 			} else {
453
-				newValue = BouncerDisallowedByUser
453
+				newValue = MulticlientDisallowedByUser
454 454
 			}
455 455
 		}
456 456
 		if err == nil {

+ 4
- 3
oragono.yaml View File

@@ -346,9 +346,10 @@ accounts:
346 346
         # rename-prefix - this is the prefix to use when renaming clients (e.g. Guest-AB54U31)
347 347
         rename-prefix: Guest-
348 348
 
349
-    # bouncer controls whether oragono can act as a bouncer, i.e., allowing
350
-    # multiple connections to attach to the same client/nickname identity
351
-    bouncer:
349
+    # multiclient controls whether oragono allows multiple connections to
350
+    # attach to the same client/nickname identity; this is part of the
351
+    # functionality traditionally provided by a bouncer like ZNC
352
+    multiclient:
352 353
         # when disabled, each connection must use a separate nickname (as is the
353 354
         # typical behavior of IRC servers). when enabled, a new connection that
354 355
         # has authenticated with SASL can associate itself with an existing

Loading…
Cancel
Save