Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / policyfile / README.md
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
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.
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
23 var pf = require('policyfile');
24 pf.createServer();
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
36 var pf = require('policyfile');
37 pf.createServer();
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
45 ```js
46 var pf = require('policyfile')
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.createServer();
53 pf.listen(1337, server, function(){
54   console.log(':3 yay')
55 });
56 ```
57
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.
59
60 #### server.add
61 Adds more origins to the policy file you can add as many arguments as you like.
62
63 ```js
64 var pf = require('policyfile');
65 pf.createServer(['google.com:80']);
66 pf.listen();
67 pf.add('blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080'); // now has 3 origins
68 ```
69
70 #### server.add
71 Adds more origins to the policy file you can add as many arguments as you like.
72
73 ```js
74 var pf = require('policyfile');
75 pf.createServer(['blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080']);
76 pf.listen();
77 pf.remove('blog.3rd-Eden.com:8080'); // only contains the :80 version now
78 ```
79
80 #### server.close
81 Shuts down the server
82
83 ```js
84 var pf = require('policyfile');
85 pf.createServer();
86 pf.listen();
87 pf.close(); // OH NVM.
88 ```
89
90 ## API
91 http://3rd-eden.com/FlashPolicyFileServer/
92
93 ## Examples
94 See https://github.com/3rd-Eden/FlashPolicyFileServer/tree/master/examples for examples
95
96 ## Licence
97
98 MIT see LICENSE file in the repository