safe progress

This commit is contained in:
Istvan Ruzman
2020-08-06 18:04:24 +02:00
parent 3254bc66e0
commit fd16436c3c
53 changed files with 2167 additions and 4589 deletions

View File

@@ -11,27 +11,29 @@ from pyrad.dictionary import Dictionary
def main(path_to_dictionary, coa_type, nas_identifier):
# create coa client
client = Client(server='127.0.0.1',
secret=b'Kah3choteereethiejeimaeziecumi',
dict=Dictionary(path_to_dictionary))
client = Client(
server="127.0.0.1",
secret=b"Kah3choteereethiejeimaeziecumi",
dict=Dictionary(path_to_dictionary),
)
# set coa timeout
client.timeout = 30
# create coa request packet
attributes = {
'Acct-Session-Id': '1337',
'NAS-Identifier': nas_identifier,
"Acct-Session-Id": "1337",
"NAS-Identifier": nas_identifier,
}
if coa_type == 'coa':
if coa_type == "coa":
# create coa request
request = client.CreateCoAPacket(**attributes)
elif coa_type == 'dis':
elif coa_type == "dis":
# create disconnect request
request = client.CreateCoAPacket(
code=pyrad.packet.DisconnectRequest,
**attributes)
code=pyrad.packet.DisconnectRequest, **attributes
)
else:
sys.exit(1)
@@ -41,11 +43,11 @@ def main(path_to_dictionary, coa_type, nas_identifier):
print(result.code)
if __name__ == '__main__':
if __name__ == "__main__":
if len(sys.argv) != 3:
print('usage: coa.py {coa|dis} daemon-1234')
print("usage: coa.py {coa|dis} daemon-1234")
sys.exit(1)
dictionary = path.join(path.dirname(path.abspath(__file__)), 'dictionary')
dictionary = path.join(path.dirname(path.abspath(__file__)), "dictionary")
main(dictionary, sys.argv[1], sys.argv[2])