2 It basically allows you to allow or disallow Flash Player sockets from accessing your site.
11 The server is based on the regular and know `net` and `http` server patterns. So it you can just listen
12 for all the events that a `net` based server emits etc. But there is one extra event, the `connect_failed`
13 event. This event is triggered when we are unable to listen on the supplied port number.
16 Creates a new server instance and accepts 2 optional arguments:
18 - `options` **Object** Options to configure the server instance
19 - `log` **Boolean** Enable logging to STDOUT and STDERR (defaults to true)
20 - `origins` **Array** An Array of origins that are allowed by the server (defaults to *:*)
23 var pf = require('policyfile');
29 Start listening on the server and it takes 3 optional arguments
31 - `port` **Number** On which port number should we listen? (defaults to 843, which is the first port number the FlashPlayer checks)
32 - `server` **Server** A http server, if we are unable to accept requests or run the server we can also answer the policy requests inline over the supplied HTTP server.
33 - `callback` **Function** A callback function that is called when listening to the server was successful.
36 var pf = require('policyfile');
38 pf.listen(1337, function(){
43 Changing port numbers can be handy if you do not want to run your server as root and have port 843 forward to a non root port number (aka a number above 1024).
46 var pf = require('policyfile')
47 , http = require('http');
49 server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')});
53 pf.listen(1337, server, function(){
58 Support for serving inline requests over a existing HTTP connection as the FlashPlayer will first check port 843, but if it's unable to get a response there it will send a policy file request over port 80, which is usually your http server.
61 Adds more origins to the policy file you can add as many arguments as you like.
64 var pf = require('policyfile');
65 pf.createServer(['google.com:80']);
67 pf.add('blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080'); // now has 3 origins
71 Adds more origins to the policy file you can add as many arguments as you like.
74 var pf = require('policyfile');
75 pf.createServer(['blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080']);
77 pf.remove('blog.3rd-Eden.com:8080'); // only contains the :80 version now
84 var pf = require('policyfile');
87 pf.close(); // OH NVM.
91 http://3rd-eden.com/FlashPolicyFileServer/
94 See https://github.com/3rd-Eden/FlashPolicyFileServer/tree/master/examples for examples
98 MIT see LICENSE file in the repository