comparison plugins/mod_proxy65.lua @ 14158:f34ad235cf3b 0.12

mod_proxy65: Don't link connections until after activation Although the module pauses the connections, in some cases server.link() (at least with the epoll backend) will have the effect of unpausing the connection (because it sets new read handlers). Many thanks to Max Hearnden for discovering and reporting this issue.
author Matthew Wild <mwild1@gmail.com>
date Wed, 29 Apr 2026 11:37:21 +0100
parents 3bbb1af92514
children 4bbb17445ed9
comparison
equal deleted inserted replaced
14157:f881ed0ee8bd 14158:f34ad235cf3b
58 module:log("debug", "SOCKS5 target connected for session %s", sha); 58 module:log("debug", "SOCKS5 target connected for session %s", sha);
59 else -- transfers[sha].target ~= nil 59 else -- transfers[sha].target ~= nil
60 transfers[sha].initiator = conn; 60 transfers[sha].initiator = conn;
61 session.sha = sha; 61 session.sha = sha;
62 module:log("debug", "SOCKS5 initiator connected for session %s", sha); 62 module:log("debug", "SOCKS5 initiator connected for session %s", sha);
63 server.link(conn, transfers[sha].target, max_buffer_size);
64 server.link(transfers[sha].target, conn, max_buffer_size);
65 end 63 end
66 else -- error, unexpected input 64 else -- error, unexpected input
67 conn:write("\5\1\0\3\0\0\0"); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte) 65 conn:write("\5\1\0\3\0\0\0"); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte)
68 conn:close(); 66 conn:close();
69 module:log("debug", "Invalid SOCKS5 negotiation received: %q", data:sub(1, 300)); 67 module:log("debug", "Invalid SOCKS5 negotiation received: %q", data:sub(1, 300));
164 -- module:log("debug", "The recipient was not connected to the proxy; activation failed (%s)", info); 162 -- module:log("debug", "The recipient was not connected to the proxy; activation failed (%s)", info);
165 -- origin.send(st.error_reply(stanza, "cancel", "not-allowed", "The recipient is not connected to the proxy")); 163 -- origin.send(st.error_reply(stanza, "cancel", "not-allowed", "The recipient is not connected to the proxy"));
166 else -- if transfers[sha].initiator ~= nil and transfers[sha].target ~= nil then 164 else -- if transfers[sha].initiator ~= nil and transfers[sha].target ~= nil then
167 module:log("debug", "Transfer activated (%s)", info); 165 module:log("debug", "Transfer activated (%s)", info);
168 transfers[sha].activated = true; 166 transfers[sha].activated = true;
167 server.link(transfers[sha].initiator, transfers[sha].target, max_buffer_size);
168 server.link(transfers[sha].target, transfers[sha].initiator, max_buffer_size);
169 transfers[sha].target:resume(); 169 transfers[sha].target:resume();
170 transfers[sha].initiator:resume(); 170 transfers[sha].initiator:resume();
171 origin.send(st.reply(stanza)); 171 origin.send(st.reply(stanza));
172 end 172 end
173 elseif to and sid then 173 elseif to and sid then