pyrad.host – RADIUS host definition
Base class with the settings shared by RADIUS clients and servers.
- class pyrad.host.Host(authport=1812, acctport=1813, coaport=3799, dict=None)[source]
Generic RADIUS capable host.
Base class of
pyrad.client.Clientandpyrad.server.Server, which holds the dictionary and the ports and creates packets with this dictionary.- Variables:
dict – RADIUS dictionary
authport – the port a server listens on for authentication packets, or the port of the server a client sends them to
acctport – the port a server listens on for accounting packets, or the port of the server a client sends them to
coaport – the port a server listens on for CoA and Disconnect packets, or the port of the server a client sends them to
- Parameters:
authport (int) – authentication port, see
authportacctport (int) – accounting port, see
acctportcoaport (int) – CoA port, see
coaportdict (pyrad.dictionary.Dictionary) – RADIUS dictionary
- CreateAcctPacket(**args)[source]
Create an accounting packet with the dictionary of this host.
The keyword arguments are passed to
pyrad.packet.AcctPacket: packet arguments (code,id,secret,authenticator,message_authenticator,packet) and attributes to add, with-in the attribute names replaced by_. The default code is Accounting-Request.- Returns:
a new packet
- Return type:
- CreateAuthPacket(**args)[source]
Create an authentication packet with the dictionary of this host.
The keyword arguments are passed to
pyrad.packet.AuthPacket: packet arguments (code,id,secret,authenticator,auth_type,message_authenticator,packet) and attributes to add, with-in the attribute names replaced by_(User_Name='alice'). The default code is Access-Request.- Returns:
a new packet
- Return type:
- CreateCoAPacket(**args)[source]
Create a CoA or Disconnect packet with the dictionary of this host.
The keyword arguments are passed to
pyrad.packet.CoAPacket: packet arguments (code,id,secret,authenticator,message_authenticator,packet) and attributes to add, with-in the attribute names replaced by_. The default code is CoA-Request, passcode=pyrad.packet.DisconnectRequestfor a Disconnect-Request.- Returns:
a new packet
- Return type:
- CreatePacket(**args)[source]
Create a generic RADIUS packet with the dictionary of this host.
The keyword arguments are passed to
pyrad.packet.Packet: packet arguments such ascode,id,secret,authenticatororpacket, and attributes to add, with-in the attribute names replaced by_.- Returns:
a new packet
- Return type:
- SendPacket(fd, pkt)[source]
Send a request packet to the address in
pkt.source.The packet is encoded with
pkt.RequestPacket(). pyrad doesn’t use this method itself;pyrad.client.Client.SendPacket()replaces it.- Parameters:
fd (socket.socket) – socket to send the packet with
pkt (pyrad.packet.Packet) – packet to send
- SendReplyPacket(fd, pkt)[source]
Send a reply packet to the address in
pkt.source.The packet is encoded with
pyrad.packet.Packet.ReplyPacket(). A reply created withCreateReplyof a received request has the source of the request.- Parameters:
fd (socket.socket) – socket to send the packet with
pkt (pyrad.packet.Packet) – reply packet to send