This module defines the abstract session interface in a class named AbstractSession, and two descendants MasterSession and StackedSession.
Sessions are hierarchically stacked into each other just like proxies. Each session has an owner session (except for the master session which is on the top), and variables are "inherited" from owner sessions. (implemented using a simple getattr wrapper) This way stacked sessions can inherit data from encapsulating proxies. (an HTTP proxy may define an URL and a mime-type, and stacked CVP module may inspect those values)
from Zone import root_zone
import Zorp
Module defining global constants, and interface entry points to the Zorp core.
from Zorp import *
Module defining global constants, and interface entry points to the Zorp core.
import os
Both MasterSession and StackedSession are derived from this class.
none
Destroys the session.
destroy ( self ) |
We close filedescriptors here, in case no proxy module could be started (because of policy violations, or because the module cannot be found).
Table 4-104. Arguments for AbstractSession.destroy()
self | this instance |
Master session class.
Table 4-105. Attributes for class MasterSession
client_fd | client fd |
client_stream | client stream |
client_address | SockAddr instance containing client address |
client_local | local address (on the firewall) |
client_zone | zone of the client |
server_fd | server fd |
server_stream | server stream |
server_address | SockAddr instance containing server address |
server_local | local address (on the firewall) |
server_zone | zone of the server |
service | service instance this session runs |
session_id | unique identifier for this session in the format: "(firewall/service:instance id/proxy)" |
instance_id | the instance identifier of the service (sequence number) |
started | indicates that the instance has been started |
auth | authentication method |
Initializes a MasterSession instance.
__init__ ( self ) |
This constructor initializes a new MasterSession instance based on its arguments.
Table 4-106. Arguments for MasterSession.__init__()
self | this instance |
Function called when the master session is freed.
__del__ ( self ) |
This function is called when the master session is freed, thus the session ended. We inform our spawner service about this event.
Function to actually check access control.
isClientPermitted ( self ) |
This function is called when a connection is established to perform access control checks whether the client is permitted to use the requested service. Its return value specifies the result of the check.
Table 4-107. Arguments for MasterSession.isClientPermitted()
self | this instance |
Z_ACCEPT for success, and Z_REJECT for failure
Set client address and perform access control.
setClient ( self, fd, addr, ) |
Sets the client address of the given session, and performs access control checks.
Table 4-108. Arguments for MasterSession.setClient()
self | this instance |
fd | fd of the client |
addr | sockaddr of the client |
Set the server address and perform access control checks.
setServer ( self, addr ) |
Stores the server address of the given connection, looks up server zone and performs access control and raises an exception upon failure.
Table 4-109. Arguments for MasterSession.setServer()
self | this instance |
addr | Server address |
Sets the service belonging to this session.
setService ( self, service ) |
Stores the service reference, and recalculates the session_id
Table 4-110. Arguments for MasterSession.setService()
self | this instance |
service | Service instance |
Set service instance number and recalculate session id.
setServiceInstance ( self, instance_id ) |
Sets service instance number, and makes up a unique identifier for this session.
Table 4-111. Arguments for MasterSession.setServiceInstance()
self | this instance |
instance_id | unique identifier of the service instance |
A StackedSession is a subsession, inheriting attributes from its parent.
Table 4-112. Attributes for class StackedSession
owner | Parent session |
chainer | Chainer used to chain up to parent. If none simply server_fd is used. |
Initializes a StackedSession instance.
__init__ ( self, owner, chainer=None, ) |
This constructor initializes a new StackedSession instance based on parameters.
Table 4-113. Arguments for StackedSession.__init__()
self | this instance |
owner | Parent session |
chainer | Chainer used to chain up to parent. |
Perform attribute inheritance
__getattr__ ( self, name ) |
Wrapper to return variables from parent session, if not overriden in this instance.
Table 4-114. Arguments for StackedSession.__getattr__()
self | this instance |
name | Name of the attribute to get. |
The value of the given attribute.
Set the proxy name used in this subsession.
setProxy ( self, proxy ) |
Stores a reference to the proxy class, and modifies the session_id to include the proxy name.
Table 4-115. Arguments for StackedSession.setProxy()
self | this instance |
proxy | Proxy class, derived from Proxy |