diff options
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile')
13 files changed, 0 insertions, 1182 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/.npmignore b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/.npmignore deleted file mode 100644 index b512c09d..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/LICENSE b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/LICENSE deleted file mode 100644 index bdb8f617..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011 Arnout Kazemier,3rd-Eden - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/Makefile b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/Makefile deleted file mode 100644 index 1362d66a..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -doc: - dox --title "FlashPolicyFileServer" lib/* > doc/index.html - -test: - expresso -I lib $(TESTFLAGS) tests/*.test.js - -.PHONY: test doc
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/README.md b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/README.md deleted file mode 100644 index 527921ee..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/README.md +++ /dev/null @@ -1,98 +0,0 @@ -## LOL, WUT? -It basically allows you to allow or disallow Flash Player sockets from accessing your site. - -## Installation - -```bash -npm install policyfile -``` -## Usage - -The server is based on the regular and know `net` and `http` server patterns. So it you can just listen -for all the events that a `net` based server emits etc. But there is one extra event, the `connect_failed` -event. This event is triggered when we are unable to listen on the supplied port number. - -### createServer -Creates a new server instance and accepts 2 optional arguments: - -- `options` **Object** Options to configure the server instance - - `log` **Boolean** Enable logging to STDOUT and STDERR (defaults to true) -- `origins` **Array** An Array of origins that are allowed by the server (defaults to *:*) - -```js -var pf = require('policyfile'); -pf.createServer(); -pf.listen(); -``` - -#### server.listen -Start listening on the server and it takes 3 optional arguments - -- `port` **Number** On which port number should we listen? (defaults to 843, which is the first port number the FlashPlayer checks) -- `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. -- `callback` **Function** A callback function that is called when listening to the server was successful. - -```js -var pf = require('policyfile'); -pf.createServer(); -pf.listen(1337, function(){ - console.log(':3 yay') -}); -``` - -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). - -```js -var pf = require('policyfile') - , http = require('http'); - -server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')}); -server.listen(80); - -pf.createServer(); -pf.listen(1337, server, function(){ - console.log(':3 yay') -}); -``` - -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. - -#### server.add -Adds more origins to the policy file you can add as many arguments as you like. - -```js -var pf = require('policyfile'); -pf.createServer(['google.com:80']); -pf.listen(); -pf.add('blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080'); // now has 3 origins -``` - -#### server.add -Adds more origins to the policy file you can add as many arguments as you like. - -```js -var pf = require('policyfile'); -pf.createServer(['blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080']); -pf.listen(); -pf.remove('blog.3rd-Eden.com:8080'); // only contains the :80 version now -``` - -#### server.close -Shuts down the server - -```js -var pf = require('policyfile'); -pf.createServer(); -pf.listen(); -pf.close(); // OH NVM. -``` - -## API -http://3rd-eden.com/FlashPolicyFileServer/ - -## Examples -See https://github.com/3rd-Eden/FlashPolicyFileServer/tree/master/examples for examples - -## Licence - -MIT see LICENSE file in the repository
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/doc/index.html b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/doc/index.html deleted file mode 100644 index 743fcdaf..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/doc/index.html +++ /dev/null @@ -1,375 +0,0 @@ -<html> - <head> - <title>FlashPolicyFileServer</title> - <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> - <style>body { - margin: 0; - padding: 0; - font: 14px/1.5 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; - color: #252519; -} -a { - color: #252519; -} -a:hover { - text-decoration: underline; - color: #19469D; -} -p { - margin: 12px 0; -} -h1, h2, h3 { - margin: 0; - padding: 0; -} -table#source { - width: 100%; - border-collapse: collapse; -} -table#source td:first-child { - padding: 30px 40px 30px 40px; - vertical-align: top; -} -table#source td:first-child, -table#source td:first-child pre { - width: 450px; -} -table#source td:last-child { - padding: 30px 0 30px 40px; - border-left: 1px solid #E5E5EE; - background: #F5F5FF; -} -table#source tr { - border-bottom: 1px solid #E5E5EE; -} -table#source tr.filename { - padding-top: 40px; - border-top: 1px solid #E5E5EE; -} -table#source tr.filename td:first-child { - text-transform: capitalize; -} -table#source tr.filename td:last-child { - font-size: 12px; -} -table#source tr.filename h2 { - margin: 0; - padding: 0; - cursor: pointer; -} -table#source tr.code h1, -table#source tr.code h2, -table#source tr.code h3 { - margin-top: 30px; - font-family: "Lucida Grande", "Helvetica Nueue", Arial, sans-serif; - font-size: 18px; -} -table#source tr.code h2 { - font-size: 16px; -} -table#source tr.code h3 { - font-size: 14px; -} -table#source tr.code ul { - margin: 15px 0 15px 35px; - padding: 0; -} -table#source tr.code ul li { - margin: 0; - padding: 1px 0; -} -table#source tr.code ul li p { - margin: 0; - padding: 0; -} -table#source tr.code td:first-child pre { - padding: 20px; -} -#ribbon { - position: fixed; - top: 0; - right: 0; -} -code .string { color: #219161; } -code .regexp { color: #219161; } -code .keyword { color: #954121; } -code .number { color: #19469D; } -code .comment { color: #bbb; } -code .this { color: #19469D; }</style> - <script> - $(function(){ - $('tr.code').hide(); - $('tr.filename').toggle(function(){ - $(this).nextUntil('.filename').fadeIn(); - }, function(){ - $(this).nextUntil('.filename').fadeOut(); - }); - }); - </script> - </head> - <body> -<table id="source"><tbody><tr><td><h1>FlashPolicyFileServer</h1></td><td></td></tr><tr class="filename"><td><h2 id="lib/server.js"><a href="#">server</a></h2></td><td>lib/server.js</td></tr><tr class="code"> -<td class="docs"> -<p>Module dependencies and cached references. - </p> -</td> -<td class="code"> -<pre><code><span class="keyword">var</span> <span class="variable">slice</span> = <span class="class">Array</span>.<span class="variable">prototype</span>.<span class="variable">slice</span> - , <span class="variable">net</span> = <span class="variable">require</span>(<span class="string">'net'</span>);</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>The server that does the Policy File severing</p> - -<h2>Options</h2> - -<ul><li><code>log</code> false or a function that can output log information, defaults to console.log?</li></ul> - -<h2></h2> - -<ul><li><p><strong>param</strong>: <em>Object</em> options Options to customize the servers functionality.</p></li><li><p><strong>param</strong>: <em>Array</em> origins The origins that are allowed on this server, defaults to <code>*:*</code>.</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="keyword">function</span> <span class="class">Server</span>(<span class="variable">options</span>, <span class="variable">origins</span>){ - <span class="keyword">var</span> <span class="variable">me</span> = <span class="this">this</span>; - - <span class="this">this</span>.<span class="variable">origins</span> = <span class="variable">origins</span> || [<span class="string">'*:*'</span>]; - <span class="this">this</span>.<span class="variable">port</span> = <span class="number integer">843</span>; - <span class="this">this</span>.<span class="variable">log</span> = <span class="variable">console</span>.<span class="variable">log</span>; - - <span class="comment">// merge `this` with the options</span> - <span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">options</span>).<span class="variable">forEach</span>(<span class="keyword">function</span>(<span class="variable">key</span>){ - <span class="variable">me</span>[<span class="variable">key</span>] &<span class="variable">amp</span>;&<span class="variable">amp</span>; (<span class="variable">me</span>[<span class="variable">key</span>] = <span class="variable">options</span>[<span class="variable">key</span>]) - }); - - <span class="comment">// create the net server</span> - <span class="this">this</span>.<span class="variable">socket</span> = <span class="variable">net</span>.<span class="variable">createServer</span>(<span class="keyword">function</span> <span class="variable">createServer</span>(<span class="variable">socket</span>){ - <span class="variable">socket</span>.<span class="variable">on</span>(<span class="string">'error'</span>, <span class="keyword">function</span> <span class="variable">socketError</span>(){ <span class="variable">me</span>.<span class="variable">responder</span>.<span class="variable">call</span>(<span class="variable">me</span>, <span class="variable">socket</span>) }); - <span class="variable">me</span>.<span class="variable">responder</span>.<span class="variable">call</span>(<span class="variable">me</span>, <span class="variable">socket</span>); - }); - - <span class="comment">// Listen for errors as the port might be blocked because we do not have root priv.</span> - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">on</span>(<span class="string">'error'</span>, <span class="keyword">function</span> <span class="variable">serverError</span>(<span class="variable">err</span>){ - <span class="comment">// Special and common case error handling</span> - <span class="keyword">if</span> (<span class="variable">err</span>.<span class="variable">errno</span> == <span class="number integer">13</span>){ - <span class="variable">me</span>.<span class="variable">log</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">log</span>( - <span class="string">'Unable to listen to port `'</span> + <span class="variable">me</span>.<span class="variable">port</span> + <span class="string">'` as your Node.js instance does not have root privileges. '</span> + - ( - <span class="variable">me</span>.<span class="variable">server</span> - ? <span class="string">'The Flash Policy file will now be served inline over the supplied HTTP server, Flash Policy files request will suffer.'</span> - : <span class="string">'No fallback server supplied.'</span> - ) - ); - - <span class="variable">me</span>.<span class="variable">socket</span>.<span class="variable">removeAllListeners</span>(); - <span class="keyword">delete</span> <span class="variable">me</span>.<span class="variable">socket</span>; - - <span class="variable">me</span>.<span class="variable">emit</span>(<span class="string">'connect_failed'</span>, <span class="variable">err</span>); - } <span class="keyword">else</span> { - <span class="variable">me</span>.<span class="variable">log</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">log</span>(<span class="string">'FlashPolicyFileServer received a error event:\n'</span> + (<span class="variable">err</span>.<span class="variable">message</span> ? <span class="variable">err</span>.<span class="variable">message</span> : <span class="variable">err</span>)); - } - }); - - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">on</span>(<span class="string">'timeout'</span>, <span class="keyword">function</span> <span class="variable">serverTimeout</span>(){}); - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">on</span>(<span class="string">'close'</span>, <span class="keyword">function</span> <span class="variable">serverClosed</span>(<span class="variable">err</span>){ - <span class="variable">err</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">log</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">log</span>(<span class="string">'Server closing due to an error: \n'</span> + (<span class="variable">err</span>.<span class="variable">message</span> ? <span class="variable">err</span>.<span class="variable">message</span> : <span class="variable">err</span>)); - - <span class="keyword">if</span> (<span class="variable">me</span>.<span class="variable">server</span>){ - <span class="comment">// not online anymore</span> - <span class="keyword">delete</span> <span class="variable">me</span>.<span class="variable">server</span>.<span class="variable">online</span>; - - <span class="comment">// Remove the inline policy listener if we close down</span> - <span class="comment">// but only when the server was `online` (see listen prototype)</span> - <span class="keyword">if</span>( <span class="variable">me</span>.<span class="variable">server</span>[<span class="string">'@'</span>] &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">server</span>.<span class="variable">online</span>){ - <span class="variable">me</span>.<span class="variable">server</span>.<span class="variable">removeListener</span>(<span class="string">'connection'</span>, <span class="variable">me</span>.<span class="variable">server</span>[<span class="string">'@'</span>]); - } - } - <span class="variable">me</span>.<span class="variable">log</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">me</span>.<span class="variable">log</span>(<span class="string">'Shutting down FlashPolicyFileServer'</span>); - }); - - <span class="comment">// Compile the initial `buffer`</span> - <span class="this">this</span>.<span class="variable">compile</span>(); -}</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Start listening for requests</p> - -<h2></h2> - -<ul><li><p><strong>param</strong>: <em>Number</em> port The port number it should be listening to.</p></li><li><p><strong>param</strong>: <em>Server</em> server A HTTP server instance, this will be used to listen for inline requests</p></li><li><p><strong>param</strong>: <em>Function</em> cb The callback needs to be called once server is ready</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">listen</span> = <span class="keyword">function</span> <span class="variable">listen</span>(<span class="variable">port</span>, <span class="variable">server</span>, <span class="variable">cb</span>){ - <span class="keyword">var</span> <span class="variable">me</span> = <span class="this">this</span> - , <span class="variable">args</span> = <span class="variable">slice</span>.<span class="variable">call</span>(<span class="variable">arguments</span>, <span class="number integer">0</span>) - , <span class="variable">callback</span>; - - <span class="comment">// assign the correct vars, for flexible arguments</span> - <span class="variable">args</span>.<span class="variable">forEach</span>(<span class="keyword">function</span> <span class="variable">args</span>(<span class="variable">arg</span>){ - <span class="keyword">var</span> <span class="variable">type</span> = <span class="keyword">typeof</span> <span class="variable">arg</span>; - - <span class="keyword">if</span> (<span class="variable">type</span> === <span class="string">'number'</span>) <span class="variable">me</span>.<span class="variable">port</span> = <span class="variable">arg</span>; - <span class="keyword">if</span> (<span class="variable">type</span> === <span class="string">'function'</span>) <span class="variable">callback</span> = <span class="variable">arg</span>; - <span class="keyword">if</span> (<span class="variable">type</span> === <span class="string">'object'</span>) <span class="variable">me</span>.<span class="variable">server</span> = <span class="variable">arg</span>; - }); - - <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">server</span>){ - - <span class="comment">// no one in their right mind would ever create a `@` prototype, so Im just gonna store</span> - <span class="comment">// my function on the server, so I can remove it later again once the server(s) closes</span> - <span class="this">this</span>.<span class="variable">server</span>[<span class="string">'@'</span>] = <span class="keyword">function</span> <span class="variable">connection</span>(<span class="variable">socket</span>){ - <span class="variable">socket</span>.<span class="variable">once</span>(<span class="string">'data'</span>, <span class="keyword">function</span> <span class="variable">requestData</span>(<span class="variable">data</span>){ - <span class="comment">// if it's a Flash policy request, and we can write to the </span> - <span class="keyword">if</span> ( - <span class="variable">data</span> - &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">data</span>[<span class="number integer">0</span>] === <span class="number integer">60</span> - &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">data</span>.<span class="variable">toString</span>() === <span class="string">'<policy-file-request/>\0'</span> - &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">socket</span> - &<span class="variable">amp</span>;&<span class="variable">amp</span>; (<span class="variable">socket</span>.<span class="variable">readyState</span> === <span class="string">'open'</span> || <span class="variable">socket</span>.<span class="variable">readyState</span> === <span class="string">'writeOnly'</span>) - ){ - <span class="comment">// send the buffer</span> - <span class="variable">socket</span>.<span class="variable">end</span>(<span class="variable">me</span>.<span class="variable">buffer</span>); - } - }); - }; - <span class="comment">// attach it</span> - <span class="this">this</span>.<span class="variable">server</span>.<span class="variable">on</span>(<span class="string">'connection'</span>, <span class="this">this</span>.<span class="variable">server</span>[<span class="string">'@'</span>]); - } - - <span class="comment">// We add a callback method, so we can set a flag for when the server is `enabled` or `online`.</span> - <span class="comment">// this flag is needed because if a error occurs and the we cannot boot up the server the</span> - <span class="comment">// fallback functionality should not be removed during the `close` event</span> - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">listen</span>(<span class="this">this</span>.<span class="variable">port</span>, <span class="keyword">function</span> <span class="variable">serverListening</span>(){ - <span class="variable">me</span>.<span class="variable">socket</span>.<span class="variable">online</span> = <span class="variable">true</span>; - - <span class="keyword">if</span> (<span class="variable">callback</span>) <span class="variable">callback</span>(), <span class="variable">callback</span> = <span class="variable">undefined</span>; - - }); - - <span class="keyword">return</span> <span class="this">this</span>; -};</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Adds a new origin to the Flash Policy File.</p> - -<h2></h2> - -<ul><li><p><strong>param</strong>: <em>Arguments</em> The origins that need to be added.</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">add</span> = <span class="keyword">function</span> <span class="variable">add</span>(){ - <span class="keyword">var</span> <span class="variable">args</span> = <span class="variable">slice</span>.<span class="variable">call</span>(<span class="variable">arguments</span>, <span class="number integer">0</span>) - , <span class="variable">i</span> = <span class="variable">args</span>.<span class="variable">length</span>; - - <span class="comment">// flag duplicates</span> - <span class="keyword">while</span> (<span class="variable">i</span>--){ - <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">origins</span>.<span class="variable">indexOf</span>(<span class="variable">args</span>[<span class="variable">i</span>]) &<span class="variable">gt</span>;= <span class="number integer">0</span>){ - <span class="variable">args</span>[<span class="variable">i</span>] = <span class="keyword">null</span>; - } - } - - <span class="comment">// Add all the arguments to the array</span> - <span class="comment">// but first we want to remove all `falsy` values from the args</span> - <span class="class">Array</span>.<span class="variable">prototype</span>.<span class="variable">push</span>.<span class="variable">apply</span>( - <span class="this">this</span>.<span class="variable">origins</span> - , <span class="variable">args</span>.<span class="variable">filter</span>(<span class="keyword">function</span>(<span class="variable">value</span>){ <span class="keyword">return</span> !!<span class="variable">value</span> }) - ); - - <span class="this">this</span>.<span class="variable">compile</span>(); - <span class="keyword">return</span> <span class="this">this</span>; -};</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Removes a origin from the Flash Policy File.</p> - -<h2></h2> - -<ul><li><p><strong>param</strong>: <em>String</em> origin The origin that needs to be removed from the server</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">remove</span> = <span class="keyword">function</span> <span class="variable">remove</span>(<span class="variable">origin</span>){ - <span class="keyword">var</span> <span class="variable">position</span> = <span class="this">this</span>.<span class="variable">origins</span>.<span class="variable">indexOf</span>(<span class="variable">origin</span>); - - <span class="comment">// only remove and recompile if we have a match</span> - <span class="keyword">if</span> (<span class="variable">position</span> &<span class="variable">gt</span>; <span class="number integer">0</span>){ - <span class="this">this</span>.<span class="variable">origins</span>.<span class="variable">splice</span>(<span class="variable">position</span>,<span class="number integer">1</span>); - <span class="this">this</span>.<span class="variable">compile</span>(); - } - - <span class="keyword">return</span> <span class="this">this</span>; -};</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Closes and cleans up the server</p> - -<ul><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">close</span> = <span class="keyword">function</span> <span class="variable">close</span>(){ - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">removeAllListeners</span>(); - <span class="this">this</span>.<span class="variable">socket</span>.<span class="variable">close</span>(); - - <span class="keyword">return</span> <span class="this">this</span>; -};</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Proxy the event listener requests to the created Net server - </p> -</td> -<td class="code"> -<pre><code><span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">process</span>.<span class="class">EventEmitter</span>.<span class="variable">prototype</span>).<span class="variable">forEach</span>(<span class="keyword">function</span> <span class="variable">proxy</span>(<span class="variable">key</span>){ - <span class="class">Server</span>.<span class="variable">prototype</span>[<span class="variable">key</span>] = <span class="class">Server</span>.<span class="variable">prototype</span>[<span class="variable">key</span>] || <span class="keyword">function</span> (){ - <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">socket</span>) <span class="this">this</span>.<span class="variable">socket</span>[<span class="variable">key</span>].<span class="variable">apply</span>(<span class="this">this</span>.<span class="variable">socket</span>, <span class="variable">arguments</span>); - <span class="keyword">return</span> <span class="this">this</span>; - }; -});</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Creates a new server instance.</p> - -<h2></h2> - -<ul><li><p><strong>param</strong>: <em>Object</em> options A options object to override the default config</p></li><li><p><strong>param</strong>: <em>Array</em> origins The origins that should be allowed by the server</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul> -</td> -<td class="code"> -<pre><code><span class="variable">exports</span>.<span class="variable">createServer</span> = <span class="keyword">function</span> <span class="variable">createServer</span>(<span class="variable">options</span>, <span class="variable">origins</span>){ - <span class="variable">origins</span> = <span class="class">Array</span>.<span class="variable">isArray</span>(<span class="variable">origins</span>) ? <span class="variable">origins</span> : (<span class="class">Array</span>.<span class="variable">isArray</span>(<span class="variable">options</span>) ? <span class="variable">options</span> : <span class="variable">false</span>); - <span class="variable">options</span> = !<span class="class">Array</span>.<span class="variable">isArray</span>(<span class="variable">options</span>) &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">options</span> ? <span class="variable">options</span> : {}; - - <span class="keyword">return</span> <span class="keyword">new</span> <span class="class">Server</span>(<span class="variable">options</span>, <span class="variable">origins</span>); -};</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Provide a hook to the original server, so it can be extended if needed. - </p> -</td> -<td class="code"> -<pre><code><span class="variable">exports</span>.<span class="class">Server</span> = <span class="class">Server</span>;</code></pre> -</td> -</tr> -<tr class="code"> -<td class="docs"> -<p>Module version - </p> -</td> -<td class="code"> -<pre><code><span class="variable">exports</span>.<span class="variable">version</span> = <span class="string">'0.0.2'</span>; -</code></pre> -</td> -</tr> </body> -</html></tbody></table>
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.fallback.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.fallback.js deleted file mode 100644 index b439449a..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.fallback.js +++ /dev/null @@ -1,8 +0,0 @@ -var http = require('http') - , fspfs = require('../'); - -var server = http.createServer(function(q,r){ r.writeHead(200); r.end(':3') }) - , flash = fspfs.createServer(); - -server.listen(8080); -flash.listen(8081,server);
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.js deleted file mode 100644 index 5e2290f7..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/examples/basic.js +++ /dev/null @@ -1,5 +0,0 @@ -var http = require('http') - , fspfs = require('../'); - -var flash = fspfs.createServer(); -flash.listen();
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/index.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/index.js deleted file mode 100644 index 60cf2989..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/server.js');
\ No newline at end of file diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/lib/server.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/lib/server.js deleted file mode 100644 index a525772b..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/lib/server.js +++ /dev/null @@ -1,289 +0,0 @@ -/** - * Module dependencies and cached references. - */ - -var slice = Array.prototype.slice - , net = require('net'); - -/** - * The server that does the Policy File severing - * - * Options: - * - `log` false or a function that can output log information, defaults to console.log? - * - * @param {Object} options Options to customize the servers functionality. - * @param {Array} origins The origins that are allowed on this server, defaults to `*:*`. - * @api public - */ - -function Server (options, origins) { - var me = this; - - this.origins = origins || ['*:*']; - this.port = 843; - this.log = console.log; - - // merge `this` with the options - Object.keys(options).forEach(function (key) { - me[key] && (me[key] = options[key]) - }); - - // create the net server - this.socket = net.createServer(function createServer (socket) { - socket.on('error', function socketError () { - me.responder.call(me, socket); - }); - - me.responder.call(me, socket); - }); - - // Listen for errors as the port might be blocked because we do not have root priv. - this.socket.on('error', function serverError (err) { - // Special and common case error handling - if (err.errno == 13) { - me.log && me.log( - 'Unable to listen to port `' + me.port + '` as your Node.js instance does not have root privileges. ' + - ( - me.server - ? 'The Flash Policy File requests will only be served inline over the supplied HTTP server. Inline serving is slower than a dedicated server instance.' - : 'No fallback server supplied, we will be unable to answer Flash Policy File requests.' - ) - ); - - me.emit('connect_failed', err); - me.socket.removeAllListeners(); - delete me.socket; - } else { - me.log && me.log('FlashPolicyFileServer received an error event:\n' + (err.message ? err.message : err)); - } - }); - - this.socket.on('timeout', function serverTimeout () {}); - this.socket.on('close', function serverClosed (err) { - err && me.log && me.log('Server closing due to an error: \n' + (err.message ? err.message : err)); - - if (me.server) { - // Remove the inline policy listener if we close down - // but only when the server was `online` (see listen prototype) - if (me.server['@'] && me.server.online) { - me.server.removeListener('connection', me.server['@']); - } - - // not online anymore - delete me.server.online; - } - }); - - // Compile the initial `buffer` - this.compile(); -} - -/** - * Start listening for requests - * - * @param {Number} port The port number it should be listening to. - * @param {Server} server A HTTP server instance, this will be used to listen for inline requests - * @param {Function} cb The callback needs to be called once server is ready - * @api public - */ - -Server.prototype.listen = function listen (port, server, cb){ - var me = this - , args = slice.call(arguments, 0) - , callback; - - // assign the correct vars, for flexible arguments - args.forEach(function args (arg){ - var type = typeof arg; - - if (type === 'number') me.port = arg; - if (type === 'function') callback = arg; - if (type === 'object') me.server = arg; - }); - - if (this.server) { - - // no one in their right mind would ever create a `@` prototype, so Im just gonna store - // my function on the server, so I can remove it later again once the server(s) closes - this.server['@'] = function connection (socket) { - socket.once('data', function requestData (data) { - // if it's a Flash policy request, and we can write to the - if ( - data - && data[0] === 60 - && data.toString() === '<policy-file-request/>\0' - && socket - && (socket.readyState === 'open' || socket.readyState === 'writeOnly') - ){ - // send the buffer - try { - socket.end(me.buffer); - } catch (e) {} - } - }); - }; - - // attach it - this.server.on('connection', this.server['@']); - } - - // We add a callback method, so we can set a flag for when the server is `enabled` or `online`. - // this flag is needed because if a error occurs and the we cannot boot up the server the - // fallback functionality should not be removed during the `close` event - this.port >= 0 && this.socket.listen(this.port, function serverListening () { - me.socket.online = true; - if (callback) { - callback.call(me); - callback = undefined; - } - }); - - return this; -}; - -/** - * Responds to socket connects and writes the compile policy file. - * - * @param {net.Socket} socket The socket that needs to receive the message - * @api private - */ - -Server.prototype.responder = function responder (socket){ - if (socket && socket.readyState == 'open' && socket.end) { - try { - socket.end(this.buffer); - } catch (e) {} - } -}; - -/** - * Compiles the supplied origins to a Flash Policy File format and stores it in a Node.js Buffer - * this way it can be send over the wire without any performance loss. - * - * @api private - */ - -Server.prototype.compile = function compile (){ - var xml = [ - '<?xml version="1.0"?>' - , '<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">' - , '<cross-domain-policy>' - ]; - - // add the allow access element - this.origins.forEach(function origin (origin){ - var parts = origin.split(':'); - xml.push('<allow-access-from domain="' + parts[0] + '" to-ports="'+ parts[1] +'"/>'); - }); - - xml.push('</cross-domain-policy>'); - - // store the result in a buffer so we don't have to re-generate it all the time - this.buffer = new Buffer(xml.join(''), 'utf8'); - - return this; -}; - -/** - * Adds a new origin to the Flash Policy File. - * - * @param {Arguments} The origins that need to be added. - * @api public - */ - -Server.prototype.add = function add(){ - var args = slice.call(arguments, 0) - , i = args.length; - - // flag duplicates - while (i--) { - if (this.origins.indexOf(args[i]) >= 0){ - args[i] = null; - } - } - - // Add all the arguments to the array - // but first we want to remove all `falsy` values from the args - Array.prototype.push.apply( - this.origins - , args.filter(function filter (value) { - return !!value; - }) - ); - - this.compile(); - return this; -}; - -/** - * Removes a origin from the Flash Policy File. - * - * @param {String} origin The origin that needs to be removed from the server - * @api public - */ - -Server.prototype.remove = function remove (origin){ - var position = this.origins.indexOf(origin); - - // only remove and recompile if we have a match - if (position > 0) { - this.origins.splice(position,1); - this.compile(); - } - - return this; -}; - -/** - * Closes and cleans up the server - * - * @api public - */ - -Server.prototype.close = function close () { - this.socket.removeAllListeners(); - this.socket.close(); - - return this; -}; - -/** - * Proxy the event listener requests to the created Net server - */ - -Object.keys(process.EventEmitter.prototype).forEach(function proxy (key){ - Server.prototype[key] = Server.prototype[key] || function () { - if (this.socket) { - this.socket[key].apply(this.socket, arguments); - } - - return this; - }; -}); - -/** - * Creates a new server instance. - * - * @param {Object} options A options object to override the default config - * @param {Array} origins The origins that should be allowed by the server - * @api public - */ - -exports.createServer = function createServer(options, origins){ - origins = Array.isArray(origins) ? origins : (Array.isArray(options) ? options : false); - options = !Array.isArray(options) && options ? options : {}; - - return new Server(options, origins); -}; - -/** - * Provide a hook to the original server, so it can be extended if needed. - */ - -exports.Server = Server; - -/** - * Module version - */ - -exports.version = '0.0.4'; diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/package.json b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/package.json deleted file mode 100644 index fb91440b..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/package.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "policyfile@0.0.4", - "scope": null, - "escapedName": "policyfile", - "name": "policyfile", - "rawSpec": "0.0.4", - "spec": "0.0.4", - "type": "version" - }, - "C:\\apache-tomcat-8.5.11\\webapps\\vnfmarket\\node_modules\\socket.io" - ] - ], - "_defaultsLoaded": true, - "_engineSupported": true, - "_from": "policyfile@0.0.4", - "_id": "policyfile@0.0.4", - "_inCache": true, - "_location": "/policyfile", - "_nodeVersion": "v0.4.8", - "_npmVersion": "1.0.12", - "_phantomChildren": {}, - "_requested": { - "raw": "policyfile@0.0.4", - "scope": null, - "escapedName": "policyfile", - "name": "policyfile", - "rawSpec": "0.0.4", - "spec": "0.0.4", - "type": "version" - }, - "_requiredBy": [ - "/socket.io" - ], - "_resolved": "https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz", - "_shasum": "d6b82ead98ae79ebe228e2daf5903311ec982e4d", - "_shrinkwrap": null, - "_spec": "policyfile@0.0.4", - "_where": "C:\\apache-tomcat-8.5.11\\webapps\\vnfmarket\\node_modules\\socket.io", - "author": { - "name": "Arnout Kazemier" - }, - "bugs": { - "url": "https://github.com/3rd-Eden/FlashPolicyFileServer/issues" - }, - "dependencies": {}, - "description": "Flash Socket Policy File Server. A server to respond to Flash Socket Policy requests, both inline and through a dedicated server instance.", - "devDependencies": {}, - "directories": { - "lib": "./lib" - }, - "dist": { - "shasum": "d6b82ead98ae79ebe228e2daf5903311ec982e4d", - "tarball": "https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz" - }, - "engines": { - "node": "*" - }, - "homepage": "https://github.com/3rd-Eden/FlashPolicyFileServer#readme", - "keywords": [ - "flash", - "socket", - "policy", - "file", - "server", - "Flash Socket Policy File Server", - "cross domain" - ], - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/3rd-Eden/FlashPolicyFileServer/blob/master/LICENSE" - } - ], - "main": "index", - "maintainers": [ - { - "name": "Arnout Kazemier", - "email": "info@3rd-Eden.com", - "url": "http://blog.3rd-Eden.com" - } - ], - "name": "policyfile", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repositories": [ - { - "type": "git", - "url": "git+https://github.com/3rd-Eden/FlashPolicyFileServer.git" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/3rd-Eden/FlashPolicyFileServer.git" - }, - "scripts": {}, - "version": "0.0.4" -} diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.crt b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.crt deleted file mode 100644 index 5883cd44..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.crt +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDXTCCAkWgAwIBAgIJAMUSOvlaeyQHMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTAxMTE2MDkzMjQ5WhcNMTMxMTE1MDkzMjQ5WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAz+LXZOjcQCJq3+ZKUFabj71oo/ex/XsBcFqtBThjjTw9CVEVwfPQQp4X -wtPiB204vnYXwQ1/R2NdTQqCZu47l79LssL/u2a5Y9+0NEU3nQA5qdt+1FAE0c5o -exPimXOrR3GWfKz7PmZ2O0117IeCUUXPG5U8umhDe/4mDF4ZNJiKc404WthquTqg -S7rLQZHhZ6D0EnGnOkzlmxJMYPNHSOY1/6ivdNUUcC87awNEA3lgfhy25IyBK3QJ -c+aYKNTbt70Lery3bu2wWLFGtmNiGlQTS4JsxImRsECTI727ObS7/FWAQsqW+COL -0Sa5BuMFrFIpjPrEe0ih7vRRbdmXRwIDAQABo1AwTjAdBgNVHQ4EFgQUDnV4d6mD -tOnluLoCjkUHTX/n4agwHwYDVR0jBBgwFoAUDnV4d6mDtOnluLoCjkUHTX/n4agw -DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAFwV4MQfTo+qMv9JMiyno -IEiqfOz4RgtmBqRnXUffcjS2dhc7/z+FPZnM79Kej8eLHoVfxCyWRHFlzm93vEdv -wxOCrD13EDOi08OOZfxWyIlCa6Bg8cMAKqQzd2OvQOWqlRWBTThBJIhWflU33izX -Qn5GdmYqhfpc+9ZHHGhvXNydtRQkdxVK2dZNzLBvBlLlRmtoClU7xm3A+/5dddeP -AQHEPtyFlUw49VYtZ3ru6KqPms7MKvcRhYLsy9rwSfuuniMlx4d0bDR7TOkw0QQS -A0N8MGQRQpzl4mw4jLzyM5d5QtuGBh2P6hPGa0YQxtI3RPT/p6ENzzBiAKXiSfzo -xw== ------END CERTIFICATE----- diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.private.key b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.private.key deleted file mode 100644 index f31ff3d9..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/ssl/ssl.private.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAz+LXZOjcQCJq3+ZKUFabj71oo/ex/XsBcFqtBThjjTw9CVEV -wfPQQp4XwtPiB204vnYXwQ1/R2NdTQqCZu47l79LssL/u2a5Y9+0NEU3nQA5qdt+ -1FAE0c5oexPimXOrR3GWfKz7PmZ2O0117IeCUUXPG5U8umhDe/4mDF4ZNJiKc404 -WthquTqgS7rLQZHhZ6D0EnGnOkzlmxJMYPNHSOY1/6ivdNUUcC87awNEA3lgfhy2 -5IyBK3QJc+aYKNTbt70Lery3bu2wWLFGtmNiGlQTS4JsxImRsECTI727ObS7/FWA -QsqW+COL0Sa5BuMFrFIpjPrEe0ih7vRRbdmXRwIDAQABAoIBAGe4+9VqZfJN+dsq -8Osyuz01uQ8OmC0sAWTIqUlQgENIyf9rCJsUBlYmwR5BT6Z69XP6QhHdpSK+TiAR -XUz0EqG9HYzcxHIBaACP7j6iRoQ8R4kbbiWKo0z3WqQGIOqFjvD/mKEuQdE5mEYw -eOUCG6BnX1WY2Yr8WKd2AA/tp0/Y4d8z04u9eodMpSTbHTzYMJb5SbBN1vo6FY7q -8zSuO0BMzXlAxUsCwHsk1GQHFr8Oh3zIR7bQGtMBouI+6Lhh7sjFYsfxJboqMTBV -IKaA216M6ggHG7MU1/jeKcMGDmEfqQLQoyWp29rMK6TklUgipME2L3UD7vTyAVzz -xbVOpZkCgYEA8CXW4sZBBrSSrLR5SB+Ubu9qNTggLowOsC/kVKB2WJ4+xooc5HQo -mFhq1v/WxPQoWIxdYsfg2odlL+JclK5Qcy6vXmRSdAQ5lK9gBDKxZSYc3NwAw2HA -zyHCTK+I0n8PBYQ+yGcrxu0WqTGnlLW+Otk4CejO34WlgHwbH9bbY5UCgYEA3ZvT -C4+OoMHXlmICSt29zUrYiL33IWsR3/MaONxTEDuvgkOSXXQOl/8Ebd6Nu+3WbsSN -bjiPC/JyL1YCVmijdvFpl4gjtgvfJifs4G+QHvO6YfsYoVANk4u6g6rUuBIOwNK4 -RwYxwDc0oysp+g7tPxoSgDHReEVKJNzGBe9NGGsCgYEA4O4QP4gCEA3B9BF2J5+s -n9uPVxmiyvZUK6Iv8zP4pThTBBMIzNIf09G9AHPQ7djikU2nioY8jXKTzC3xGTHM -GJZ5m6fLsu7iH+nDvSreDSeNkTBfZqGAvoGYQ8uGE+L+ZuRfCcXYsxIOT5s6o4c3 -Dle2rVFpsuKzCY00urW796ECgYBn3go75+xEwrYGQSer6WR1nTgCV29GVYXKPooy -zmmMOT1Yw80NSkEw0pFD4cTyqVYREsTrPU0mn1sPfrOXxnGfZSVFpcR/Je9QVfQ7 -eW7GYxwfom335aqHVj10SxRqteP+UoWWnHujCPz94VRKZMakBddYCIGSan+G6YdS -7sdmwwKBgBc2qj0wvGXDF2kCLwSGfWoMf8CS1+5fIiUIdT1e/+7MfDdbmLMIFVjF -QKS3zVViXCbrG5SY6wS9hxoc57f6E2A8vcaX6zy2xkZlGHQCpWRtEM5R01OWJQaH -HsHMmQZGUQVoDm1oRkDhrTFK4K3ukc3rAxzeTZ96utOQN8/KJsTv ------END RSA PRIVATE KEY----- diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/unit.test.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/unit.test.js deleted file mode 100644 index 932b3c14..00000000 --- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/policyfile/tests/unit.test.js +++ /dev/null @@ -1,231 +0,0 @@ -var fspfs = require('../') - , fs = require('fs') - , http = require('http') - , https = require('https') - , net = require('net') - , should = require('should') - , assert = require('assert'); - -module.exports = { - // Library version should be Semver compatible - 'Library version': function(){ - fspfs.version.should.match(/^\d+\.\d+\.\d+$/); - } - - // Creating a server instace should not cause any problems - // either using the new Server or createServer method. -, 'Create Server instance': function(){ - var server = fspfs.createServer() - , server2 = new fspfs.Server({log:false}, ['blog.3rd-Eden.com:1337']); - - // server 2 options test - server2.log.should.be.false; - server2.origins.length.should.equal(1); - server2.origins[0].should.equal('blog.3rd-Eden.com:1337'); - - // server defaults - (typeof server.log).should.be.equal('function'); - server.origins.length.should.equal(1); - server.origins[0].should.equal('*:*'); - - // instance checking, sanity check - assert.ok(server instanceof fspfs.Server); - assert.ok(!!server.buffer); - - // more options testing - server = fspfs.createServer(['blog.3rd-Eden.com:80']); - server.origins.length.should.equal(1); - server.origins[0].should.equal('blog.3rd-Eden.com:80'); - - server = fspfs.createServer({log:false},['blog.3rd-Eden.com:80']); - server.log.should.be.false; - server.origins.length.should.equal(1); - server.origins[0].should.equal('blog.3rd-Eden.com:80'); - - } - -, 'Add origin': function(){ - var server = fspfs.createServer(); - server.add('google.com:80', 'blog.3rd-Eden.com:1337'); - - server.origins.length.should.equal(3); - server.origins.indexOf('google.com:80').should.be.above(0); - - // don't allow duplicates - server.add('google.com:80', 'google.com:80'); - - var i = server.origins.length - , count = 0; - - while(i--){ - if (server.origins[i] === 'google.com:80'){ - count++; - } - } - - count.should.equal(1); - } - -, 'Remove origin': function(){ - var server = fspfs.createServer(); - server.add('google.com:80', 'blog.3rd-Eden.com:1337'); - server.origins.length.should.equal(3); - - server.remove('google.com:80'); - server.origins.length.should.equal(2); - server.origins.indexOf('google.com:80').should.equal(-1); - } - -, 'Buffer': function(){ - var server = fspfs.createServer(); - - Buffer.isBuffer(server.buffer).should.be.true; - server.buffer.toString().indexOf('to-ports="*"').should.be.above(0); - server.buffer.toString().indexOf('domain="*"').should.be.above(0); - server.buffer.toString().indexOf('domain="google.com"').should.equal(-1); - - // The buffers should be rebuild when new origins are added - server.add('google.com:80'); - server.buffer.toString().indexOf('to-ports="80"').should.be.above(0); - server.buffer.toString().indexOf('domain="google.com"').should.be.above(0); - - server.remove('google.com:80'); - server.buffer.toString().indexOf('to-ports="80"').should.equal(-1); - server.buffer.toString().indexOf('domain="google.com"').should.equal(-1); - } - -, 'Responder': function(){ - var server = fspfs.createServer() - , calls = 0 - // dummy socket to emulate a `real` socket - , dummySocket = { - readyState: 'open' - , end: function(buffer){ - calls++; - Buffer.isBuffer(buffer).should.be.true; - buffer.toString().should.equal(server.buffer.toString()); - } - }; - - server.responder(dummySocket); - calls.should.equal(1); - } - -, 'Event proxy': function(){ - var server = fspfs.createServer() - , calls = 0; - - Object.keys(process.EventEmitter.prototype).forEach(function proxy(key){ - assert.ok(!!server[key] && typeof server[key] === 'function'); - }); - - // test if it works by calling a none default event - server.on('pew', function(){ - calls++; - }); - - server.emit('pew'); - calls.should.equal(1); - } - -, 'inline response http': function(){ - var port = 1335 - , httpserver = http.createServer(function(q,r){r.writeHead(200);r.end(':3')}) - , server = fspfs.createServer(); - - httpserver.listen(port, function(){ - server.listen(port + 1, httpserver, function(){ - var client = net.createConnection(port); - client.write('<policy-file-request/>\0'); - client.on('error', function(err){ - assert.ok(!err, err) - }); - client.on('data', function(data){ - - var response = data.toString(); - console.log(response); - - response.indexOf('to-ports="*"').should.be.above(0); - response.indexOf('domain="*"').should.be.above(0); - response.indexOf('domain="google.com"').should.equal(-1); - - // clean up - client.destroy(); - server.close(); - httpserver.close(); - }); - }); - }); - } - -, 'server response': function(){ - var port = 1340 - , server = fspfs.createServer(); - - server.listen(port, function(){ - var client = net.createConnection(port); - client.write('<policy-file-request/>\0'); - client.on('error', function(err){ - assert.ok(!err, err) - }); - client.on('data', function(data){ - - var response = data.toString(); - - response.indexOf('to-ports="*"').should.be.above(0); - response.indexOf('domain="*"').should.be.above(0); - response.indexOf('domain="google.com"').should.equal(-1); - - // clean up - client.destroy(); - server.close(); - }); - }); - } - -, 'inline response https': function(){ - var port = 1345 - , ssl = { - key: fs.readFileSync(__dirname + '/ssl/ssl.private.key').toString() - , cert: fs.readFileSync(__dirname + '/ssl/ssl.crt').toString() - } - , httpserver = https.createServer(ssl, function(q,r){r.writeHead(200);r.end(':3')}) - , server = fspfs.createServer(); - - httpserver.listen(port, function(){ - server.listen(port + 1, httpserver, function(){ - var client = net.createConnection(port); - client.write('<policy-file-request/>\0'); - client.on('error', function(err){ - assert.ok(!err, err) - }); - client.on('data', function(data){ - - var response = data.toString(); - - response.indexOf('to-ports="*"').should.be.above(0); - response.indexOf('domain="*"').should.be.above(0); - response.indexOf('domain="google.com"').should.equal(-1); - - // clean up - client.destroy(); - server.close(); - httpserver.close(); - }); - }); - }); - } - -, 'connect_failed': function(){ - var server = fspfs.createServer(); - - server.on('connect_failed', function(){ - assert.ok(true); - }); - - server.listen(function(){ - assert.ok(false, 'Run this test without root access'); - server.close(); - }); - } -};
\ No newline at end of file |