diff --git a/src/Tunnel.hs b/src/Tunnel.hs index 4e3f455..8ff68b7 100644 --- a/src/Tunnel.hs +++ b/src/Tunnel.hs @@ -200,8 +200,9 @@ runTlsTunnelingServer (tlsCert, tlsKey) endPoint@(bindTo, portNumber) isAllowed where runApp :: N.AppData -> WS.ConnectionOptions -> WS.ServerApp -> IO () runApp appData opts app = do - let socket = fromJust $ N.appRawSocket appData - stream <- WS.makeStream (N.recv socket defaultRecvBufferSize <&> \payload -> if payload == mempty then Nothing else Just payload) (NL.sendAll socket . fromJust) + stream <- WS.makeStream (N.appRead appData <&> \payload -> if payload == mempty then Nothing else Just payload) (N.appWrite appData . toStrict . fromJust) + --let socket = fromJust $ N.appRawSocket appData + --stream <- WS.makeStream (N.recv socket defaultRecvBufferSize <&> \payload -> if payload == mempty then Nothing else Just payload) (NL.sendAll socket . fromJust) bracket (WS.makePendingConnectionFromStream stream opts) (\conn -> catch (WS.close $ WS.pendingStream conn) (\(_ :: SomeException) -> return ())) app diff --git a/test/Spec.hs b/test/Spec.hs index 4f5a3e7..5ad5c76 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -21,6 +21,7 @@ import Data.Binary (decode, encode) import Tunnel import Types import Protocols +import Credentials import qualified Socks5 as Socks5 testTCPLocalToRemote :: Bool -> IO () @@ -33,7 +34,8 @@ testTCPLocalToRemote useTLS = do -- SERVER let serverPort = 8080 - let serverWithoutTLS = runServer useTLS ("0.0.0.0", serverPort) (const True) + let tls = if useTLS then Just (Credentials.certificate, Credentials.key) else Nothing + let serverWithoutTLS = runServer tls ("0.0.0.0", serverPort) (const True) -- CLIENT let tunnelSetting = TunnelSettings { @@ -54,6 +56,7 @@ testTCPLocalToRemote useTLS = do , tlsSNI = "toto.com" , websocketPingFrequencySec = 30 , customHeaders = [(CI.mk "toto", "tata"), (CI.mk "titi", "tutu")] + , tlsVerifyCertificate = False } let client = runClient tunnelSetting @@ -95,7 +98,8 @@ testUDPLocalToRemote useTLS = do -- SERVER let serverPort = 8080 - let serverWithoutTLS = runServer useTLS ("0.0.0.0", serverPort) (const True) + let tls = if useTLS then Just (Credentials.certificate, Credentials.key) else Nothing + let serverWithoutTLS = runServer tls ("0.0.0.0", serverPort) (const True) -- CLIENT let tunnelSetting = TunnelSettings { @@ -116,6 +120,7 @@ testUDPLocalToRemote useTLS = do , tlsSNI = "toto.com" , websocketPingFrequencySec = 30 , customHeaders = [(CI.mk "toto", "tata"), (CI.mk "titi", "tutu")] + , tlsVerifyCertificate = False } let client = runClient tunnelSetting @@ -156,7 +161,8 @@ testSocks5Tunneling useTLS = do -- SERVER let serverPort = 8080 - let serverWithoutTLS = runServer useTLS ("0.0.0.0", serverPort) (const True) + let tls = if useTLS then Just (Credentials.certificate, Credentials.key) else Nothing + let serverWithoutTLS = runServer tls ("0.0.0.0", serverPort) (const True) -- CLIENT let tunnelSetting = TunnelSettings { @@ -177,6 +183,7 @@ testSocks5Tunneling useTLS = do , tlsSNI = "toto.com" , websocketPingFrequencySec = 30 , customHeaders = [(CI.mk "toto", "tata"), (CI.mk "titi", "tutu")] + , tlsVerifyCertificate = False } let client = runClient tunnelSetting diff --git a/wstunnel.cabal b/wstunnel.cabal index 5dfd651..59ada20 100644 --- a/wstunnel.cabal +++ b/wstunnel.cabal @@ -1,5 +1,5 @@ name: wstunnel -version: 0.5.0.0 +version: 0.5.1.0 synopsis: Tunneling program over websocket protocol description: For more information regarding wstunnel, please refer to README.md homepage: https://github.com/githubuser/wstunnel#readme