From dc605ebb0134c96c6a17415d58b45e0702d38c5c Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Tue, 29 Nov 2016 21:06:01 +1000 Subject: [PATCH] client: Send quit messages more correctly --- CHANGELOG.md | 6 ++++-- irc/client.go | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e529f64f..76bfc461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,10 +19,12 @@ New release of Oragono! ### Removed ### Fixed -* Prevented a DoS related to lots of clients connecting at once. -* Removed races around setting and changing `NICK`s, to be more safe. * Fixed crash when using STATUSMSG-like messaging. * Fixed crash with gIRC-Go ircmsg library we depend on. +* Fixed not sending `MODE` changes to all clients in a channel. +* Fixed timeout issue with go-ident library we depend on (which caused hangs on connection). +* Prevented a DoS related to lots of clients connecting at once. +* Removed races around setting and changing `NICK`s, to be more safe. ## [0.4.0] - 2016-11-03 diff --git a/irc/client.go b/irc/client.go index e73293f2..53dc23a5 100644 --- a/irc/client.go +++ b/irc/client.go @@ -58,6 +58,7 @@ type Client struct { nickMaskCasefolded string operName string quitTimer *time.Timer + quitMessageSent bool realname string registered bool saslInProgress bool @@ -378,8 +379,11 @@ func (client *Client) ChangeNickname(nickname string) error { } func (client *Client) Quit(message string) { - client.Send(nil, client.nickMaskString, "QUIT", message) - client.Send(nil, client.nickMaskString, "ERROR", message) + if !client.quitMessageSent { + client.Send(nil, client.nickMaskString, "QUIT", message) + client.Send(nil, client.nickMaskString, "ERROR", message) + client.quitMessageSent = true + } } // destroy gets rid of a client, removes them from server lists etc. @@ -388,6 +392,9 @@ func (client *Client) destroy() { return } + // send quit/error message to client if they haven't been sent already + client.Quit("Connection closed") + client.isDestroyed = true client.server.whoWas.Append(client) friends := client.Friends() @@ -416,12 +423,6 @@ func (client *Client) destroy() { // remove my monitors client.clearMonitorList() - // send quit messages to friends - for friend := range client.Friends() { - //TODO(dan): store quit message in user, if exists use that instead here - friend.Send(nil, client.nickMaskString, "QUIT", "Exited") - } - // clean up channels for channel := range client.channels { channel.Quit(client) @@ -439,6 +440,12 @@ func (client *Client) destroy() { } client.socket.Close() + + // send quit messages to friends + for friend := range friends { + //TODO(dan): store quit message in user, if exists use that instead here + friend.Send(nil, client.nickMaskString, "QUIT", "Exited") + } } // SendFromClient sends an IRC line coming from a specific client.