diff --git a/app/Main.hs b/app/Main.hs index a91bfac..e594140 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -64,7 +64,7 @@ cmdLine = WsTunnel , proxy = def &= explicit &= name "p" &= name "httpProxy" &= help "If set, will use this proxy to connect to the server" &= typ "USER:PASS@HOST:PORT" , soMark = def &= explicit &= name "soMark" - &= help "(linux only) Mark network packet with SO_MARK sockoption with the specified value" &= typ "int" + &= help "(linux only) Mark network packet with SO_MARK sockoption with the specified value. You need to use {root, sudo, capabilities} to run wstunnel when using this option" &= typ "int" , wsTunnelServer = def &= argPos 0 &= typ "ws[s]://wstunnelServer[:port]" , serverMode = def &= explicit &= name "server" diff --git a/src/Tunnel.hs b/src/Tunnel.hs index e0fd81a..7a3df7c 100644 --- a/src/Tunnel.hs +++ b/src/Tunnel.hs @@ -45,7 +45,7 @@ rrunTCPClient cfg app = bracket N.setSocketOption s N.RecvBuffer defaultRecvBufferSize N.setSocketOption s N.SendBuffer defaultSendBufferSize so_mark_val <- readIORef sO_MARK_Value - when (N.isSupportedSocketOption sO_MARK) (N.setSocketOption s sO_MARK so_mark_val) + _ <- when (so_mark_val /= 0 && N.isSupportedSocketOption sO_MARK) (N.setSocketOption s sO_MARK so_mark_val) return (s,addr) ) (\r -> catch (N.close $ fst r) (\(_ :: SomeException) -> return ())) diff --git a/src/Types.hs b/src/Types.hs index ae6c49c..6ee8c76 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -40,7 +40,7 @@ sO_MARK = N.CustomSockOpt (fromIntegral 1, fromIntegral 36) -- https://elixir.bo {-# NOINLINE sO_MARK_Value #-} sO_MARK_Value :: IORef Int -sO_MARK_Value = unsafeDupablePerformIO $ (newIORef 131072) +sO_MARK_Value = unsafeDupablePerformIO $ (newIORef 0) data Protocol = UDP | TCP | STDIO | SOCKS5 deriving (Show, Read, Eq)