# HG changeset patch # User leonbogaert@gmail.com # Date 1309987528 0 # Node ID 7dcc5953d79917284c7682063f0ce0df382d4a5c # Parent 145fa870321cd8e3f8c69611571ab782e4b26b54 First version of mod_flash_policy diff -r 145fa870321c -r 7dcc5953d799 mod_flash_policy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_flash_policy Wed Jul 06 21:25:28 2011 +0000 @@ -0,0 +1,46 @@ +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"); +else + string = config.string +end + +module:log("debug", "crossdomain string: "..string); + +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([[ + + + + + ]].."\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 +end + +function module.load() + filters.add_filter_hook(filter_session); +end + +function module.unload() + filters.remove_filter_hook(filter_session); +end \ No newline at end of file