index.js
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();
}
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();
}
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 ( ) ; }
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
The server that does the Policy File severing