From 43aa3e55295a67c83eddacc7417cefe93d59b1be Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 26 Aug 2020 15:18:57 +0200 Subject: [PATCH] Fix downstream PING argument handling The PONG message should have these arguments: - Our server name - The PING message's source name Closes: https://todo.sr.ht/~emersion/soju/92 --- downstream.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index d27528e..2c447f8 100644 --- a/downstream.go +++ b/downstream.go @@ -960,10 +960,23 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { return err } case "PING": + var source, destination string + if err := parseMessageParams(msg, &source); err != nil { + return err + } + if len(msg.Params) > 1 { + destination = msg.Params[1] + } + if destination != "" && destination != dc.srv.Hostname { + return ircError{&irc.Message{ + Command: irc.ERR_NOSUCHSERVER, + Params: []string{dc.nick, destination, "No such server"}, + }} + } dc.SendMessage(&irc.Message{ Prefix: dc.srv.prefix(), Command: "PONG", - Params: msg.Params, + Params: []string{dc.srv.Hostname, source}, }) return nil case "USER":