De-duplicate downstream QUIT handling

This commit is contained in:
Simon Ser 2020-02-06 22:22:14 +01:00
parent cd7556264e
commit 89f1944d30
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -128,6 +128,8 @@ func (c *downstreamConn) WriteMessage(msg *irc.Message) {
func (c *downstreamConn) handleMessage(msg *irc.Message) error {
switch msg.Command {
case "QUIT":
return c.Close()
case "PING":
// TODO: handle params
c.WriteMessage(&irc.Message{
@ -157,8 +159,6 @@ func (c *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
}
c.username = "~" + msg.Params[0]
c.realname = msg.Params[3]
case "QUIT":
return c.Close()
default:
c.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command)
@ -189,7 +189,7 @@ func (c *downstreamConn) register() error {
c.WriteMessage(&irc.Message{
Command: irc.RPL_MYINFO,
Params: []string{c.nick, c.srv.Hostname, "unknown", "aiwroO", "OovaimnqpsrtklbeI"},
Params: []string{c.nick, c.srv.Hostname, "jounce", "aiwroO", "OovaimnqpsrtklbeI"},
})
c.WriteMessage(&irc.Message{
@ -210,8 +210,6 @@ func (c *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
"You may not reregister",
},
}}
case "QUIT":
return c.Close()
default:
c.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command)