[geary/geary-0.13] Merge branch 'wip/ubuntu-1804-network-unreachable' into 'master'



commit dd60135af2fbcd46d08dc2ce4491e228273c3e85
Author: Michael Gratton <mike vee net>
Date:   Wed Feb 20 00:46:18 2019 +0000

    Merge branch 'wip/ubuntu-1804-network-unreachable' into 'master'
    
    Ubuntu 18.04 network unreachable
    
    Closes #217
    
    See merge request GNOME/geary!112
    
    (cherry picked from commit ac6c369d23770725c8abf4eb898084939420ebc9)
    
    f48170ae Prevent circular refs using idle and timeout manager when running
    7fe445a9 Retry using IPv4 only when connecting to an endpoint fails
    39145933 Fix "Peer sent fatal TLS alert: Decode error" on Ubuntu 18.04

 src/engine/api/geary-endpoint.vala | 41 +++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/api/geary-endpoint.vala b/src/engine/api/geary-endpoint.vala
index 4968751a..c833c92d 100644
--- a/src/engine/api/geary-endpoint.vala
+++ b/src/engine/api/geary-endpoint.vala
@@ -119,8 +119,41 @@ public class Geary.Endpoint : BaseObject {
         this.tls_method = method;
     }
 
-    public async SocketConnection connect_async(Cancellable? cancellable = null) throws Error {
-        return yield get_socket_client().connect_async(this.remote, cancellable);
+    public async GLib.SocketConnection connect_async(GLib.Cancellable? cancellable = null)
+        throws GLib.Error {
+        GLib.SocketClient client = get_socket_client();
+        GLib.IOError? connect_error = null;
+        try {
+            return yield client.connect_async(this.remote, cancellable);
+        } catch (GLib.IOError.NETWORK_UNREACHABLE err) {
+            connect_error = err;
+        }
+
+        // Ubuntu 18.04 for some reason started throwing
+        // NETWORK_UNREACHABLE when an AAAA record was resolved for
+        // host name but no valid IPv6 network was available. Work
+        // around by re-attempting manually resolving and selecting an
+        // address to use. See issue #217.
+        GLib.SocketAddressEnumerator addrs = this.remote.enumerate();
+        GLib.SocketAddress? addr = yield addrs.next_async(cancellable);
+        while (addr != null) {
+            GLib.InetSocketAddress? inet_addr = addr as GLib.InetSocketAddress;
+            if (inet_addr != null) {
+                try {
+                    return yield client.connect_async(
+                        new GLib.InetSocketAddress(
+                            inet_addr.address, (uint16) inet_addr.port
+                        ),
+                        cancellable
+                    );
+                } catch (GLib.IOError.NETWORK_UNREACHABLE err) {
+                    // Keep going
+                }
+            }
+            addr = yield addrs.next_async(cancellable);
+        }
+
+        throw connect_error;
     }
 
     public async TlsClientConnection starttls_handshake_async(IOStream base_stream,
@@ -157,7 +190,9 @@ public class Geary.Endpoint : BaseObject {
     }
 
     private void prepare_tls_cx(GLib.TlsClientConnection tls_cx) {
-        tls_cx.server_identity = this.remote;
+        // Setting this on Ubuntu 18.04 breaks some TLS
+        // connections. See issue #217.
+        // tls_cx.server_identity = this.remote;
         tls_cx.validation_flags = this.tls_validation_flags;
         if (Endpoint.default_tls_database != null) {
             tls_cx.set_database(Endpoint.default_tls_database);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]