pyrad.client – basic client

class pyrad.client.Timeout[source]

Simple exception class which is raised when a timeout occurs while waiting for a RADIUS server to respond.

class pyrad.client.Client(server, authport=1812, acctport=1813, coaport=3799, secret=b'', dict=None, retries=3, timeout=5)[source]

Basic RADIUS client. This class implements a basic RADIUS client. It can send requests to a RADIUS server, taking care of timeouts and retries, and validate its replies.

Variables:
  • retries – number of times to retry sending a RADIUS request

  • timeout – number of seconds to wait for an answer

CreateAcctPacket(**args)[source]

Create a new RADIUS packet. This utility function creates a new RADIUS packet which can be used to communicate with the RADIUS server this client talks to. This is initializing the new packet with the dictionary and secret used for the client.

Returns:

a new empty packet instance

Return type:

pyrad.packet.Packet

CreateAuthPacket(**args)[source]

Create a new RADIUS packet. This utility function creates a new RADIUS packet which can be used to communicate with the RADIUS server this client talks to. This is initializing the new packet with the dictionary and secret used for the client.

Returns:

a new empty packet instance

Return type:

pyrad.packet.AuthPacket

CreateCoAPacket(**args)[source]

Create a new RADIUS packet. This utility function creates a new RADIUS packet which can be used to communicate with the RADIUS server this client talks to. This is initializing the new packet with the dictionary and secret used for the client.

Returns:

a new empty packet instance

Return type:

pyrad.packet.Packet

SendPacket(pkt)[source]

Send a packet to a RADIUS server.

Parameters:

pkt (pyrad.packet.Packet) – the packet to send

Returns:

the reply packet received

Return type:

pyrad.packet.Packet

Raises:

Timeout – RADIUS server does not reply

bind(addr)[source]

Bind socket to an address. Binding the socket used for communicating to an address can be usefull when working on a machine with multiple addresses.

Parameters:

addr (host,port tuple) – network address (hostname or IP) and port to bind to