Kaynağa Gözat

Merge pull request #1620 from slingamn/bugs

small fixes to kick off the 2.7 window
tags/v2.7.0-rc1
Shivaram Lingamneni 3 yıl önce
ebeveyn
işleme
3ceb346c61
No account linked to committer's email address
6 değiştirilmiş dosya ile 42 ekleme ve 11 silme
  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 Dosyayı Görüntüle

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

+ 7
- 0
irc/channelmanager.go Dosyayı Görüntüle

176
 		return
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
 	if afterJoin {
183
 	if afterJoin {
180
 		entry.pendingJoins -= 1
184
 		entry.pendingJoins -= 1
181
 	}
185
 	}
288
 			entry.skeleton = skel
292
 			entry.skeleton = skel
289
 			cm.chans[cfname] = entry
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
 	return nil
299
 	return nil
293
 }
300
 }

+ 20
- 5
irc/config.go Dosyayı Görüntüle

59
 	TLS TLSListenConfig
59
 	TLS TLSListenConfig
60
 	// SNI configuration, with multiple certificates:
60
 	// SNI configuration, with multiple certificates:
61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
62
+	MinTLSVersion   string            `yaml:"min-tls-version"`
62
 	Proxy           bool
63
 	Proxy           bool
63
 	Tor             bool
64
 	Tor             bool
64
 	STSOnly         bool `yaml:"sts-only"`
65
 	STSOnly         bool `yaml:"sts-only"`
881
 	result := tls.Config{
882
 	result := tls.Config{
882
 		Certificates: certificates,
883
 		Certificates: certificates,
883
 		ClientAuth:   clientAuth,
884
 		ClientAuth:   clientAuth,
885
+		MinVersion:   tlsMinVersionFromString(config.MinTLSVersion),
884
 	}
886
 	}
885
 	return &result, nil
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
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
908
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
889
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
909
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
890
 	// the parsed form of the certificate is not retained." tls.Config:
910
 	// the parsed form of the certificate is not retained." tls.Config:
1477
 		return nil, err
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
 	// #1428: Tor listeners should never see STS
1500
 	// #1428: Tor listeners should never see STS
1486
 	config.Server.supportedCapsWithoutSTS = caps.NewSet()
1501
 	config.Server.supportedCapsWithoutSTS = caps.NewSet()
1487
 	config.Server.supportedCapsWithoutSTS.Union(config.Server.supportedCaps)
1502
 	config.Server.supportedCapsWithoutSTS.Union(config.Server.supportedCaps)

+ 10
- 5
irc/modes.go Dosyayı Görüntüle

32
 // to confirm that the client actually has a valid operclass)
32
 // to confirm that the client actually has a valid operclass)
33
 func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, oper *Oper) modes.ModeChanges {
33
 func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, oper *Oper) modes.ModeChanges {
34
 	applied := make(modes.ModeChanges, 0)
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
 	for _, change := range changes {
39
 	for _, change := range changes {
37
 		if change.Mode != modes.ServerNotice {
40
 		if change.Mode != modes.ServerNotice {
42
 				}
45
 				}
43
 
46
 
44
 				if client.SetMode(change.Mode, true) {
47
 				if client.SetMode(change.Mode, true) {
45
-					if change.Mode == modes.Invisible {
48
+					if change.Mode == modes.Invisible && present {
46
 						client.server.stats.ChangeInvisible(1)
49
 						client.server.stats.ChangeInvisible(1)
47
-					} else if change.Mode == modes.Operator {
50
+					} else if change.Mode == modes.Operator && present {
48
 						client.server.stats.ChangeOperators(1)
51
 						client.server.stats.ChangeOperators(1)
49
 					}
52
 					}
50
 					applied = append(applied, change)
53
 					applied = append(applied, change)
53
 			case modes.Remove:
56
 			case modes.Remove:
54
 				var removedSnomasks string
57
 				var removedSnomasks string
55
 				if client.SetMode(change.Mode, false) {
58
 				if client.SetMode(change.Mode, false) {
56
-					if change.Mode == modes.Invisible {
59
+					if change.Mode == modes.Invisible && present {
57
 						client.server.stats.ChangeInvisible(-1)
60
 						client.server.stats.ChangeInvisible(-1)
58
 					} else if change.Mode == modes.Operator {
61
 					} else if change.Mode == modes.Operator {
59
 						removedSnomasks = client.server.snomasks.String(client)
62
 						removedSnomasks = client.server.snomasks.String(client)
60
-						client.server.stats.ChangeOperators(-1)
63
+						if present {
64
+							client.server.stats.ChangeOperators(-1)
65
+						}
61
 						applyOper(client, nil, nil)
66
 						applyOper(client, nil, nil)
62
 						if removedSnomasks != "" {
67
 						if removedSnomasks != "" {
63
 							client.server.snomasks.RemoveClient(client)
68
 							client.server.snomasks.RemoveClient(client)
86
 			if len(addMasks) != 0 {
91
 			if len(addMasks) != 0 {
87
 				oper := client.Oper()
92
 				oper := client.Oper()
88
 				// #1176: require special operator privileges to subscribe to snomasks
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
 					success = true
95
 					success = true
91
 					client.server.snomasks.AddMasks(client, addMasks...)
96
 					client.server.snomasks.AddMasks(client, addMasks...)
92
 				}
97
 				}

+ 1
- 1
irctest

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

+ 2
- 0
traditional.yaml Dosyayı Görüntüle

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

Loading…
İptal
Kaydet