upstream: compare service nick with case-mapping

This commit is contained in:
Simon Ser 2022-07-08 14:47:43 +02:00
parent dc356200c2
commit 7db1be44fa
2 changed files with 7 additions and 3 deletions

View File

@ -494,16 +494,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
}
}
if msg.Prefix.Name == serviceNick {
if uc.network.equalCasemap(msg.Prefix.Name, serviceNick) {
uc.logger.Printf("skipping %v from soju's service: %v", msg.Command, msg)
break
}
if target == serviceNick {
if uc.network.equalCasemap(target, serviceNick) {
uc.logger.Printf("skipping %v to soju's service: %v", msg.Command, msg)
break
}
if msg.Prefix.Name == uc.serverPrefix.Name || target == "*" || strings.HasPrefix(target, "$") {
if uc.network.equalCasemap(msg.Prefix.Name, uc.serverPrefix.Name) || target == "*" || strings.HasPrefix(target, "$") {
// This is a server message
uc.produce("", msg, 0)
break

View File

@ -179,6 +179,10 @@ func (net *network) isStopped() bool {
}
}
func (net *network) equalCasemap(a, b string) bool {
return net.casemap(a) == net.casemap(b)
}
func userIdent(u *database.User) string {
// The ident is a string we will send to upstream servers in clear-text.
// For privacy reasons, make sure it doesn't expose any meaningful user