Refactoring the project structure
This commit is contained in:
parent
98901acb39
commit
a9d622927f
10
Dockerfile
10
Dockerfile
|
@ -7,14 +7,16 @@ WORKDIR /app
|
|||
# Clone the TorBot repository from GitHub
|
||||
RUN git clone https://github.com/DedSecInside/TorBot.git /app
|
||||
|
||||
# Install Poetry
|
||||
RUN pip install --no-cache-dir poetry
|
||||
# Install dependencies
|
||||
RUN pip install -r /app/requirements.txt
|
||||
|
||||
# Install TorBot dependencies using Poetry
|
||||
RUN cd /app && poetry install
|
||||
# Set the SOCKS5_PORT environment variable
|
||||
ENV SOCKS5_PORT=9050
|
||||
|
||||
# Expose the port specified in the .env file
|
||||
EXPOSE $SOCKS5_PORT
|
||||
|
||||
# Run the TorBot script
|
||||
CMD ["poetry", "run", "python", "torbot"]
|
||||
# Example way to run the container:
|
||||
# docker run --network="host" your-image-name poetry run python torbot -u https://www.example.com --depth 2 --visualize tree --save json
|
||||
|
|
11
README.md
11
README.md
|
@ -54,21 +54,14 @@
|
|||
|
||||
### TorBot
|
||||
|
||||
#### Using `poetry`
|
||||
* TorBot dependencies are managed using `poetry`, you can find the installation commands below:
|
||||
```sh
|
||||
poetry install # to install dependencies
|
||||
poetry run python torbot -u https://www.example.com --depth 2 --visualize tree --save json # example of running command with poetry
|
||||
poetry run python torbot -h # for help
|
||||
```
|
||||
|
||||
#### Using `venv`
|
||||
* If using Python ^3.4,
|
||||
```sh
|
||||
python -m venv torbot_venv
|
||||
source torbot_venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
python torbot -u https://www.example.com
|
||||
pip install -e .
|
||||
./main.py --help
|
||||
```
|
||||
|
||||
#### Using `docker`
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""
|
||||
Core
|
||||
"""
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import sys
|
||||
|
@ -8,12 +7,11 @@ import logging
|
|||
import toml
|
||||
import httpx
|
||||
|
||||
from modules.api import get_ip
|
||||
from modules.color import color
|
||||
from modules.updater import check_version
|
||||
from modules.info import execute_all
|
||||
from modules.linktree import LinkTree
|
||||
from modules.config import project_root_directory
|
||||
from torbot.modules.api import get_ip
|
||||
from torbot.modules.color import color
|
||||
from torbot.modules.updater import check_version
|
||||
from torbot.modules.info import execute_all
|
||||
from torbot.modules.linktree import LinkTree
|
||||
|
||||
|
||||
def print_tor_ip_address(client: httpx.Client) -> None:
|
||||
|
@ -167,12 +165,11 @@ def set_arguments() -> argparse.ArgumentParser:
|
|||
if __name__ == "__main__":
|
||||
try:
|
||||
arg_parser = set_arguments()
|
||||
config_file_path = os.path.join(project_root_directory, "pyproject.toml")
|
||||
config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pyproject.toml")
|
||||
try:
|
||||
version = None
|
||||
with open(config_file_path, "r") as f:
|
||||
data = toml.load(f)
|
||||
version = data["tool"]["poetry"]["version"]
|
||||
version = data["project"]["version"]
|
||||
except Exception as e:
|
||||
raise Exception("unable to find version from pyproject.toml.\n", e)
|
||||
|
|
@ -257,3 +257,18 @@ validators==0.20.0 ; python_version >= "3.9" and python_full_version <= "3.11.4"
|
|||
--hash=sha256:24148ce4e64100a2d5e267233e23e7afeb55316b47d30faae7eb6e7292bc226a
|
||||
yattag==1.15.1 ; python_version >= "3.9" and python_full_version <= "3.11.4" \
|
||||
--hash=sha256:960fa54be1229d96f43178133e0b195c003391fdc49ecdb6b69b7374db6be416
|
||||
|
||||
numpy~=1.24.4
|
||||
beautifulsoup4~=4.11.1
|
||||
sklearn~=0.0
|
||||
scikit-learn~=1.3.0
|
||||
httpx~=0.25.0
|
||||
yattag~=1.15.1
|
||||
termcolor~=1.1.0
|
||||
python-dotenv~=0.20.0
|
||||
Unipath~=1.1
|
||||
validators~=0.20.0
|
||||
phonenumbers~=8.13.22
|
||||
tabulate~=0.9.0
|
||||
treelib~=1.7.0
|
||||
toml~=0.10.2
|
|
@ -51,7 +51,7 @@ class LinkTree(Tree):
|
|||
self._append_node(id=self._url, parent_id=None)
|
||||
self._build_tree(url=self._url, depth=self._depth)
|
||||
|
||||
def _append_node(self, id: str, parent_id: str | None) -> None:
|
||||
def _append_node(self, id: str, parent_id: str or None) -> None:
|
||||
"""
|
||||
Creates a node for a tree using the given ID which corresponds to a URL.
|
||||
If the parent_id is None, this will be considered a root node.
|
||||
|
@ -144,9 +144,9 @@ class LinkTree(Tree):
|
|||
|
||||
for node in nodes:
|
||||
status_code = node.data.status
|
||||
if status_code >= 200 and status_code < 300:
|
||||
if 200 <= status_code < 300:
|
||||
insert(node, "green")
|
||||
elif status_code >= 300 and status_code < 400:
|
||||
elif 300 <= status_code < 400:
|
||||
insert(node, "yellow")
|
||||
else:
|
||||
insert(node, "red")
|
Can't render this file because it is too large.
|
|
@ -2,7 +2,7 @@ import httpx
|
|||
from yattag import Doc
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
from ..api import get_ip
|
||||
from torbot.modules.api import get_ip
|
||||
|
||||
|
||||
def generate_mock_torproject_page(header: str, body: str) -> str:
|
|
@ -1,7 +1,7 @@
|
|||
from bs4 import BeautifulSoup
|
||||
from yattag import Doc
|
||||
|
||||
from ..linktree import parse_hostname, parse_links, parse_emails, parse_phone_numbers
|
||||
from torbot.modules.linktree import parse_hostname, parse_links, parse_emails, parse_phone_numbers
|
||||
|
||||
|
||||
def test_parse_hostname() -> None:
|
Loading…
Reference in New Issue