diff --git a/src/Tunnel.hs b/src/Tunnel.hs index 4faefb5..778b0ec 100644 --- a/src/Tunnel.hs +++ b/src/Tunnel.hs @@ -200,7 +200,8 @@ runTlsTunnelingServer endPoint@(bindTo, portNumber) isAllowed = do where runApp :: N.AppData -> WS.ConnectionOptions -> WS.ServerApp -> IO () runApp appData opts app = do - 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/src/Types.hs b/src/Types.hs index cf9c8cb..a7f73d0 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -33,7 +33,7 @@ deriving instance Hashable N.SockAddr {-# NOINLINE defaultRecvBufferSize #-} defaultRecvBufferSize :: Int defaultRecvBufferSize = unsafeDupablePerformIO $ - bracket (N.socket N.AF_INET N.Stream 0) N.close (\sock -> N.getSocketOption sock N.RecvBuffer) + bracket (N.socket N.AF_INET N.Stream 0) N.close (\sock -> N.getSocketOption sock N.RecvBuffer) sO_MARK :: N.SocketOption sO_MARK = N.SockOpt 1 36 -- https://elixir.bootlin.com/linux/latest/source/arch/alpha/include/uapi/asm/socket.h#L64