pyrad.server – basic server

class pyrad.server.RemoteHost(address, secret, name, authport=1812, acctport=1813, coaport=3799)[source]

Remote RADIUS capable host we can talk to.

class pyrad.server.ServerPacketError[source]

Exception class for bogus packets. ServerPacketError exceptions are only used inside the Server class to abort processing of a packet.

class pyrad.server.Server(addresses=[], authport=1812, acctport=1813, coaport=3799, hosts=None, dict=None, auth_enabled=True, acct_enabled=True, coa_enabled=False)[source]

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.

Variables:
  • hosts – hosts who are allowed to talk to us
  • _poll – poll object for network sockets
  • _fdmap – map of filedescriptors to network sockets
  • MaxPacketSize – maximum size of a RADIUS packet
BindToAddress(addr)[source]

Add an address to listen to. An empty string indicated you want to listen on all addresses.

Parameters:addr (string) – IP address to listen on
CreateReplyPacket(pkt, **attributes)[source]

Create a reply packet. Create a new packet which can be returned as a reply to a received packet.

Parameters:pkt (Packet instance) – original packet
HandleAcctPacket(pkt)[source]

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 class instance) – packet to process
HandleAuthPacket(pkt)[source]

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 class instance) – packet to process
HandleCoaPacket(pkt)[source]

CoA 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 class instance) – packet to process
HandleDisconnectPacket(pkt)[source]

CoA 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 class instance) – packet to process
Run()[source]

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.