From 395411a4b7bde9abd2babf9c340caac269330dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Sat, 7 Jan 2023 21:55:17 +0100 Subject: [PATCH] fix tests Former-commit-id: 3c1a21d65244abf3246e613894e87b8003cf0b0d Former-commit-id: 7bc826fe1639e801bed796b98b335a17a895534a [formerly d60d7601d0bc507981a324ab9409c714da95704d] [formerly 867e778fb88d3613ca9f15664a220dcef968b916 [formerly ebdd8bd6976374edc4b90380c6ab0170767365e4 [formerly ebdd8bd6976374edc4b90380c6ab0170767365e4 [formerly 8857bded398e0483a2c05a7151ee10bc6a924090]] [formerly ebdd8bd6976374edc4b90380c6ab0170767365e4 [formerly 8857bded398e0483a2c05a7151ee10bc6a924090] [formerly 8857bded398e0483a2c05a7151ee10bc6a924090 [formerly e10ed5b7830b0d92e6a02fc2b014911391c069a8]]]]] Former-commit-id: 8ce3d6efb0bd0a736ab8b26863500c97ae74b326 [formerly ffb58efa8e318ec077393824e3b78fa584122323] Former-commit-id: f35c65a8dc1a03257ac808f9db49ec637256432b Former-commit-id: c6b92d91ee088509fe4c04bfd8b3cb120fbdee7d Former-commit-id: a320429f1e660d218c87a570202337c1648f2645 Former-commit-id: c69b9ac920eb12fc7545017c085c0f15994448ca [formerly 6a5abade9fd1f7250558a9bc653e2e9a151ab173] Former-commit-id: 080d2f5fa42ded6e2fa74ae5325ee62025773c64 --- src/Tunnel.hs | 5 +++-- test/Spec.hs | 13 ++++++++++--- wstunnel.cabal | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) 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