3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00
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.
This commit is contained in:
Shivaram Lingamneni 2021-05-27 11:43:21 -04:00
parent 91cdb96bcb
commit ec48966b68

View File

@ -2658,13 +2658,19 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
return false return false
} }
details := client.Details()
// #1647: we need to publish a full NUH. send ~u (or the configured alternative) // #1647: we need to publish a full NUH. send ~u (or the configured alternative)
// as the user/ident, and send the relayer's hostname as the hostname: // as the user/ident, and send the relayer's hostname as the hostname:
ident := config.Server.CoerceIdent ident := config.Server.CoerceIdent
if ident == "" { if ident == "" {
ident = "~u" ident = "~u"
} }
hostname := client.Hostname() // #1661: if the bot has its own account, use the account cloak,
// otherwise fall back to the hostname (which may be IP-derived)
hostname := details.hostname
if details.accountName != "" {
hostname = config.Server.Cloaks.ComputeAccountCloak(details.accountName)
}
nuh := fmt.Sprintf("%s!%s@%s", nick, ident, hostname) nuh := fmt.Sprintf("%s!%s@%s", nick, ident, hostname)
channel.AddHistoryItem(history.Item{ channel.AddHistoryItem(history.Item{
@ -2675,9 +2681,8 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
// 3 possibilities for tags: // 3 possibilities for tags:
// no tags, the relaymsg tag only, or the relaymsg tag together with all client-only tags // no tags, the relaymsg tag only, or the relaymsg tag together with all client-only tags
cnick := client.Nick()
relayTag := map[string]string{ relayTag := map[string]string{
caps.RelaymsgTagName: cnick, caps.RelaymsgTagName: details.nick,
} }
clientOnlyTags := msg.ClientOnlyTags() clientOnlyTags := msg.ClientOnlyTags()
var fullTags map[string]string var fullTags map[string]string
@ -2685,7 +2690,7 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
fullTags = relayTag fullTags = relayTag
} else { } else {
fullTags = make(map[string]string, 1+len(clientOnlyTags)) fullTags = make(map[string]string, 1+len(clientOnlyTags))
fullTags[caps.RelaymsgTagName] = cnick fullTags[caps.RelaymsgTagName] = details.nick
for t, v := range clientOnlyTags { for t, v := range clientOnlyTags {
fullTags[t] = v fullTags[t] = v
} }