mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
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.
This commit is contained in:
parent
91cdb96bcb
commit
ec48966b68
@ -2658,13 +2658,19 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
||||
return false
|
||||
}
|
||||
|
||||
details := client.Details()
|
||||
// #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:
|
||||
ident := config.Server.CoerceIdent
|
||||
if ident == "" {
|
||||
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)
|
||||
|
||||
channel.AddHistoryItem(history.Item{
|
||||
@ -2675,9 +2681,8 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
||||
|
||||
// 3 possibilities for tags:
|
||||
// no tags, the relaymsg tag only, or the relaymsg tag together with all client-only tags
|
||||
cnick := client.Nick()
|
||||
relayTag := map[string]string{
|
||||
caps.RelaymsgTagName: cnick,
|
||||
caps.RelaymsgTagName: details.nick,
|
||||
}
|
||||
clientOnlyTags := msg.ClientOnlyTags()
|
||||
var fullTags map[string]string
|
||||
@ -2685,7 +2690,7 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
||||
fullTags = relayTag
|
||||
} else {
|
||||
fullTags = make(map[string]string, 1+len(clientOnlyTags))
|
||||
fullTags[caps.RelaymsgTagName] = cnick
|
||||
fullTags[caps.RelaymsgTagName] = details.nick
|
||||
for t, v := range clientOnlyTags {
|
||||
fullTags[t] = v
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user