Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created December 3, 2018 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singpolyma/50aa32157b727871fa1f569ddcfc0721 to your computer and use it in GitHub Desktop.
Save singpolyma/50aa32157b727871fa1f569ddcfc0721 to your computer and use it in GitHub Desktop.
diff -r 7a3ac037e57f mod_onions/mod_onions.lua
--- a/mod_onions/mod_onions.lua Fri Jun 08 21:59:42 2018 +0200
+++ b/mod_onions/mod_onions.lua Mon Dec 03 01:28:59 2018 +0000
@@ -148,12 +148,16 @@
end
function socks5listener.onconnect(conn)
+ if not sessions[conn].socks5_handler == socks5_handshake_sent then
+
module:log("debug", "Connected to SOCKS5 proxy, sending SOCKS5 handshake.");
-- Socks version 5, 1 method, no auth
conn:write(c(5) .. c(1) .. c(0));
sessions[conn].socks5_handler = socks5_handshake_sent;
+
+ end
end
function socks5listener.register_outgoing(conn, session)
@mwild1
Copy link

mwild1 commented Dec 3, 2018

This if condition is almost certainly not what you intended. Due to operator precedence rules, the 'not' affects the immediately adjacent value, i.e. it will turn sessions[conn].socks5_handler into either true or false and proceed to compare that with socks5_handshake_sent (which is always a function value).

You can test this easily in the Lua REPL:

> if not "a" == "a" then print "hello" end
> if not "a" == "b" then print "hello" end
> if not ("a" == "a") then print "hello" end
> if not ("a" == "b") then print "hello" end
hello

Now, since you said this patch actually fixes your issue, I think we need to further understand the problem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment