-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
304 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ jobs: | |
|
||
- name: Format | ||
run: > | ||
poetry run yapf -dr | ||
poetry run ruff format --diff | ||
librouteros | ||
tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
# -*- coding: UTF-8 -*- | ||
|
||
import typing | ||
from binascii import unhexlify, hexlify #pylint: disable=no-name-in-module | ||
from binascii import unhexlify, hexlify # pylint: disable=no-name-in-module | ||
from hashlib import md5 | ||
|
||
|
||
def encode_password(token: str, password: str) -> str: | ||
#pylint: disable=redefined-outer-name | ||
token_bytes = token.encode('ascii', 'strict') | ||
# pylint: disable=redefined-outer-name | ||
token_bytes = token.encode("ascii", "strict") | ||
token_bytes = unhexlify(token) | ||
password_bytes = password.encode('ascii', 'strict') | ||
password_bytes = password.encode("ascii", "strict") | ||
hasher = md5() | ||
hasher.update(b'\x00' + password_bytes + token_bytes) | ||
hasher.update(b"\x00" + password_bytes + token_bytes) | ||
password_bytes = hexlify(hasher.digest()) | ||
return '00' + password_bytes.decode('ascii', 'strict') | ||
return "00" + password_bytes.decode("ascii", "strict") | ||
|
||
|
||
def token(api: typing.Any, username: str, password: str) -> None: | ||
"""Login using pre routeros 6.43 authorization method.""" | ||
sentence = api('/login') | ||
tok = tuple(sentence)[0]['ret'] | ||
sentence = api("/login") | ||
tok = tuple(sentence)[0]["ret"] | ||
encoded = encode_password(tok, password) | ||
tuple(api('/login', **{'name': username, 'response': encoded})) | ||
tuple(api("/login", **{"name": username, "response": encoded})) | ||
|
||
|
||
def plain(api: typing.Any, username: str, password: str) -> None: | ||
"""Login using post routeros 6.43 authorization method.""" | ||
tuple(api('/login', **{'name': username, 'password': password})) | ||
tuple(api("/login", **{"name": username, "password": password})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.