~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 2

[PATCH] xirc: Fix sending hostnames starting with ':' in WHO replies

Details
Message ID
<20230121135926.6204-1-delthas@dille.cc>
DKIM signature
missing
Download raw message
Patch: +5 -0
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
Details
Message ID
<CANnEQ3GJEUW+QKVg6aC2YACmcOzpv=N4eoCYJ8=YQY3Aj-KAWQ@mail.gmail.com>
In-Reply-To
<20230121135926.6204-1-delthas@dille.cc> (view parent)
DKIM signature
missing
Download raw message
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
>
Details
Message ID
<v_XHLU4X5rZ5eVDvSjPZjdFwmCJpiSyh_xvOzt0Ohm50rcjIwUS74O8XlMLZtDHfArjFsV83KFU8Wq12CmFGiYhrsjoF04wkglpGlt7leVo=@emersion.fr>
In-Reply-To
<20230121135926.6204-1-delthas@dille.cc> (view parent)
DKIM signature
missing
Download raw message
Edited to not mutate the field. Pushed, thanks!
Details
Message ID
<NKVwk98ZZgZP6mcKTYz004t_EqMQ64XSxghjs6xylj9gkfVWqZQ3Q10QaekLLug_C753Iy8FmHGj2MPGrDlr91iYp7xuyA5wGK1EIsdkzt4=@emersion.fr>
In-Reply-To
<CANnEQ3GJEUW+QKVg6aC2YACmcOzpv=N4eoCYJ8=YQY3Aj-KAWQ@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<CANnEQ3HC3xZoOpn+kDakcXikf+1DtoNzNrOLwRDWoNZqyovd9w@mail.gmail.com>
In-Reply-To
<NKVwk98ZZgZP6mcKTYz004t_EqMQ64XSxghjs6xylj9gkfVWqZQ3Q10QaekLLug_C753Iy8FmHGj2MPGrDlr91iYp7xuyA5wGK1EIsdkzt4=@emersion.fr> (view parent)
DKIM signature
missing
Download raw message
On Wed, Jan 25, 2023 at 1:05 AM Simon Ser <contact@emersion.fr> wrote:
> No, this would confuse clients which parse the IP and don't expect
> square brackets. See:
> https://modern.ircdocs.horse/#rplwhoisuser-311

I see, thanks for clarifying.
Reply to thread Export thread (mbox)