This module defines the Listener class, the main entry point for client requests. Listener binds to a given address, waits for connections, and for each connection spawns a new session to handle that connection.
from Service import services
Module defining service related classes.
from Session import MasterSession
Module defining session related classes and functions.
from Zorp import *
Module defining global constants, and interface entry points to the Zorp core.
from traceback import print_exc
This is the starting point of Zorp services. It listens on the given port, and when a connection is accepted it starts a session and the given service.
Table 4-67. Attributes for class Listener
listen | A Zorp.Listen instance |
service | the service to be started |
bindto | bind address |
local | local address where the listener is bound |
Constructor to initialize a Listen instance
__init__ ( self, bindto, service, transparent=FALSE, ) |
Creates the instance, sets the initial attributes, and starts the listener
Table 4-68. Arguments for Listener.__init__()
self | this instance |
bindto | the address to bind to |
service | the service name to start |
transparent | TRUE if this is a listener of a transparent service, specifying this is not mandatory but performs additional checks |
ServiceException
Callback to inform the python layer about incoming connections.
accepted ( self, client, fd, ) |
This callback is called by the core when a connection is accepted. Its primary function is to check access control (whether the client is permitted to connect to this port), and to spawn a new session to handle the connection.
Exceptions raised due to policy violations are handled here.
Table 4-69. Arguments for Listener.accepted()
self | this instance |
client | the address of the client |
fd | the fd of the connection to the client |
DACException
TRUE if the connection is accepted
Stops the listener on the given port
destroy ( self ) |
Calls the destroy method of the low-level object
Table 4-70. Arguments for Listener.destroy()
self | this instance |
Returns the service associated with the listener
getService ( self, session ) |
Returns the service to start.
Table 4-71. Arguments for Listener.getService()
self | this instance |
session | session reference |
This class is similar to a simple Listener, but instead of starting a fixed service, it chooses one based on the client zone.
It takes a mapping of services indexed by a zone name, with an exception of the * service, which matches anything.
Table 4-72. Attributes for class ZoneListener
services | services mapping indexed by zone name |
Initialize a ZoneListener instance.
__init__ ( self, bindto, services, ) |
Initialize a ZoneListener instance and set initial attribute values based on arguments.
Table 4-73. Arguments for ZoneListener.__init__()
self | this instance |
bindto | bind to this address |
services | a mapping between zone names and services |
Virtual function which returns the service to be ran
getService ( self, session ) |
Called by our base class to find out the service to be used for the current session.
Table 4-74. Arguments for ZoneListener.getService()
self | this instance |
session | session we are starting |