Skip to content

Instantly share code, notes, and snippets.

@ppmathis
Last active April 2, 2018 20:11
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 ppmathis/aade39527de118e87ba99098dacb7677 to your computer and use it in GitHub Desktop.
Save ppmathis/aade39527de118e87ba99098dacb7677 to your computer and use it in GitHub Desktop.
function listener.onconnect(conn)
-- Debug code for analyzing stacktraces
if conn:ip() == nil then
module:log("warn", "[ppmathis] conn:ip() returned nil - panic! getpeername(): %s %s", conn:socket():getpeername());
end
-- Check if connection is coming from a trusted proxy
if not is_trusted_proxy(conn) then
conn:close();
module:log("warn", "Dropped connection from untrusted proxy: %s", conn:ip());
return;
end
-- Initialize session variables
sessions[conn] = {
handler = nil;
buffer = nil;
};
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment