safe progress
This commit is contained in:
@@ -11,43 +11,46 @@ from pyrad.dictionary import Dictionary
|
||||
|
||||
|
||||
def main(path_to_dictionary):
|
||||
srv = Client(server='127.0.0.1',
|
||||
secret=b'Kah3choteereethiejeimaeziecumi',
|
||||
dict=Dictionary(path_to_dictionary))
|
||||
srv = Client(
|
||||
server="127.0.0.1",
|
||||
secret=b"Kah3choteereethiejeimaeziecumi",
|
||||
dict=Dictionary(path_to_dictionary),
|
||||
)
|
||||
|
||||
req = srv.CreateAuthPacket(
|
||||
code=pyrad.packet.AccessRequest,
|
||||
**{
|
||||
'User-Name': 'wichert',
|
||||
'NAS-IP-Address': '192.168.1.10',
|
||||
'NAS-Port': 0,
|
||||
'Service-Type': 'Login-User',
|
||||
'NAS-Identifier': 'trillian',
|
||||
'Called-Station-Id': '00-04-5F-00-0F-D1',
|
||||
'Calling-Station-Id': '00-01-24-80-B3-9C',
|
||||
'Framed-IP-Address': '10.0.0.100',
|
||||
})
|
||||
"User-Name": "wichert",
|
||||
"NAS-IP-Address": "192.168.1.10",
|
||||
"NAS-Port": 0,
|
||||
"Service-Type": "Login-User",
|
||||
"NAS-Identifier": "trillian",
|
||||
"Called-Station-Id": "00-04-5F-00-0F-D1",
|
||||
"Calling-Station-Id": "00-01-24-80-B3-9C",
|
||||
"Framed-IP-Address": "10.0.0.100",
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
print('Sending authentication request')
|
||||
print("Sending authentication request")
|
||||
reply = srv.SendPacket(req)
|
||||
except pyrad.client.Timeout:
|
||||
print('RADIUS server does not reply')
|
||||
print("RADIUS server does not reply")
|
||||
sys.exit(1)
|
||||
except socket.error as error:
|
||||
print('Network error: ' + error[1])
|
||||
print("Network error: " + error[1])
|
||||
sys.exit(1)
|
||||
|
||||
if reply.code == pyrad.packet.AccessAccept:
|
||||
print('Access accepted')
|
||||
print("Access accepted")
|
||||
else:
|
||||
print('Access denied')
|
||||
print("Access denied")
|
||||
|
||||
print('Attributes returned by server:')
|
||||
print("Attributes returned by server:")
|
||||
for key, value in reply.items():
|
||||
print(f'{key} {value}')
|
||||
print(f"{key} {value}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
dictionary = path.join(path.dirname(path.abspath(__file__)), 'dictionary')
|
||||
if __name__ == "__main__":
|
||||
dictionary = path.join(path.dirname(path.abspath(__file__)), "dictionary")
|
||||
main(dictionary)
|
||||
|
||||
Reference in New Issue
Block a user