Class PolicyServer
In: flashpolicyd.rb
Parent: Object

Methods

bogusclient   debug   dumpconnections   dumpthreads   error   fatal   info   log   new   printstats   serve   start   toggledebug   warn  

Public Class methods

Synopsis

Initializes the server

Args

port:The port to listen on, if the port is < 1024 server must run as roo
host:The host to listen on, use 0.0.0.0 for all addresses
xml:The XML to serve to clients
logger:An instanse of the Ruby Standard Logger class
timeout:How long does client have to complete the whole process before the socket closes and the thread terminates
debug:Set to true to enable DEBUG level logging from startup

Public Instance methods

Logs a message passed to it and increment the bogus client counter inside a mutex

Log a msg at level DEBUG

Walks the list of active connections and dump them to the logger at INFO level

Dump the current thread list

Log a msg at level ERROR

Log a msg at level FATAL

Log a msg at level INFO

Generic logging method that takes a severity constant from the Logger class such as Logger::DEBUG

Prints some basic stats about the server so far, bogus client are ones that timeout or otherwise cause problems

The main logic of client handling, waits for @timeout seconds to receive a null terminated request containing "policy-file-request" and sends back the data, else marks the client as bogus and close the connection.

Any exception caught during this should mark a client as bogus

Synopsis

Starts the main loop of the server and handles connections, logic is more or less:

  1. Opens the port for listening
  2. Create a new thread so the connection handling happens seperate from the main loop
  3. Create a loop to accept new sessions from the socket, each new sesison gets a new thread
  4. Increment the totalclient variable for stats handling
  5. Create a OpenStruct structure with detail about the current connection and put it in the @connections array
  6. Pass the connection to the serve method for handling
  7. Once handling completes, remove the connection from the active list and close the socket

If the logger instanse is in DEBUG mode, put it into INFO and vica versa

Log a msg at level WARN

[Validate]