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

Show real IP in WHOWAS to opers with ban capability.

This commit is contained in:
Alex Jaspersen 2021-06-20 10:26:30 -07:00
parent 6786b87fbd
commit e5c2588eab
4 changed files with 11 additions and 4 deletions

View File

@ -269,6 +269,7 @@ type WhoWas struct {
username string username string
hostname string hostname string
realname string realname string
realIP net.IP
// technically not required for WHOWAS: // technically not required for WHOWAS:
account string account string
accountName string accountName string
@ -598,6 +599,10 @@ func (client *Client) IP() net.IP {
client.stateMutex.RLock() client.stateMutex.RLock()
defer client.stateMutex.RUnlock() defer client.stateMutex.RUnlock()
return client.getIPNoMutex()
}
func (client *Client) getIPNoMutex() net.IP {
if client.proxiedIP != nil { if client.proxiedIP != nil {
return client.proxiedIP return client.proxiedIP
} }

View File

@ -436,6 +436,7 @@ func (client *Client) detailsNoMutex() (result ClientDetails) {
result.username = client.username result.username = client.username
result.hostname = client.hostname result.hostname = client.hostname
result.realname = client.realname result.realname = client.realname
result.realIP = client.getIPNoMutex()
result.nickMask = client.nickMaskString result.nickMask = client.nickMaskString
result.nickMaskCasefolded = client.nickMaskCasefolded result.nickMaskCasefolded = client.nickMaskCasefolded
result.account = client.account result.account = client.account

View File

@ -3416,11 +3416,8 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
count = 0 count = 0
} }
} }
//var target string
//if len(msg.Params) > 2 {
// target = msg.Params[2]
//}
cnick := client.Nick() cnick := client.Nick()
canSeeIP := client.Oper().HasRoleCapab("ban")
for _, nickname := range nicknames { for _, nickname := range nicknames {
if len(nickname) == 0 { if len(nickname) == 0 {
continue continue
@ -3431,6 +3428,9 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
} else { } else {
for _, whoWas := range results { for _, whoWas := range results {
rb.Add(nil, server.name, RPL_WHOWASUSER, cnick, whoWas.nick, whoWas.username, whoWas.hostname, "*", whoWas.realname) 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.realIP.String())))
}
} }
} }
rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, utils.SafeErrorParam(nickname), client.t("End of WHOWAS")) rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, utils.SafeErrorParam(nickname), client.t("End of WHOWAS"))

View File

@ -168,6 +168,7 @@ const (
ERR_USERSDONTMATCH = "502" ERR_USERSDONTMATCH = "502"
ERR_HELPNOTFOUND = "524" ERR_HELPNOTFOUND = "524"
ERR_CANNOTSENDRP = "573" ERR_CANNOTSENDRP = "573"
RPL_WHOWASIP = "652"
RPL_WHOISSECURE = "671" RPL_WHOISSECURE = "671"
RPL_YOURLANGUAGESARE = "687" RPL_YOURLANGUAGESARE = "687"
ERR_INVALIDMODEPARAM = "696" ERR_INVALIDMODEPARAM = "696"