From 29ad541ac7c24388103ee03f6c20c71bbfd20c5a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 9 Mar 2021 18:56:28 +0100 Subject: [PATCH] Send network settings in LISTNETWORKS --- downstream.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/downstream.go b/downstream.go index fcb4b47..1a4dc79 100644 --- a/downstream.go +++ b/downstream.go @@ -1993,8 +1993,34 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { } attrs := irc.Tags{ - "name": irc.TagValue(network.GetName()), - "state": irc.TagValue(state), + "name": irc.TagValue(network.GetName()), + "state": irc.TagValue(state), + "nickname": irc.TagValue(network.Nick), + } + + if network.Username != "" { + attrs["username"] = irc.TagValue(network.Username) + } + if network.Realname != "" { + attrs["realname"] = irc.TagValue(network.Realname) + } + + if u, err := network.URL(); err == nil { + hasHostPort := true + switch u.Scheme { + case "ircs": + attrs["tls"] = irc.TagValue("1") + case "irc+insecure": + attrs["tls"] = irc.TagValue("0") + default: + hasHostPort = false + } + if host, port, err := net.SplitHostPort(u.Host); err == nil && hasHostPort { + attrs["host"] = irc.TagValue(host) + attrs["port"] = irc.TagValue(port) + } else if hasHostPort { + attrs["host"] = irc.TagValue(u.Host) + } } dc.SendMessage(&irc.Message{