From 51a12983d8aa4c850edf77def0a5762c739a1e14 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 30 Apr 2024 14:23:49 +0200 Subject: [PATCH] downstream: ensure numerics always carry a source prefix From [1]: > Distinct from a normal message, a numeric reply MUST contain a > and use a three-digit numeric as the command. [1]: https://modern.ircdocs.horse/#numeric-replies --- downstream.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/downstream.go b/downstream.go index 35bdfdd..b0c296b 100644 --- a/downstream.go +++ b/downstream.go @@ -530,6 +530,12 @@ func (dc *downstreamConn) SendMessage(ctx context.Context, msg *irc.Message) { msg = &msgCopy msg.Prefix = nil } + if msg.Prefix == nil && isNumeric(msg.Command) { + // Numerics must always carry a source + msgCopy := *msg + msg = &msgCopy + msg.Prefix = dc.srv.prefix() + } dc.srv.metrics.downstreamOutMessagesTotal.Inc() dc.conn.SendMessage(ctx, msg)