Skip to content

Commit

Permalink
Merge pull request #1480 from slingamn/issue1479_tor_cloak
Browse files Browse the repository at this point in the history
fix #1479
  • Loading branch information
slingamn committed Jan 15, 2021
2 parents 2fd537f + d1f8317 commit 3e230e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions irc/getters.go
Expand Up @@ -307,6 +307,13 @@ func (client *Client) setAccountName(name string) {
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) {
client.stateMutex.Lock()
if client.account != "" {
Expand Down
14 changes: 14 additions & 0 deletions irc/handlers.go
Expand Up @@ -116,6 +116,20 @@ func sendSuccessfulAccountAuth(service *ircService, client *Client, rb *Response
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)
}

Expand Down

0 comments on commit 3e230e2

Please sign in to comment.