From ef2d145d1fc079c891eec3df4c4722e6366a1b57 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 18 Feb 2020 20:40:32 +0100 Subject: [PATCH] Fix PING handlers, again --- downstream.go | 21 +-------------------- upstream.go | 18 +----------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/downstream.go b/downstream.go index 4dd221d..e505f0d 100644 --- a/downstream.go +++ b/downstream.go @@ -195,29 +195,10 @@ func (dc *downstreamConn) handleMessage(msg *irc.Message) error { case "QUIT": return dc.Close() case "PING": - var from, to string - if len(msg.Params) >= 1 { - from = msg.Params[0] - } - if len(msg.Params) >= 2 { - to = msg.Params[1] - } - - if to != "" && to != dc.srv.Hostname { - return ircError{&irc.Message{ - Command: irc.ERR_NOSUCHSERVER, - Params: []string{to, "No such server"}, - }} - } - - params := []string{dc.srv.Hostname} - if from != "" { - params = append(params, from) - } dc.SendMessage(&irc.Message{ Prefix: dc.srv.prefix(), Command: "PONG", - Params: params, + Params: msg.Params, }) return nil default: diff --git a/upstream.go b/upstream.go index a21f6c8..236da88 100644 --- a/upstream.go +++ b/upstream.go @@ -111,25 +111,9 @@ func (uc *upstreamConn) getChannel(name string) (*upstreamChannel, error) { func (uc *upstreamConn) handleMessage(msg *irc.Message) error { switch msg.Command { case "PING": - var from, to string - if len(msg.Params) >= 1 { - from = msg.Params[0] - } - if len(msg.Params) >= 2 { - to = msg.Params[1] - } - - if to != "" && to != uc.srv.Hostname { - return fmt.Errorf("invalid PING destination %q", to) - } - - params := []string{uc.srv.Hostname} - if from != "" { - params = append(params, from) - } uc.SendMessage(&irc.Message{ Command: "PONG", - Params: params, + Params: msg.Params, }) return nil case "MODE":