Some IPv6 hostnames can start with a colon (eg '::1'). This breaks
the IRC line format.
To work around this issue, prefix the hostname with a '0'. This
changes the representation of the IP but not its value.
See: https://todo.sr.ht/~taiite/senpai/109
---
xirc/whox.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/xirc/whox.go b/xirc/whox.go
index 2e11813..ee5978c 100644
--- a/xirc/whox.go+++ b/xirc/whox.go
@@ -80,6 +80,11 @@ func (info *WHOXInfo) set(k byte, v string) {
}
func GenerateWHOXReply(prefix *irc.Prefix, nick, fields string, info *WHOXInfo) *irc.Message {
+ if strings.HasPrefix(info.Hostname, ":") {+ // The hostname cannot start with a colon as this would get parsed as a trailing parameter.+ // IPv6 addresses such as "::1" are prefixed with a zero to ensure this.+ info.Hostname = "0" + info.Hostname+ } if fields == "" {
return &irc.Message{
Prefix: prefix,
base-commit: 959baa964f45b40fad239e21a246e3b963f9ca57
--
2.38.0
On Sun, Jan 22, 2023 at 12:32 AM delthas <delthas@dille.cc> wrote:
>> Some IPv6 hostnames can start with a colon (eg '::1'). This breaks> the IRC line format.>> To work around this issue, prefix the hostname with a '0'. This> changes the representation of the IP but not its value.>> See: https://todo.sr.ht/~taiite/senpai/109> ---> xirc/whox.go | 5 +++++> 1 file changed, 5 insertions(+)>> diff --git a/xirc/whox.go b/xirc/whox.go> index 2e11813..ee5978c 100644> --- a/xirc/whox.go> +++ b/xirc/whox.go> @@ -80,6 +80,11 @@ func (info *WHOXInfo) set(k byte, v string) {> }>> func GenerateWHOXReply(prefix *irc.Prefix, nick, fields string, info *WHOXInfo) *irc.Message {> + if strings.HasPrefix(info.Hostname, ":") {> + // The hostname cannot start with a colon as this would get parsed as a trailing parameter.> + // IPv6 addresses such as "::1" are prefixed with a zero to ensure this.
I wonder if the square brackets notation [::1] would make sense here?
> + info.Hostname = "0" + info.Hostname> + }> if fields == "" {> return &irc.Message{> Prefix: prefix,>> base-commit: 959baa964f45b40fad239e21a246e3b963f9ca57> --> 2.38.0>
On Monday, January 23rd, 2023 at 21:47, novenary <streetwalkermc@gmail.com> wrote:
> I wonder if the square brackets notation [::1] would make sense here?
No, this would confuse clients which parse the IP and don't expect
square brackets. See:
https://modern.ircdocs.horse/#rplwhoisuser-311