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

Merge pull request #1480 from slingamn/issue1479_tor_cloak

fix #1479
This commit is contained in:
Shivaram Lingamneni 2021-01-15 06:18:35 -05:00 committed by GitHub
commit 3e230e2a17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -307,6 +307,13 @@ func (client *Client) setAccountName(name string) {
client.accountName = name client.accountName = name
} }
func (client *Client) setCloakedHostname(cloak string) {
client.stateMutex.Lock()
defer client.stateMutex.Unlock()
client.cloakedHostname = cloak
client.updateNickMaskNoMutex()
}
func (client *Client) historyCutoff() (cutoff time.Time) { func (client *Client) historyCutoff() (cutoff time.Time) {
client.stateMutex.Lock() client.stateMutex.Lock()
if client.account != "" { if client.account != "" {

View File

@ -116,6 +116,20 @@ func sendSuccessfulAccountAuth(service *ircService, client *Client, rb *Response
client.server.sendLoginSnomask(details.nickMask, details.accountName) client.server.sendLoginSnomask(details.nickMask, details.accountName)
} }
// #1479: for Tor clients, replace the hostname with the always-on cloak here
// (for normal clients, this would discard the IP-based cloak, but with Tor
// there's no such concern)
if rb.session.isTor {
config := client.server.Config()
if config.Server.Cloaks.EnabledForAlwaysOn {
cloakedHostname := config.Server.Cloaks.ComputeAccountCloak(details.accountName)
client.setCloakedHostname(cloakedHostname)
if client.registered {
client.sendChghost(details.nickMask, client.Hostname())
}
}
}
client.server.logger.Info("accounts", "client", details.nick, "logged into account", details.accountName) client.server.logger.Info("accounts", "client", details.nick, "logged into account", details.accountName)
} }