mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-15 00:19:29 +01:00
Merge pull request #1702 from ajaspers/whowas
Show real IP in WHOWAS to opers with ban capability.
This commit is contained in:
commit
f07524111c
@ -269,6 +269,7 @@ type WhoWas struct {
|
|||||||
username string
|
username string
|
||||||
hostname string
|
hostname string
|
||||||
realname string
|
realname string
|
||||||
|
ip 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
|
||||||
}
|
}
|
||||||
|
@ -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.ip = 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
|
||||||
|
@ -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 {
|
||||||
results := server.whoWas.Find(nickname, count)
|
results := server.whoWas.Find(nickname, count)
|
||||||
if len(results) == 0 {
|
if len(results) == 0 {
|
||||||
@ -3428,6 +3425,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.ip.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"))
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user