瀏覽代碼

review fixes

tags/v1.2.0-rc1
Shivaram Lingamneni 4 年之前
父節點
當前提交
3cb9234bb5
共有 5 個檔案被更改,包括 14 行新增13 行删除
  1. 1
    1
      docs/MANUAL.md
  2. 3
    3
      irc/caps/set.go
  3. 3
    3
      irc/caps/set_test.go
  4. 2
    2
      irc/handlers.go
  5. 5
    4
      irc/server.go

+ 1
- 1
docs/MANUAL.md 查看文件

@@ -348,7 +348,7 @@ Otherwise, in the Oragono config file, you'll want to enable raw line logging by
348 348
 
349 349
 # IRC over TLS
350 350
 
351
-Traditionally, IRC used a plaintext protocol, typically on port 6667. Over time, a convention emerged to use this protocol inside SSL/TLS instead, typically on port 6697. As of now, we recommend that you make your server available *exclusively* via TLS, since allowing plaintext access can result in the disclosure of user data or passwords. While the default config file still exposes a public plaintext port for the benefit of legacy clients, it also contains instructions on how to disable it --- if at all possible, you should follow them!
351
+IRC has traditionally been available over both plaintext (on port 6667) and SSL/TLS (on port 6697). We recommend that you make your server available exclusively via TLS, since exposing plaintext access allows for unauthorized interception or modification of user data or passwords. While the default config file exposes a plaintext public port, it also contains instructions on how to disable it or replace it with a 'dummy' plaintext listener that simply directs users to reconnect using TLS.
352 352
 
353 353
 
354 354
 ## How do I use Let's Encrypt certificates?

+ 3
- 3
irc/caps/set.go 查看文件

@@ -93,8 +93,8 @@ func (s *Set) Empty() bool {
93 93
 
94 94
 const maxPayloadLength = 440
95 95
 
96
-// String returns all of our enabled capabilities as a string.
97
-func (s *Set) String(version Version, values Values) (result []string) {
96
+// Strings returns all of our enabled capabilities as a slice of strings.
97
+func (s *Set) Strings(version Version, values Values) (result []string) {
98 98
 	var strs sort.StringSlice
99 99
 
100 100
 	var capab Capability
@@ -105,7 +105,7 @@ func (s *Set) String(version Version, values Values) (result []string) {
105 105
 			continue
106 106
 		}
107 107
 		capString := capab.Name()
108
-		if version == Cap302 {
108
+		if version >= Cap302 {
109 109
 			val, exists := values[capab]
110 110
 			if exists {
111 111
 				capString += "=" + val

+ 3
- 3
irc/caps/set_test.go 查看文件

@@ -43,17 +43,17 @@ func TestSets(t *testing.T) {
43 43
 		t.Error("Add/Remove don't work")
44 44
 	}
45 45
 
46
-	// test String()
46
+	// test Strings()
47 47
 	values := make(Values)
48 48
 	values[InviteNotify] = "invitemepls"
49 49
 
50
-	actualCap301ValuesString := s1.String(Cap301, values)
50
+	actualCap301ValuesString := s1.Strings(Cap301, values)
51 51
 	expectedCap301ValuesString := []string{"invite-notify userhost-in-names"}
52 52
 	if !reflect.DeepEqual(actualCap301ValuesString, expectedCap301ValuesString) {
53 53
 		t.Errorf("Generated Cap301 values string [%v] did not match expected values string [%v]", actualCap301ValuesString, expectedCap301ValuesString)
54 54
 	}
55 55
 
56
-	actualCap302ValuesString := s1.String(Cap302, values)
56
+	actualCap302ValuesString := s1.Strings(Cap302, values)
57 57
 	expectedCap302ValuesString := []string{"invite-notify=invitemepls userhost-in-names"}
58 58
 	if !reflect.DeepEqual(actualCap302ValuesString, expectedCap302ValuesString) {
59 59
 		t.Errorf("Generated Cap302 values string [%s] did not match expected values string [%s]", actualCap302ValuesString, expectedCap302ValuesString)

+ 2
- 2
irc/handlers.go 查看文件

@@ -569,11 +569,11 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
569 569
 
570 570
 	sendCapLines := func(cset *caps.Set, values caps.Values) {
571 571
 		version := rb.session.capVersion
572
-		capLines := cset.String(version, values)
572
+		capLines := cset.Strings(version, values)
573 573
 		// weechat 1.4 has a bug here where it won't accept the CAP reply unless it contains
574 574
 		// the server.name source:
575 575
 		for i, capStr := range capLines {
576
-			if version == caps.Cap302 && i < len(capLines)-1 {
576
+			if version >= caps.Cap302 && i < len(capLines)-1 {
577 577
 				rb.Add(nil, server.name, "CAP", details.nick, subCommand, "*", capStr)
578 578
 			} else {
579 579
 				rb.Add(nil, server.name, "CAP", details.nick, subCommand, capStr)

+ 5
- 4
irc/server.go 查看文件

@@ -673,6 +673,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
673 673
 	server.logger.Debug("server", "STS Vals", stsCurrentCapValue, stsValue, fmt.Sprintf("server[%v] config[%v]", stsPreviouslyEnabled, config.Server.STS.Enabled))
674 674
 	if (config.Server.STS.Enabled != stsPreviouslyEnabled) || (stsValue != stsCurrentCapValue) {
675 675
 		// XXX: STS is always removed by CAP NEW sts=duration=0, not CAP DEL
676
+		// so the appropriate notify is always a CAP NEW; put it in addedCaps for any change
676 677
 		addedCaps.Add(caps.STS)
677 678
 	}
678 679
 
@@ -704,17 +705,17 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
704 705
 
705 706
 	// updated caps get DEL'd and then NEW'd
706 707
 	// so, we can just add updated ones to both removed and added lists here and they'll be correctly handled
707
-	server.logger.Debug("server", "Updated Caps", strings.Join(updatedCaps.String(caps.Cap301, config.Server.capValues), " "))
708
+	server.logger.Debug("server", "Updated Caps", strings.Join(updatedCaps.Strings(caps.Cap301, config.Server.capValues), " "))
708 709
 	addedCaps.Union(updatedCaps)
709 710
 	removedCaps.Union(updatedCaps)
710 711
 
711 712
 	if !addedCaps.Empty() || !removedCaps.Empty() {
712 713
 		capBurstSessions = server.clients.AllWithCapsNotify()
713 714
 
714
-		added[caps.Cap301] = addedCaps.String(caps.Cap301, config.Server.capValues)
715
-		added[caps.Cap302] = addedCaps.String(caps.Cap302, config.Server.capValues)
715
+		added[caps.Cap301] = addedCaps.Strings(caps.Cap301, config.Server.capValues)
716
+		added[caps.Cap302] = addedCaps.Strings(caps.Cap302, config.Server.capValues)
716 717
 		// removed never has values, so we leave it as Cap301
717
-		removed = removedCaps.String(caps.Cap301, config.Server.capValues)
718
+		removed = removedCaps.Strings(caps.Cap301, config.Server.capValues)
718 719
 	}
719 720
 
720 721
 	for _, sSession := range capBurstSessions {

Loading…
取消
儲存