Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show real IP in WHOWAS to opers with ban capability. #1702

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions irc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ type WhoWas struct {
username string
hostname string
realname string
ip net.IP
// technically not required for WHOWAS:
account string
accountName string
Expand Down Expand Up @@ -598,6 +599,10 @@ func (client *Client) IP() net.IP {
client.stateMutex.RLock()
defer client.stateMutex.RUnlock()

return client.getIPNoMutex()
}

func (client *Client) getIPNoMutex() net.IP {
if client.proxiedIP != nil {
return client.proxiedIP
}
Expand Down
1 change: 1 addition & 0 deletions irc/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ func (client *Client) detailsNoMutex() (result ClientDetails) {
result.username = client.username
result.hostname = client.hostname
result.realname = client.realname
result.ip = client.getIPNoMutex()
result.nickMask = client.nickMaskString
result.nickMaskCasefolded = client.nickMaskCasefolded
result.account = client.account
Expand Down
8 changes: 4 additions & 4 deletions irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3416,11 +3416,8 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
count = 0
}
}
//var target string
//if len(msg.Params) > 2 {
// target = msg.Params[2]
//}
cnick := client.Nick()
canSeeIP := client.Oper().HasRoleCapab("ban")
for _, nickname := range nicknames {
if len(nickname) == 0 {
continue
Expand All @@ -3431,6 +3428,9 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
} else {
for _, whoWas := range results {
rb.Add(nil, server.name, RPL_WHOWASUSER, cnick, whoWas.nick, whoWas.username, whoWas.hostname, "*", whoWas.realname)
if canSeeIP {
rb.Add(nil, server.name, RPL_WHOWASIP, cnick, whoWas.nick, fmt.Sprintf(client.t("was connecting from %s"), utils.IPStringToHostname(whoWas.ip.String())))
}
}
}
rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, utils.SafeErrorParam(nickname), client.t("End of WHOWAS"))
Expand Down
1 change: 1 addition & 0 deletions irc/numerics.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const (
ERR_USERSDONTMATCH = "502"
ERR_HELPNOTFOUND = "524"
ERR_CANNOTSENDRP = "573"
RPL_WHOWASIP = "652"
RPL_WHOISSECURE = "671"
RPL_YOURLANGUAGESARE = "687"
ERR_INVALIDMODEPARAM = "696"
Expand Down