-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added torrent module * underscores bugfix * added docstrings * updated requirements * changed directory * Added required changes * Fix base runners * Remove API key, fix main runner * Linting with Black Co-authored-by: omarkelov <36790281+omarkelov@users.noreply.github.com> Co-authored-by: Anton Nikolaev <regwebghost@yandex.ru>
- Loading branch information
1 parent
a4e67e6
commit 6810c8a
Showing
6 changed files
with
64 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
__root_dir = Path(__file__).parents[4] | ||
sys.path.append(str(__root_dir)) |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pprint import pprint | ||
from sys import argv | ||
from requests import get | ||
from src.core.utils.module import run_module | ||
from .module import Runner | ||
|
||
result = run_module( | ||
Runner, args=argv, arg_name="ip", arg_default=get("https://ifconfig.me/").text | ||
) | ||
pprint(result) |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from requests import get | ||
|
||
from src.core.base.recon import ReconRunner, PossibleKeys | ||
from src.core.utils.response import ScriptResponse | ||
from src.core.utils.validators import validate_kwargs | ||
|
||
|
||
class Defaults: | ||
API_KEY = "API_KEY_HERE" | ||
|
||
|
||
class Runner(ReconRunner): | ||
""" | ||
Runner class is used for parsing torrents by ip. | ||
""" | ||
|
||
def __init__(self, logger: str = __name__): | ||
super(Runner, self).__init__(logger) | ||
|
||
@validate_kwargs(PossibleKeys.KEYS) | ||
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error: | ||
""" | ||
Parses torrents by ip. | ||
:param args: args from core runner. | ||
:param kwargs: kwargs from core runner. | ||
:return: ScriptResponse with dictionary of torrents. | ||
""" | ||
ip = kwargs.get("ip") | ||
api_key = kwargs.get("torrent_api_key", Defaults.API_KEY) | ||
if not ip: | ||
return ScriptResponse.error(message="No IP was provided") | ||
response = get( | ||
f"https://api.antitor.com/history/peer/?ip={ip}&key={api_key}" | ||
).json() | ||
return ScriptResponse.success( | ||
message=f"Script finished for {ip}", result=response | ||
) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
chardet==3.0.4 | ||
idna==2.10 | ||
requests==2.24.0 | ||
urllib3==1.25.9 |