-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflashpolicy.js
executable file
·39 lines (31 loc) · 1.11 KB
/
flashpolicy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
var net = require('net');
var args = { /* defaults */
devel: false
};
/* Parse command line options */
var pattern = /^--(.*?)(?:=(.*))?$/;
process.argv.forEach(function(value) {
var match = pattern.exec(value);
if (match) {
args[match[1]] = match[2] ? match[2] : true;
}
});
policy = '<?xml version="1.0"?>\n';
policy += '<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n';
policy += '<cross-domain-policy>\n';
policy += '<allow-access-from domain="*.worlize.com" to-ports="80,443"/>\n';
if (args.devel) {
policy += '<allow-access-from domain="*.worlize.local" to-ports="80,443"/>\n';
policy += '<allow-access-from domain="localhost" to-ports="80,443"/>\n';
}
policy += '</cross-domain-policy>\n';
net.createServer(function(socket){
socket.write(policy);
socket.end();
console.log("Provided response to " + socket.remoteAddress);
}).listen(843);
console.log("Ready to accept connections on port 843.")
if (args.devel) {
console.log("Development mode enabled. Allowing access from *.worlize.local and localhost");
}