Browse Source

Merge pull request #1620 from slingamn/bugs

small fixes to kick off the 2.7 window
tags/v2.7.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
3ceb346c61
No account linked to committer's email address
6 changed files with 42 additions and 11 deletions
  1. 2
    0
      default.yaml
  2. 7
    0
      irc/channelmanager.go
  3. 20
    5
      irc/config.go
  4. 10
    5
      irc/modes.go
  5. 1
    1
      irctest
  6. 2
    0
      traditional.yaml

+ 2
- 0
default.yaml View File

@@ -58,6 +58,8 @@ server:
58 58
             # always send a PROXY protocol header ahead of the connection. See the
59 59
             # manual ("Reverse proxies") for more details.
60 60
             proxy: false
61
+            # set the minimum TLS version:
62
+            min-tls-version: 1.2
61 63
 
62 64
         # Example of a Unix domain socket for proxying:
63 65
         # "/tmp/oragono_sock":

+ 7
- 0
irc/channelmanager.go View File

@@ -176,6 +176,10 @@ func (cm *ChannelManager) maybeCleanup(channel *Channel, afterJoin bool) {
176 176
 		return
177 177
 	}
178 178
 
179
+	cm.maybeCleanupInternal(cfname, entry, afterJoin)
180
+}
181
+
182
+func (cm *ChannelManager) maybeCleanupInternal(cfname string, entry *channelManagerEntry, afterJoin bool) {
179 183
 	if afterJoin {
180 184
 		entry.pendingJoins -= 1
181 185
 	}
@@ -288,6 +292,9 @@ func (cm *ChannelManager) SetUnregistered(channelName string, account string) (e
288 292
 			entry.skeleton = skel
289 293
 			cm.chans[cfname] = entry
290 294
 		}
295
+		// #1619: if the channel has 0 members and was only being retained
296
+		// because it was registered, clean it up:
297
+		cm.maybeCleanupInternal(cfname, entry, false)
291 298
 	}
292 299
 	return nil
293 300
 }

+ 20
- 5
irc/config.go View File

@@ -59,6 +59,7 @@ type listenerConfigBlock struct {
59 59
 	TLS TLSListenConfig
60 60
 	// SNI configuration, with multiple certificates:
61 61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
62
+	MinTLSVersion   string            `yaml:"min-tls-version"`
62 63
 	Proxy           bool
63 64
 	Tor             bool
64 65
 	STSOnly         bool `yaml:"sts-only"`
@@ -881,10 +882,29 @@ func loadTlsConfig(config listenerConfigBlock) (tlsConfig *tls.Config, err error
881 882
 	result := tls.Config{
882 883
 		Certificates: certificates,
883 884
 		ClientAuth:   clientAuth,
885
+		MinVersion:   tlsMinVersionFromString(config.MinTLSVersion),
884 886
 	}
885 887
 	return &result, nil
886 888
 }
887 889
 
890
+func tlsMinVersionFromString(version string) uint16 {
891
+	version = strings.ToLower(version)
892
+	version = strings.TrimPrefix(version, "v")
893
+	switch version {
894
+	case "1", "1.0":
895
+		return tls.VersionTLS10
896
+	case "1.1":
897
+		return tls.VersionTLS11
898
+	case "1.2":
899
+		return tls.VersionTLS12
900
+	case "1.3":
901
+		return tls.VersionTLS13
902
+	default:
903
+		// tls package will fill in a sane value, currently 1.0
904
+		return 0
905
+	}
906
+}
907
+
888 908
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
889 909
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
890 910
 	// the parsed form of the certificate is not retained." tls.Config:
@@ -1477,11 +1497,6 @@ func LoadConfig(filename string) (config *Config, err error) {
1477 1497
 		return nil, err
1478 1498
 	}
1479 1499
 
1480
-	err = config.prepareListeners()
1481
-	if err != nil {
1482
-		return nil, fmt.Errorf("failed to prepare listeners: %v", err)
1483
-	}
1484
-
1485 1500
 	// #1428: Tor listeners should never see STS
1486 1501
 	config.Server.supportedCapsWithoutSTS = caps.NewSet()
1487 1502
 	config.Server.supportedCapsWithoutSTS.Union(config.Server.supportedCaps)

+ 10
- 5
irc/modes.go View File

@@ -32,6 +32,9 @@ var (
32 32
 // to confirm that the client actually has a valid operclass)
33 33
 func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, oper *Oper) modes.ModeChanges {
34 34
 	applied := make(modes.ModeChanges, 0)
35
+	// #1617: if the user is offline, they are not counted in LUSERS,
36
+	// so don't modify the LUSERS stats for +i or +o.
37
+	present := len(client.Sessions()) != 0
35 38
 
36 39
 	for _, change := range changes {
37 40
 		if change.Mode != modes.ServerNotice {
@@ -42,9 +45,9 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool,
42 45
 				}
43 46
 
44 47
 				if client.SetMode(change.Mode, true) {
45
-					if change.Mode == modes.Invisible {
48
+					if change.Mode == modes.Invisible && present {
46 49
 						client.server.stats.ChangeInvisible(1)
47
-					} else if change.Mode == modes.Operator {
50
+					} else if change.Mode == modes.Operator && present {
48 51
 						client.server.stats.ChangeOperators(1)
49 52
 					}
50 53
 					applied = append(applied, change)
@@ -53,11 +56,13 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool,
53 56
 			case modes.Remove:
54 57
 				var removedSnomasks string
55 58
 				if client.SetMode(change.Mode, false) {
56
-					if change.Mode == modes.Invisible {
59
+					if change.Mode == modes.Invisible && present {
57 60
 						client.server.stats.ChangeInvisible(-1)
58 61
 					} else if change.Mode == modes.Operator {
59 62
 						removedSnomasks = client.server.snomasks.String(client)
60
-						client.server.stats.ChangeOperators(-1)
63
+						if present {
64
+							client.server.stats.ChangeOperators(-1)
65
+						}
61 66
 						applyOper(client, nil, nil)
62 67
 						if removedSnomasks != "" {
63 68
 							client.server.snomasks.RemoveClient(client)
@@ -86,7 +91,7 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool,
86 91
 			if len(addMasks) != 0 {
87 92
 				oper := client.Oper()
88 93
 				// #1176: require special operator privileges to subscribe to snomasks
89
-				if oper.HasRoleCapab("snomasks") || oper.HasRoleCapab("ban") {
94
+				if force || oper.HasRoleCapab("snomasks") || oper.HasRoleCapab("ban") {
90 95
 					success = true
91 96
 					client.server.snomasks.AddMasks(client, addMasks...)
92 97
 				}

+ 1
- 1
irctest

@@ -1 +1 @@
1
-Subproject commit 5e622a34d38be329aec98b3b983a239fe3e1b4b7
1
+Subproject commit 322cb7ae26a2a94a0daec5458373319fa4e0e743

+ 2
- 0
traditional.yaml View File

@@ -32,6 +32,8 @@ server:
32 32
             # always send a PROXY protocol header ahead of the connection. See the
33 33
             # manual ("Reverse proxies") for more details.
34 34
             proxy: false
35
+            # optionally set the minimum TLS version (defaults to 1.0):
36
+            # min-tls-version: 1.2
35 37
 
36 38
         # Example of a Unix domain socket for proxying:
37 39
         # "/tmp/oragono_sock":

Loading…
Cancel
Save