Package pyrad :: Module server :: Class Server
[show private | hide private]
[frames | no frames]

Class Server

Host --+
       |
      Server

Known Subclasses:
Proxy

Basic RADIUS server.

This class implements the basics of a RADIUS server. It takes care of the details of receiving and decoding requests; processing of the requests should be done by overloading the appropriate methods in derived classes.
Method Summary
  __init__(self, addresses, authport, acctport, hosts, dict)
Constructor.
  BindToAddress(self, addr)
Add an address to listen to.
  CreateReplyPacket(self, pkt, **attributes)
Create a reply packet.
  HandleAcctPacket(self, pkt)
Accounting packet handler.
  HandleAuthPacket(self, pkt)
Authentication packet handler.
  Run(self)
Main loop.
Packet class instance _GrabPacket(self, pktgen, fd)
Read a packet from a network connection.
  _HandleAcctPacket(self, pkt)
Process a packet received on the accounting port
  _HandleAuthPacket(self, pkt)
Process a packet received on the authentication port
  _PrepareSockets(self)
Prepare all sockets to receive packets.
  _ProcessInput(self, fd)
Process available data.
    Inherited from Host
pyrad.packet.Packet CreateAcctPacket(self, **args)
Create a new RADIUS packet.
pyrad.packet.Packet CreateAuthPacket(self, **args)
Create a new RADIUS packet.
  SendPacket(self, fd, pkt)
Send a packet.
  SendReplyPacket(self, fd, pkt)
Send a packet.

Instance Variable Summary
dictionary of Host class instances hosts: hosts who are allowed to talk to us
dictionary _fdmap: map of filedescriptors to network sockets
select.poll class instance _poll: poll object for network sockets
    Inherited from Host
integer acctport: port to listen on for accounting packets
integer authport: port to listen on for authentication packets
pyrad.dictionary.Dictionary dict: RADIUS dictionary

Class Variable Summary
integer MaxPacketSize: maximum size of a RADIUS packet

Method Details

__init__(self, addresses=[], authport=1812, acctport=1813, hosts={}, dict=None)
(Constructor)

Constructor.
Parameters:
addresses - IP addresses to listen on
           (type=sequence of strings)
authport - port to listen on for authentication packets
           (type=integer)
acctport - port to listen on for accounting packets
           (type=integer)
hosts - hosts who we can talk to
           (type=dictionary mapping IP to RemoteHost class instances)
dict - RADIUS dictionary to use
           (type=Dictionary class instance)
Overrides:
pyrad.host.Host.__init__

BindToAddress(self, addr)

Add an address to listen to.

An empty string indicated you want to listen on all addresses.
Parameters:
addr - IP address to listen on
           (type=string)

CreateReplyPacket(self, pkt, **attributes)

Create a reply packet.

Create a new packet which can be returned as a reply to a received packet.
Parameters:
pkt - original packet
           (type=Packet instance)

HandleAcctPacket(self, pkt)

Accounting packet handler.

This is an empty function that is called when a valid accounting packet has been received. It can be overriden in derived classes to add custom behaviour.
Parameters:
pkt - packet to process
           (type=Packet class instance)

HandleAuthPacket(self, pkt)

Authentication packet handler.

This is an empty function that is called when a valid authentication packet has been received. It can be overriden in derived classes to add custom behaviour.
Parameters:
pkt - packet to process
           (type=Packet class instance)

Run(self)

Main loop.

This method is the main loop for a RADIUS server. It waits for packets to arrive via the network and calls other methods to process them.

_GrabPacket(self, pktgen, fd)

Read a packet from a network connection.

This method assumes there is data waiting for to be read.
Parameters:
fd - socket to read packet from
           (type=socket class instance)
Returns:
RADIUS packet
           (type=Packet class instance)

_HandleAcctPacket(self, pkt)

Process a packet received on the accounting port

If this packet should be dropped instead of processed a PacketError exception should be raised. The main loop will drop the packet and log the reason.
Parameters:
pkt - packet to process
           (type=Packet class instance)

_HandleAuthPacket(self, pkt)

Process a packet received on the authentication port

If this packet should be dropped instead of processed a PacketError exception should be raised. The main loop will drop the packet and log the reason.
Parameters:
pkt - packet to process
           (type=Packet class instance)

_PrepareSockets(self)

Prepare all sockets to receive packets.

_ProcessInput(self, fd)

Process available data.

If this packet should be dropped instead of processed a PacketError exception should be raised. The main loop will drop the packet and log the reason.

This function calls either HandleAuthPacket() or HandleAcctPacket() depending on which socket is being processed.
Parameters:
fd - socket to read packet from
           (type=socket class instance)

Instance Variable Details

hosts

hosts who are allowed to talk to us
Type:
dictionary of Host class instances

_fdmap

map of filedescriptors to network sockets
Type:
dictionary

_poll

poll object for network sockets
Type:
select.poll class instance

Class Variable Details

MaxPacketSize

maximum size of a RADIUS packet
Type:
integer
Value:
8192                                                                  

Generated by Epydoc 2.1 on Wed Jun 2 14:19:55 2004 http://epydoc.sf.net