~rjarry/aerc-devel

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

[PATCH aerc] imap: fix connection when host only has ipv6 address

Details
Message ID
<20240203231147.393514-2-robin@jarry.cc>
DKIM signature
pass
Download raw message
Patch: +3 -9
Some IMAP servers report both IPv4 and IPv6 addresses from their DNS
name:

 $ host imap.gmail.com
 imap.gmail.com has address 108.177.15.109
 imap.gmail.com has address 108.177.15.108
 imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6c
 imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6d

ResolveTCPAddr actually returns the first *IPv4* address by default,
unless the address string is an explicit IPv6 address.

Directly use net.Dial which has a fast fallback mechanism. It first
tries to connect with an IPv6 address (if any) and if that fails, it
will retry with an IPv4 address (if any) before failing completely.

Link: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/ipsock.go;l=81
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCYVLU3AOA00I.26I5IMAF3T4CK%40dow.land%3E
Link: https://pkg.go.dev/net#Dial
Reported-by: Jonathan Dowland <jon@dow.land>
Signed-off-by: Robin Jarry <robin@jarry.cc>
---
 worker/imap/connect.go | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/worker/imap/connect.go b/worker/imap/connect.go
index 818952accbe7..79254bb92c4e 100644
--- a/worker/imap/connect.go
+++ b/worker/imap/connect.go
@@ -123,19 +123,13 @@ func newTCPConn(addr string, timeout time.Duration) (*net.TCPConn, error) {
	done := make(chan tcpConn)
	go func() {
		defer log.PanicHandler()
		addr, err := net.ResolveTCPAddr("tcp", addr)

		newConn, err := net.Dial("tcp", addr)
		if err != nil {
			done <- tcpConn{nil, err}
			return
		}

		newConn, err := net.DialTCP("tcp", nil, addr)
		if err != nil {
			done <- tcpConn{nil, err}
			return
		}

		done <- tcpConn{newConn, nil}
		done <- tcpConn{newConn.(*net.TCPConn), nil}
	}()

	select {
-- 
2.43.0

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CYVTIFNW7PUH.3V76889OI8EPX@fra01>
In-Reply-To
<20240203231147.393514-2-robin@jarry.cc> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 2m1s

[imap: fix connection when host only has ipv6 address][0] from [Robin Jarry][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/49165
[1]: robin@jarry.cc

✓ #1143025 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1143025
✓ #1143024 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1143024
Details
Message ID
<CYVTUVMQQIGR.7GHV5KDV6L9O@gmail.com>
In-Reply-To
<20240203231147.393514-2-robin@jarry.cc> (view parent)
DKIM signature
pass
Download raw message
On Sun Feb 4, 2024 at 12:11 AM CET, Robin Jarry wrote:
> Some IMAP servers report both IPv4 and IPv6 addresses from their DNS
> name:
>
>  $ host imap.gmail.com
>  imap.gmail.com has address 108.177.15.109
>  imap.gmail.com has address 108.177.15.108
>  imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6c
>  imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6d
>
> ResolveTCPAddr actually returns the first *IPv4* address by default,
> unless the address string is an explicit IPv6 address.
>
> Directly use net.Dial which has a fast fallback mechanism. It first
> tries to connect with an IPv6 address (if any) and if that fails, it
> will retry with an IPv4 address (if any) before failing completely.
>
> Link: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/ipsock.go;l=81
> Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCYVLU3AOA00I.26I5IMAF3T4CK%40dow.land%3E
> Link: https://pkg.go.dev/net#Dial
> Reported-by: Jonathan Dowland <jon@dow.land>
> Signed-off-by: Robin Jarry <robin@jarry.cc>
> ---
>  worker/imap/connect.go | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>

ss(8) shows that the tcp socket for imaps is now IPv6 (was IPv4 before).

Tested-by: Koni Marti <koni.marti@gmail.com>
Details
Message ID
<CYW6OS7I5T2R.2GVRT04KPII9E@ringo>
In-Reply-To
<CYVTUVMQQIGR.7GHV5KDV6L9O@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Koni Marti, Feb 04, 2024 at 00:20:
> On Sun Feb 4, 2024 at 12:11 AM CET, Robin Jarry wrote:
> > Some IMAP servers report both IPv4 and IPv6 addresses from their DNS
> > name:
> >
> >  $ host imap.gmail.com
> >  imap.gmail.com has address 108.177.15.109
> >  imap.gmail.com has address 108.177.15.108
> >  imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6c
> >  imap.gmail.com has IPv6 address 2a00:1450:400c:c0a::6d
> >
> > ResolveTCPAddr actually returns the first *IPv4* address by default,
> > unless the address string is an explicit IPv6 address.
> >
> > Directly use net.Dial which has a fast fallback mechanism. It first
> > tries to connect with an IPv6 address (if any) and if that fails, it
> > will retry with an IPv4 address (if any) before failing completely.
> >
> > Link: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/ipsock.go;l=81
> > Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCYVLU3AOA00I.26I5IMAF3T4CK%40dow.land%3E
> > Link: https://pkg.go.dev/net#Dial
> > Reported-by: Jonathan Dowland <jon@dow.land>
> > Signed-off-by: Robin Jarry <robin@jarry.cc>
> > ---
> >  worker/imap/connect.go | 12 +++---------
> >  1 file changed, 3 insertions(+), 9 deletions(-)
> >
>
> ss(8) shows that the tcp socket for imaps is now IPv6 (was IPv4 before).
>
> Tested-by: Koni Marti <koni.marti@gmail.com>

Special FOSDEM live fix applied :)

Thanks!
Details
Message ID
<CYW8GOCZRTKR.PFV0F1E2HNHQ@cepl.eu>
In-Reply-To
<20240203231147.393514-2-robin@jarry.cc> (view parent)
DKIM signature
missing
Download raw message
On Sun Feb 4, 2024 at 12:11 AM CET, Robin Jarry wrote:
> Some IMAP servers report both IPv4 and IPv6 addresses from their DNS
> name:

I seem to have the same problem with sending. I have here

     outgoing = smtp://mcepl%40cepl.eu@redcrew.org

and

  $ host redcrew.org
redcrew.org has address 37.157.195.192
redcrew.org has IPv6 address 2a02:2b88:2:1::1cde:1
redcrew.org mail is handled by 10 redcrew.org.
  $

and when sending an email (actually sending Tested-by: to this patch ;)) 
I get error:

DEBUG 2024/02/04 11:40:49.097348 send.go:125: send config uri: 
smtp://mcepl%40cepl.eu:verysecret@redcrew.org
DEBUG 2024/02/04 11:40:49.097398 send.go:126: send config scheme: smtp
DEBUG 2024/02/04 11:40:49.097402 send.go:127: send config auth: plain
DEBUG 2024/02/04 11:40:49.097415 send.go:128: send config from: 
=?utf-8?q?Mat=C4=9Bj_Cepl?= <mcepl@cepl.eu>
DEBUG 2024/02/04 11:40:49.097424 send.go:129: send config rcpts: ["Robin 
Jarry" <robin@jarry.cc> <~rjarry/aerc-devel@lists.sr.ht> "Jonathan 
Dowland" <jon@dow.land>]
DEBUG 2024/02/04 11:40:49.097429 send.go:130: send config domain:
DEBUG 2024/02/04 11:40:49.097443 status.go:104: Sending...
DEBUG 2024/02/04 11:40:49.097459 send.go:175: send uri: 
smtp://mcepl%40cepl.eu:%5DfJTTIuHF7zunkNd@redcrew.org
ERROR 2024/02/04 11:40:49.132260 status.go:129: send:: Connection 
failed: smtp.Dial: dial tcp [2a02:2b88:2:1::1cde:1]:587: connect: 
connection refused
DEBUG 2024/02/04 11:40:49.132294 status.go:104: send:: Connection 
failed: smtp.Dial: dial tcp [2a02:2b88:2:1::1cde:1]:587: connect: 
connection refused

Any idea what's going on?

Best,

Matěj

-- 
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8

God is not worried about my financial situation.
Details
Message ID
<CYW8PXA76KT3.3RR58UIYO6GI1@ringo>
In-Reply-To
<CYW8GOCZRTKR.PFV0F1E2HNHQ@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
mcepl, Feb 04, 2024 at 11:31:
> Any idea what's going on?

If IMAP works, maybe your SMTP server has the 587 port blocked on IPv6. 
If you control the server, can you have a look at nft list ruleset 
output?
Jonathan Dowland <jon@dow.land>
Details
Message ID
<CYW8TZVPQNZ0.52P50OESMU64@dow.land>
In-Reply-To
<20240203231147.393514-2-robin@jarry.cc> (view parent)
DKIM signature
pass
Download raw message
To confirm this patch (2187ea16 in tree) fixes IMAP for me :-)
Jonathan Dowland <jon@dow.land>
Details
Message ID
<CYW8W08JLQKJ.3GQTS2MH5LVDM@dow.land>
In-Reply-To
<CYW8GOCZRTKR.PFV0F1E2HNHQ@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
On Sun Feb 4, 2024 at 10:31 AM GMT,  wrote:
> On Sun Feb 4, 2024 at 12:11 AM CET, Robin Jarry wrote:
> > Some IMAP servers report both IPv4 and IPv6 addresses from their DNS
> > name:
>
> I seem to have the same problem with sending.

Me too, but I can't otherwise confirm that it's aerc (or go) at fault
(I can't send via neomutt today either)
Reply to thread Export thread (mbox)