3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00

client: Send quit messages more correctly

This commit is contained in:
Daniel Oaks 2016-11-29 21:06:01 +10:00
parent 2e2e91689a
commit dc605ebb01
2 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -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) {
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.