From a154bd6120c2d455ae553e92d0e0df89dea7b797 Mon Sep 17 00:00:00 2001 From: Thomas Habets Date: Mon, 9 Jun 2014 16:03:11 +0200 Subject: [PATCH] Remove port from /whois output. --- daemon.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon.go b/daemon.go index 1f979ce..d8cc3b8 100644 --- a/daemon.go +++ b/daemon.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "log" + "net" "regexp" "sort" "strings" @@ -98,7 +99,13 @@ func (daemon *Daemon) SendWhois(client *Client, nicknames []string) { continue } found = true - client.ReplyNicknamed("311", c.nickname, c.username, c.conn.RemoteAddr().String(), "*", c.realname) + h := c.conn.RemoteAddr().String() + h, _, err := net.SplitHostPort(h) + if err != nil { + log.Printf("Can't parse RemoteAddr %q: %v", h, err) + h = "Unknown" + } + client.ReplyNicknamed("311", c.nickname, c.username, h, "*", c.realname) client.ReplyNicknamed("312", c.nickname, daemon.hostname, daemon.hostname) subscriptions := []string{} for _, room := range daemon.rooms {