Last active
April 2, 2018 20:11
-
-
Save ppmathis/aade39527de118e87ba99098dacb7677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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