# HG changeset patch # User leonbogaert@gmail.com # Date 1311686349 0 # Node ID 77ca0947647bb5ace7035c7ff5f121f16ecfaee7 # Parent 4219f69be1cff15b60ba17637342ef7399456bbe Copied from bash :s diff -r 4219f69be1cf -r 77ca0947647b mod_flash_policy/mod_flash_policy.lua --- a/mod_flash_policy/mod_flash_policy.lua Tue Jul 26 13:18:38 2011 +0000 +++ b/mod_flash_policy/mod_flash_policy.lua Tue Jul 26 13:19:09 2011 +0000 @@ -1,13 +1,13 @@ local filters = require "util.filters"; local config = {} config.file = module:get_option_string("crossdomain_file", ""); -config.string = module:get_option_string("crossdomain_string", [[]]); local string = '' if not config.file ~= '' then - local f = assert(io.open(config.file)); - string = f:read("*all"); + local f = assert(io.open(config.file)); + string = f:read("*all"); else - string = config.string + string = config.string end module:log("debug", "crossdomain string: "..string); @@ -15,27 +15,27 @@ module:set_global(); function filter_policy(data, session) - -- Since we only want to check the first block of data, remove the filter - filters.remove_filter(session, "bytes/in", filter_policy); - if data == "\0" then - session.send(string.."\0"); - return nil; -- Drop data to prevent it reaching the XMPP parser - else - return data; -- Pass data through, it wasn't a policy request - end - + -- Since we only want to check the first block of data, remove the filter + filters.remove_filter(session, "bytes/in", filter_policy); + if data == "\0" then + session.send(string.."\0"); + return nil; -- Drop data to prevent it reaching the XMPP parser + else + return data; -- Pass data through, it wasn't a policy request + end + end function filter_session(session) - if session.type == "c2s_unauthed" then - filters.add_filter(session, "bytes/in", filter_policy, -1); - end + if session.type == "c2s_unauthed" then + filters.add_filter(session, "bytes/in", filter_policy, -1); + end end function module.load() - filters.add_filter_hook(filter_session); + filters.add_filter_hook(filter_session); end function module.unload() - filters.remove_filter_hook(filter_session); + filters.remove_filter_hook(filter_session); end \ No newline at end of file