Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 97 lines (68 sloc) 3.032 kb
70d9bd6 @3rd-Eden read meh
authored
1 ## LOL, WUT?
2 It basically allows you to allow or disallow Flash Player sockets from accessing your site.
3
4 ## Installation
5
6 ```bash
7 npm install policyfile
8 ```
9 ## Usage
10
11 The server is based on the regular and know `net` and `http` server patterns. So it you can just listen
d00e35a @3rd-Eden Updated readme
authored
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.
70d9bd6 @3rd-Eden read meh
authored
14
15 ### createServer
16 Creates a new server instance and accepts 2 optional arguments:
17
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 *:*)
21
22 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
23 var pf = require('policyfile').createServer();
24
70d9bd6 @3rd-Eden read meh
authored
25 pf.listen();
26 ```
27
28 #### server.listen
29 Start listening on the server and it takes 3 optional arguments
30
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.
34
35 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
36 var pf = require('policyfile').createServer();
37
70d9bd6 @3rd-Eden read meh
authored
38 pf.listen(1337, function(){
39 console.log(':3 yay')
40 });
41 ```
42
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).
44
46d8410 @3rd-Eden OMG LIVE EDITING
authored
45 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
46 var pf = require('policyfile').createServer()
46d8410 @3rd-Eden OMG LIVE EDITING
authored
47 , http = require('http');
48
49 server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')});
50 server.listen(80);
51
52 pf.listen(1337, server, function(){
53 console.log(':3 yay')
54 });
55 ```
56
57 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.
58
70d9bd6 @3rd-Eden read meh
authored
59 #### server.add
60 Adds more origins to the policy file you can add as many arguments as you like.
61
62 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
63 var pf = require('policyfile').createServer(['google.com:80']);
64
70d9bd6 @3rd-Eden read meh
authored
65 pf.listen();
66 pf.add('blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080'); // now has 3 origins
67 ```
68
f576b2f @mweibel Fix typos
mweibel authored
69 #### server.remove
70 Removes added origins from the policy file - you can add as many arguments as you like.
70d9bd6 @3rd-Eden read meh
authored
71
72 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
73 var pf = require('policyfile').createServer(['blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080']);
74
70d9bd6 @3rd-Eden read meh
authored
75 pf.listen();
76 pf.remove('blog.3rd-Eden.com:8080'); // only contains the :80 version now
77 ```
78
79 #### server.close
80 Shuts down the server
81
82 ```js
34adec3 @3rd-Eden There where bugs in the examples, found by: https://twitter.com/benjiegi...
authored
83 var pf = require('policyfile').createServer();
84
70d9bd6 @3rd-Eden read meh
authored
85 pf.listen();
86 pf.close(); // OH NVM.
87 ```
88
f55feae @3rd-Eden api
authored
89 ## API
90 http://3rd-eden.com/FlashPolicyFileServer/
91
46d8410 @3rd-Eden OMG LIVE EDITING
authored
92 ## Examples
93 See https://github.com/3rd-Eden/FlashPolicyFileServer/tree/master/examples for examples
94
70d9bd6 @3rd-Eden read meh
authored
95 ## Licence
96
97 MIT see LICENSE file in the repository
Something went wrong with that request. Please try again.