Enable resetting a BOUNCER NETWORK port

When a client sends BOUNCER CHANGENETWORK with no value (or an empty
port value), this means it wants to reset the port value to its default
value.

Previously we considered an empty port as an actual valid, empty port
value, which would then be used to connect to the server (dial
'example.com:' (ie 'example.com:0'), which failed.
This commit is contained in:
delthas 2022-04-08 22:33:37 +02:00 committed by Simon Ser
parent 17374f2094
commit d8ca6d2222

View File

@ -148,17 +148,17 @@ func getNetworkAttrs(network *network) irc.Tags {
}
func networkAddrFromAttrs(attrs irc.Tags) string {
host, ok := attrs.GetTag("host")
if !ok {
host := string(attrs["host"])
if host == "" {
return ""
}
addr := host
if port, ok := attrs.GetTag("port"); ok {
if port := string(attrs["port"]); port != "" {
addr += ":" + port
}
if tlsStr, ok := attrs.GetTag("tls"); ok && tlsStr == "0" {
if tlsStr := string(attrs["tls"]); tlsStr == "0" {
addr = "irc+insecure://" + tlsStr
}