Git Product home page Git Product logo

flashpolicyfileserver's Introduction

LOL, WUT?

It basically allows you to allow or disallow Flash Player sockets from accessing your site.

Installation

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 :)
var pf = require('policyfile').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.
var pf = require('policyfile').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).

var pf = require('policyfile').createServer()
  , http = require('http');

server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')});
server.listen(80);

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.

var pf = require('policyfile').createServer(['google.com:80']);

pf.listen();
pf.add('blog.3rd-Eden.com:80', 'blog.3rd-Eden.com:8080'); // now has 3 origins

server.remove

Removes added origins from the policy file - you can add as many arguments as you like.

var pf = require('policyfile').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

var pf = require('policyfile').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

flashpolicyfileserver's People

Contributors

3rd-eden avatar einaros avatar mweibel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flashpolicyfileserver's Issues

Connecting with https

Does this library support https? I'm trying to connect to this flash policy file server via socket.io. My socket.io server is running on port 443 with ssl, and I'm unsure if this is causing a conflict with this policy file server since it seems only to accept http and the websocket connection will not be established.

TypeError {} (anonymous function)

My console log shows me this TypeError with no line number for the error

[WebSocket] response header:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: EKe7xY9gtGUsL6JCb3hs1x2qLU8=

TypeError {}
(anonymous function)

my code is:

var pf=require('policyfile').createServer(['http://website.com','website.com','website.com:*','website.com:8004','website.com:8005']);
pf.listen(function(){console.log(':3 yay')});

Where might this error come from?

Problem attaching to http instance

@3rd-Eden

I am having trouble trying to attach the policyfile module to my http instance. I am still getting the following:

FlashPolicyFileServer received an error event:
listen EACCES

wherenever I run this code:

var express = require('express');
var app = express();
var server = require('http').createServer(app).listen(process.env.PORT || 9009);
app.use(express.static(__dirname + '/public'));
var pf = require('policyfile').createServer().listen(null, server);

Acccording to their docs I should be able to do this

var pf = require('policyfile').createServer()
  , http = require('http');

server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')});
server.listen(80);

pf.listen(1337, server, function(){
  console.log(':3 yay')
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.