annotate mod_flash_policy/mod_flash_policy.lua @ 383:4099f0837936

mod_muc_log_http: Added assertion to ensure proper failure on empty responses.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 25 Jul 2011 02:21:40 +0500
parents eebc19c224fb
children 4219f69be1cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
379
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
1 local filters = require "util.filters";
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
2 local config = {}
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
3 config.file = module:get_option_string("crossdomain_file", "");
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
4 config.string = module:get_option_string("crossdomain_string", [[<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy><site-control permitted-cross-domain-policies="master-only"/><allow-access-from domain="*" /></cross-domain-policy>]]);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
5 local string = ''
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
6 if not config.file ~= '' then
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
7 local f = assert(io.open(config.file));
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
8 string = f:read("*all");
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
9 else
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
10 string = config.string
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
11 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
12
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
13 module:log("debug", "crossdomain string: "..string);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
14
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
15 module:set_global();
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
16
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
17 function filter_policy(data, session)
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
18 -- Since we only want to check the first block of data, remove the filter
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
19 filters.remove_filter(session, "bytes/in", filter_policy);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
20 if data == "<policy-file-request/>\0" then
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
21 session.send([[<?xml version="1.0"?>
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
22 <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
23 <cross-domain-policy>
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
24 <site-control permitted-cross-domain-policies="master-only"/>
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
25 <allow-access-from domain="livechat.concepts.tim-online.nl" to-ports="5222" />
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
26 </cross-domain-policy>]].."\0");
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
27 return nil; -- Drop data to prevent it reaching the XMPP parser
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
28 else
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
29 return data; -- Pass data through, it wasn't a policy request
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
30 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
31
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
32 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
33
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
34 function filter_session(session)
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
35 if session.type == "c2s_unauthed" then
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
36 filters.add_filter(session, "bytes/in", filter_policy, -1);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
37 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
38 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
39
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
40 function module.load()
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
41 filters.add_filter_hook(filter_session);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
42 end
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
43
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
44 function module.unload()
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
45 filters.remove_filter_hook(filter_session);
eebc19c224fb Moved the file to a directory
leonbogaert
parents:
diff changeset
46 end