From 71019e413b62f7fa633fed1beb4f494be4a8da19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20G=C3=89RARD?= Date: Mon, 24 Feb 2020 22:52:42 +0100 Subject: [PATCH] Fix stdio support #39 Former-commit-id: 246f55f584386261c60b3fee45e5efad98e790c3 Former-commit-id: bf287dec2a7468f0b253a024cac8b29ee3342bee [formerly 8176e5d0f3ef5144d2d01ba5f4b81d481be22b2f] [formerly e17da24300ea7102d78efa1255e416b8e7b67375 [formerly 1cdc5f6b4861456b79e39623c460c838bd6e7694 [formerly 1cdc5f6b4861456b79e39623c460c838bd6e7694 [formerly 1cdc5f6b4861456b79e39623c460c838bd6e7694 [formerly 4d081fcee59b8792745920c53d40eb1ec7c54ae8]]]]] Former-commit-id: 90d0d845d9c305199f1e0364dbafcfe6bd81e882 [formerly d155d83a30a656fea2296629fac8d9e30ea99888] Former-commit-id: 1fbff0cbcafe6e32d72d34f5892fd68641da15c5 Former-commit-id: d3dd64e785bb151d9cd7e76e50b519a74fa19b4b Former-commit-id: 6532a7f8583cd4461298fa4c8d1277e6ce656160 Former-commit-id: 3039e574018bf5af261f19653509ac399d286f8e [formerly 7d9f3cdd94d34d24efb81ad831432570327bf24c] Former-commit-id: 3bca307bbaf0cf6e98e4c725076df3c97472b639 --- app/Main.hs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Main.hs b/app/Main.hs index e594140..28795e5 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -192,7 +192,10 @@ runApp cfg serverInfo -- -L localToRemote tunnels | not . null $ localToRemote cfg = do let tunnelInfos = parseTunnelInfo <$> localToRemote cfg - let tunnelSettings = tunnelInfos >>= \tunnelInfo -> [toTcpLocalToRemoteTunnelSetting cfg serverInfo tunnelInfo, toUdpLocalToRemoteTunnelSetting cfg serverInfo tunnelInfo] + let tunnelSettings = tunnelInfos >>= \tunnelInfo -> + if Main.localPort tunnelInfo == 0 then [toStdioLocalToRemoteTunnelSetting cfg serverInfo tunnelInfo] + else if udpMode cfg then [toUdpLocalToRemoteTunnelSetting cfg serverInfo tunnelInfo] + else [toTcpLocalToRemoteTunnelSetting cfg serverInfo tunnelInfo] Async.mapConcurrently_ runClient tunnelSettings -- -D dynamicToRemote tunnels @@ -204,6 +207,22 @@ runApp cfg serverInfo putStrLn "Cannot parse correctly the command line. Please fill an issue" where + toStdioLocalToRemoteTunnelSetting cfg serverInfo (TunnelInfo lHost lPort rHost rPort) = + TunnelSettings { + localBind = lHost + , Types.localPort = fromIntegral lPort + , serverHost = Main.host serverInfo + , serverPort = fromIntegral $ Main.port serverInfo + , destHost = rHost + , destPort = fromIntegral rPort + , Types.useTls = Main.useTls serverInfo + , protocol = STDIO + , proxySetting = parseProxyInfo (proxy cfg) + , useSocks = False + , upgradePrefix = pathPrefix cfg + , udpTimeout = Main.udpTimeout cfg + } + toTcpLocalToRemoteTunnelSetting cfg serverInfo (TunnelInfo lHost lPort rHost rPort) = TunnelSettings { localBind = lHost