From 23a26f83fee447900aff232f6a7ceb115584d5ce Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Fri, 23 Jun 2017 05:15:10 +1000 Subject: [PATCH] client: Show real IP and whether the target's using TLS in WHOIS --- irc/client.go | 9 +++++++++ irc/numerics.go | 2 ++ irc/server.go | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/irc/client.go b/irc/client.go index 3ceb228a..15a3a383 100644 --- a/irc/client.go +++ b/irc/client.go @@ -150,6 +150,15 @@ func (client *Client) IP() net.IP { return net.ParseIP(IPString(client.socket.conn.RemoteAddr())) } +// IPString returns the IP address of this client as a string. +func (client *Client) IPString() string { + ip := client.IP().String() + if 0 < len(ip) && ip[0] == ':' { + ip = "0" + ip + } + return ip +} + // // command goroutine // diff --git a/irc/numerics.go b/irc/numerics.go index 5f90914d..f7799d09 100644 --- a/irc/numerics.go +++ b/irc/numerics.go @@ -72,6 +72,7 @@ const ( RPL_NOTOPIC = "331" RPL_TOPIC = "332" RPL_TOPICTIME = "333" + RPL_WHOISACTUALLY = "338" RPL_INVITING = "341" RPL_SUMMONING = "342" RPL_INVITELIST = "346" @@ -158,6 +159,7 @@ const ( ERR_USERSDONTMATCH = "502" ERR_HELPNOTFOUND = "524" ERR_CANNOTSENDRP = "573" + RPL_WHOISSECURE = "671" RPL_HELPSTART = "704" RPL_HELPTXT = "705" RPL_ENDOFHELP = "706" diff --git a/irc/server.go b/irc/server.go index 85186d05..8b56d4a2 100644 --- a/irc/server.go +++ b/irc/server.go @@ -1273,6 +1273,12 @@ func (client *Client) getWhoisOf(target *Client) { if target.class != nil { client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine) } + if client.flags[Operator] || client == target { + client.Send(nil, client.server.name, RPL_WHOISACTUALLY, client.nick, target.nick, fmt.Sprintf("%s@%s", target.username, LookupHostname(target.IPString())), target.IPString(), "Actual user@host, Actual IP") + } + if target.flags[TLS] { + client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, "is using a secure connection") + } if target.certfp != "" && (client.flags[Operator] || client == target) { client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf("has client certificate fingerprint %s", target.certfp)) }