Browse Source

fix #1661

If the relay bot and the owner share an IP, legacy bots that identify users
by user@host could misinterpret relayed lines as coming from the bot owner.
Try to avoid this by using the bot's account cloak where applicable.
tags/v2.7.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
ec48966b68
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      irc/handlers.go

+ 9
- 4
irc/handlers.go View File

2658
 		return false
2658
 		return false
2659
 	}
2659
 	}
2660
 
2660
 
2661
+	details := client.Details()
2661
 	// #1647: we need to publish a full NUH. send ~u (or the configured alternative)
2662
 	// #1647: we need to publish a full NUH. send ~u (or the configured alternative)
2662
 	// as the user/ident, and send the relayer's hostname as the hostname:
2663
 	// as the user/ident, and send the relayer's hostname as the hostname:
2663
 	ident := config.Server.CoerceIdent
2664
 	ident := config.Server.CoerceIdent
2664
 	if ident == "" {
2665
 	if ident == "" {
2665
 		ident = "~u"
2666
 		ident = "~u"
2666
 	}
2667
 	}
2667
-	hostname := client.Hostname()
2668
+	// #1661: if the bot has its own account, use the account cloak,
2669
+	// otherwise fall back to the hostname (which may be IP-derived)
2670
+	hostname := details.hostname
2671
+	if details.accountName != "" {
2672
+		hostname = config.Server.Cloaks.ComputeAccountCloak(details.accountName)
2673
+	}
2668
 	nuh := fmt.Sprintf("%s!%s@%s", nick, ident, hostname)
2674
 	nuh := fmt.Sprintf("%s!%s@%s", nick, ident, hostname)
2669
 
2675
 
2670
 	channel.AddHistoryItem(history.Item{
2676
 	channel.AddHistoryItem(history.Item{
2675
 
2681
 
2676
 	// 3 possibilities for tags:
2682
 	// 3 possibilities for tags:
2677
 	// no tags, the relaymsg tag only, or the relaymsg tag together with all client-only tags
2683
 	// no tags, the relaymsg tag only, or the relaymsg tag together with all client-only tags
2678
-	cnick := client.Nick()
2679
 	relayTag := map[string]string{
2684
 	relayTag := map[string]string{
2680
-		caps.RelaymsgTagName: cnick,
2685
+		caps.RelaymsgTagName: details.nick,
2681
 	}
2686
 	}
2682
 	clientOnlyTags := msg.ClientOnlyTags()
2687
 	clientOnlyTags := msg.ClientOnlyTags()
2683
 	var fullTags map[string]string
2688
 	var fullTags map[string]string
2685
 		fullTags = relayTag
2690
 		fullTags = relayTag
2686
 	} else {
2691
 	} else {
2687
 		fullTags = make(map[string]string, 1+len(clientOnlyTags))
2692
 		fullTags = make(map[string]string, 1+len(clientOnlyTags))
2688
-		fullTags[caps.RelaymsgTagName] = cnick
2693
+		fullTags[caps.RelaymsgTagName] = details.nick
2689
 		for t, v := range clientOnlyTags {
2694
 		for t, v := range clientOnlyTags {
2690
 			fullTags[t] = v
2695
 			fullTags[t] = v
2691
 		}
2696
 		}

Loading…
Cancel
Save