Add socks5 options to commandline
This commit is contained in:
parent
d2bd237bdd
commit
ff6c4164b8
2 changed files with 40 additions and 23 deletions
62
app/Main.hs
62
app/Main.hs
|
@ -14,16 +14,16 @@ import System.Environment (getArgs, withArgs)
|
||||||
import qualified System.Log.Logger as LOG
|
import qualified System.Log.Logger as LOG
|
||||||
|
|
||||||
data WsTunnel = WsTunnel
|
data WsTunnel = WsTunnel
|
||||||
{ localToRemote :: String
|
{ localToRemote :: String
|
||||||
-- , remoteToLocal :: String
|
-- , remoteToLocal :: String
|
||||||
-- , dynamicToRemote :: String
|
, dynamicToRemote :: String
|
||||||
, wsTunnelServer :: String
|
, wsTunnelServer :: String
|
||||||
, udpMode :: Bool
|
, udpMode :: Bool
|
||||||
, proxy :: String
|
, proxy :: String
|
||||||
, serverMode :: Bool
|
, serverMode :: Bool
|
||||||
, restrictTo :: String
|
, restrictTo :: String
|
||||||
, verbose :: Bool
|
, verbose :: Bool
|
||||||
, quiet :: Bool
|
, quiet :: Bool
|
||||||
} deriving (Show, Data, Typeable)
|
} deriving (Show, Data, Typeable)
|
||||||
|
|
||||||
data WsServerInfo = WsServerInfo
|
data WsServerInfo = WsServerInfo
|
||||||
|
@ -43,9 +43,11 @@ data TunnelInfo = TunnelInfo
|
||||||
cmdLine :: WsTunnel
|
cmdLine :: WsTunnel
|
||||||
cmdLine = WsTunnel
|
cmdLine = WsTunnel
|
||||||
{ localToRemote = def &= explicit &= name "L" &= name "localToRemote" &= typ "[BIND:]PORT:HOST:PORT"
|
{ localToRemote = def &= explicit &= name "L" &= name "localToRemote" &= typ "[BIND:]PORT:HOST:PORT"
|
||||||
&= help "Listen on local and forward traffic from remote" &= groupname "Client options"
|
&= help "Listen on local and forwards traffic from remote" &= groupname "Client options"
|
||||||
-- , remoteToLocal = def &= explicit &= name "R" &= name "RemoteToLocal" &= typ "[BIND:]PORT:HOST:PORT"
|
-- , remoteToLocal = def &= explicit &= name "R" &= name "RemoteToLocal" &= typ "[BIND:]PORT:HOST:PORT"
|
||||||
-- &= help "Listen on remote and forward traffic from local"
|
-- &= help "Listen on remote and forward traffic from local"
|
||||||
|
, dynamicToRemote= def &= explicit &= name "D" &= name "dynamicToRemote" &= typ "[BIND:]PORT"
|
||||||
|
&= help "Listen on local and dynamically (with socks5 proxy) forwards traffic from remote" &= groupname "Client options"
|
||||||
, udpMode = def &= explicit &= name "u" &= name "udp" &= help "forward UDP traffic instead of TCP"
|
, udpMode = def &= explicit &= name "u" &= name "udp" &= help "forward UDP traffic instead of TCP"
|
||||||
, proxy = def &= explicit &= name "p" &= name "httpProxy"
|
, proxy = def &= explicit &= name "p" &= name "httpProxy"
|
||||||
&= help "If set, will use this proxy to connect to the server" &= typ "USER:PASS@HOST:PORT"
|
&= help "If set, will use this proxy to connect to the server" &= typ "USER:PASS@HOST:PORT"
|
||||||
|
@ -130,19 +132,33 @@ main = do
|
||||||
if serverMode cfg
|
if serverMode cfg
|
||||||
then putStrLn ("Starting server with opts " ++ show serverInfo )
|
then putStrLn ("Starting server with opts " ++ show serverInfo )
|
||||||
>> runServer (Main.useTls serverInfo) (Main.host serverInfo, fromIntegral $ Main.port serverInfo) (parseRestrictTo $ restrictTo cfg)
|
>> runServer (Main.useTls serverInfo) (Main.host serverInfo, fromIntegral $ Main.port serverInfo) (parseRestrictTo $ restrictTo cfg)
|
||||||
else if not $ null (localToRemote cfg)
|
else if not $ null (localToRemote cfg)
|
||||||
then let (TunnelInfo lHost lPort rHost rPort) = parseTunnelInfo (localToRemote cfg)
|
then let (TunnelInfo lHost lPort rHost rPort) = parseTunnelInfo (localToRemote cfg)
|
||||||
in runClient TunnelSettings { localBind = lHost
|
in runClient TunnelSettings { localBind = lHost
|
||||||
, Tunnel.localPort = fromIntegral lPort
|
, Tunnel.localPort = fromIntegral lPort
|
||||||
, serverHost = Main.host serverInfo
|
, serverHost = Main.host serverInfo
|
||||||
, serverPort = fromIntegral $ Main.port serverInfo
|
, serverPort = fromIntegral $ Main.port serverInfo
|
||||||
, destHost = rHost
|
, destHost = rHost
|
||||||
, destPort = fromIntegral rPort
|
, destPort = fromIntegral rPort
|
||||||
, Tunnel.useTls = Main.useTls serverInfo
|
, Tunnel.useTls = Main.useTls serverInfo
|
||||||
, protocol = if udpMode cfg then UDP else TCP
|
, protocol = if udpMode cfg then UDP else TCP
|
||||||
, proxySetting = parseProxyInfo (proxy cfg)
|
, proxySetting = parseProxyInfo (proxy cfg)
|
||||||
}
|
, useSocks = False
|
||||||
else return ()
|
}
|
||||||
|
else if not $ null (dynamicToRemote cfg)
|
||||||
|
then let (TunnelInfo lHost lPort _ _) = parseTunnelInfo $ (localToRemote cfg) ++ ":127.0.0.1:0"
|
||||||
|
in runClient TunnelSettings { localBind = lHost
|
||||||
|
, Tunnel.localPort = fromIntegral lPort
|
||||||
|
, serverHost = Main.host serverInfo
|
||||||
|
, serverPort = fromIntegral $ Main.port serverInfo
|
||||||
|
, destHost = ""
|
||||||
|
, destPort = fromIntegral 0
|
||||||
|
, Tunnel.useTls = Main.useTls serverInfo
|
||||||
|
, protocol = if udpMode cfg then UDP else TCP
|
||||||
|
, proxySetting = parseProxyInfo (proxy cfg)
|
||||||
|
, useSocks = True
|
||||||
|
}
|
||||||
|
else return ()
|
||||||
|
|
||||||
|
|
||||||
putStrLn "Goodbye !"
|
putStrLn "Goodbye !"
|
||||||
|
|
|
@ -60,6 +60,7 @@ data TunnelSettings = TunnelSettings
|
||||||
, destPort :: PortNumber
|
, destPort :: PortNumber
|
||||||
, protocol :: Protocol
|
, protocol :: Protocol
|
||||||
, useTls :: Bool
|
, useTls :: Bool
|
||||||
|
, useSocks :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Show TunnelSettings where
|
instance Show TunnelSettings where
|
||||||
|
|
Loading…
Reference in a new issue