1
0
Fork 0
forked from External/ergo

Revert "remove draft/resume-0.5"

This reverts commit ba21987d03.
This commit is contained in:
Shivaram Lingamneni 2021-06-01 21:43:42 -04:00
parent b81757d273
commit 6067ce4200
14 changed files with 683 additions and 4 deletions

View file

@ -81,6 +81,26 @@ func (clients *ClientManager) Remove(client *Client) error {
return clients.removeInternal(client, oldcfnick, oldskeleton)
}
// Handles a RESUME by attaching a session to a designated client. It is the
// caller's responsibility to verify that the resume is allowed (checking tokens,
// TLS status, etc.) before calling this.
func (clients *ClientManager) Resume(oldClient *Client, session *Session) (err error) {
clients.Lock()
defer clients.Unlock()
cfnick := oldClient.NickCasefolded()
if _, ok := clients.byNick[cfnick]; !ok {
return errNickMissing
}
success, _, _, _ := oldClient.AddSession(session)
if !success {
return errNickMissing
}
return nil
}
// SetNick sets a client's nickname, validating it against nicknames in use
// XXX: dryRun validates a client's ability to claim a nick, without
// actually claiming it