From d340e19e72ffe277d47940d4cc54a3042a93dd71 Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Mon, 20 Jul 2026 19:36:58 +0000 Subject: [PATCH] remote control: fall back to IPv4 when IPv6 bind fails The remote-host TLS listener binds via startTCPServer with host=Nothing, which prefers the IPv6 wildcard (::). The invitation sent to the mobile device only ever advertises an IPv4 address, so when IPv6 is disabled the bind to :: throws and the desktop app cannot be reached (issue #5515). Keep the existing IPv6-preferring bind and only fall back to binding 0.0.0.0 when it fails, so behaviour is unchanged whenever IPv6 is available and the SMP server transport path is not touched. --- src/Simplex/RemoteControl/Discovery.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Simplex/RemoteControl/Discovery.hs b/src/Simplex/RemoteControl/Discovery.hs index 4a69a57a16..7f47959326 100644 --- a/src/Simplex/RemoteControl/Discovery.hs +++ b/src/Simplex/RemoteControl/Discovery.hs @@ -80,12 +80,17 @@ preferAddress RCCtrlAddress {address, interface} addrs = startTLSServer :: Maybe Word16 -> TMVar (Maybe N.PortNumber) -> TLS.Credential -> TLS.ServerHooks -> (Transport.TLS 'TServer -> IO ()) -> IO (Async ()) startTLSServer port_ startedOnPort credentials hooks server = async . liftIO $ do started <- newEmptyTMVarIO - bracketOnError (startTCPServer started Nothing $ maybe "0" show port_) (\_e -> setPort Nothing) $ \socket -> + bracketOnError (startTCPServerCtrl started $ maybe "0" show port_) (\_e -> setPort Nothing) $ \socket -> ifM (atomically $ readTMVar started) (runServer started socket) (setPort Nothing) where + -- Bind preferring IPv6 (dual-stack) as before; if that fails (e.g. IPv6 is + -- disabled), fall back to IPv4 so the (IPv4-only) invitation stays reachable. + startTCPServerCtrl started port = + startTCPServer started Nothing port + `catchAny` \_ -> startTCPServer started (Just "0.0.0.0") port runServer started socket = do port <- N.socketPort socket logInfo $ "System-assigned port: " <> tshow port