From 68c83a95d4b7f89c0b218a74cd7ee3e49ed91e97 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 5 Sep 2016 14:23:57 +1000 Subject: [PATCH] WHOIS: Fixes, add certfp --- irc/numerics.go | 1 + irc/server.go | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/irc/numerics.go b/irc/numerics.go index a933a47a..6430a6b3 100644 --- a/irc/numerics.go +++ b/irc/numerics.go @@ -43,6 +43,7 @@ const ( RPL_TRACELOG = "261" RPL_TRACEEND = "262" RPL_TRYAGAIN = "263" + RPL_WHOISCERTFP = "276" RPL_AWAY = "301" RPL_USERHOST = "302" RPL_ISON = "303" diff --git a/irc/server.go b/irc/server.go index 6331daec..5f851da1 100644 --- a/irc/server.go +++ b/irc/server.go @@ -648,7 +648,7 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { continue } for mclient := range matches { - mclient.getWhoisOf(client) + client.getWhoisOf(mclient) } } } else { @@ -668,13 +668,17 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func (client *Client) getWhoisOf(target *Client) { client.Send(nil, client.server.nameString, RPL_WHOISUSER, client.nickString, target.nickString, target.username.String(), target.hostname.String(), "*", target.realname) - if target.flags[Operator] { - client.Send(nil, client.server.nameString, RPL_WHOISOPERATOR, client.nickString, target.nickString, "is an IRC operator") - } - client.Send(nil, client.server.nameString, RPL_WHOISIDLE, client.nickString, target.nickString, string(target.IdleSeconds()), string(target.SignonTime()), "seconds idle, signon time") + //TODO(dan): ...one channel per reply? really? for _, line := range client.WhoisChannelsNames(target) { client.Send(nil, client.server.nameString, RPL_WHOISCHANNELS, client.nickString, target.nickString, line) } + if target.flags[Operator] { + client.Send(nil, client.server.nameString, RPL_WHOISOPERATOR, client.nickString, target.nickString, "is an IRC operator") + } + if target.certfp != "" && (client.flags[Operator] || client == target) { + client.Send(nil, client.server.nameString, RPL_WHOISCERTFP, client.nickString, target.nickString, fmt.Sprintf("has client certificate fingerprint %s", target.certfp)) + } + client.Send(nil, client.server.nameString, RPL_WHOISIDLE, client.nickString, target.nickString, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), "seconds idle, signon time") } // ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ]