Skip to content

Commit

Permalink
Fix stdio support #39
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain GÉRARD committed Feb 24, 2020
1 parent 9251838 commit 246f55f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 246f55f

Please sign in to comment.