diff --git a/.gitignore b/.gitignore index 811092d..73b66b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .git www/participants/** scripts/__pycache__/** - +.env +env/ \ No newline at end of file diff --git a/SimpleX/.env.sample b/SimpleX/.env.sample new file mode 100644 index 0000000..7f15145 --- /dev/null +++ b/SimpleX/.env.sample @@ -0,0 +1 @@ +WEBSOCKET_PORT=3030 diff --git a/SimpleX/main.py b/SimpleX/main.py index e8caff1..5ce94d0 100644 --- a/SimpleX/main.py +++ b/SimpleX/main.py @@ -1,14 +1,27 @@ from websockets.sync.client import connect +from dotenv import load_dotenv + import json import random +import os +script_abs_path = os.path.dirname(os.path.abspath(__file__)) +env_path = os.path.join(script_abs_path+"/.env") +default_env_path = os.path.join(script_abs_path+"/.env.sample") + +if os.path.exists(env_path): + load_dotenv(dotenv_path=env_path) +else: + load_dotenv(dotenv_path=default_env_path) + +websocket_port = os.getenv("WEBSOCKET_PORT") def is_simplex_link_valid(simplex_link: str) -> bool: """ Connects to the group using the `simplex_link`. If the response contains error False will be returned else True. """ - with connect("ws://localhost:3030") as websocket: + with connect(f"ws://localhost:{websocket_port}") as websocket: query = f"/c incognito {simplex_link}" command = { 'corrId': f"id{random.randint(0,999999)}", diff --git a/requirements.txt b/requirements.txt index af698b3..cbf4a08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,5 @@ requests==2.32.3 six==1.17.0 tzdata==2025.1 urllib3==2.3.0 +python-dotenv==1.0.1 +websockets==15.0.1 diff --git a/scripts/.env.sample b/scripts/.env.sample new file mode 100644 index 0000000..69154cf --- /dev/null +++ b/scripts/.env.sample @@ -0,0 +1,3 @@ +TOR_HOST=socks5h://127.0.0.1 +TOR_PORT=9050 + diff --git a/scripts/lantern.py b/scripts/lantern.py index 5cb31d7..f4bd94b 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -1,4 +1,5 @@ from utils import * +from dotenv import load_dotenv import os, pwd import pandas as pd @@ -9,11 +10,23 @@ import urllib import sys +script_abs_path = os.path.dirname(os.path.abspath(__file__)) +env_path = os.path.join(script_abs_path+"/.env") +default_env_path = os.path.join(script_abs_path+"/.env.sample") + +if os.path.exists(env_path): + load_dotenv(dotenv_path=env_path) +else: + load_dotenv(dotenv_path=default_env_path) + +tor_host = os.getenv("TOR_HOST") +tor_port = os.getenv("TOR_PORT") + def main(): #os.system('clear') proxies = { - 'http': 'socks5h://127.0.0.1:9050', - 'https': 'socks5h://127.0.0.1:9050' + 'http': f'{tor_host}:{tor_port}', + 'https': f'{tor_host}:{tor_port}' } rootpath='/srv/darknet-lantern/' @@ -33,7 +46,7 @@ def main(): # check if the directory exists if not os.path.isdir(participantdir): #if not, create it - print("Official participan ",line.strip() , "'s directory doesnt exist, creating it") + print("Official participant ",line.strip() , "'s directory doesnt exist, creating it") os.makedirs(participantdir) @@ -1193,4 +1206,4 @@ Maintenance: if __name__ == '__main__': - main() + main() diff --git a/scripts/uptimechecker.py b/scripts/uptimechecker.py index d1b929e..e3bccea 100644 --- a/scripts/uptimechecker.py +++ b/scripts/uptimechecker.py @@ -1,3 +1,5 @@ +from dotenv import load_dotenv + import os,re,pwd import csv import requests @@ -5,6 +7,20 @@ import json import pandas as pd import glob + + +script_abs_path = os.path.dirname(os.path.abspath(__file__)) +env_path = os.path.join(script_abs_path+"/.env") +default_env_path = os.path.join(script_abs_path+"/.env.sample") + +if os.path.exists(env_path): + load_dotenv(dotenv_path=env_path) +else: + load_dotenv(dotenv_path=default_env_path) + +tor_host = os.getenv("TOR_HOST") +tor_port = os.getenv("TOR_PORT") + #apt install python3-pandas python3-requests python3-socks def main(): @@ -36,8 +52,8 @@ def main(): return False proxies = { - 'http': 'socks5h://127.0.0.1:9050', - 'https': 'socks5h://127.0.0.1:9050' + 'http': f'{tor_host}:{tor_port}', + 'https': f'{tor_host}:{tor_port}' } instancepath=rootpath+'www/participants/'+instance+'/'