issue #36 - env variables: added the dotenv module and fixed requirements.txt

Since the .env file will be igonred you need to create a .env file in the root of the project. here are my variables TOR_HOST=socks5h://127.0.0.1 TOR_PORT=9050 WEBSOCKET_PORT=3030
This commit is contained in:
SovereigntyIsNotFreedom 2025-03-22 19:24:03 +00:00
parent 35e04b6eda
commit d952950a6c
5 changed files with 29 additions and 7 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
.git .git
www/participants/** www/participants/**
scripts/__pycache__/** scripts/__pycache__/**
.env
env/

View file

@ -1,14 +1,20 @@
from websockets.sync.client import connect from websockets.sync.client import connect
from dotenv import load_dotenv
import json import json
import random import random
import os
load_dotenv()
websocket_port = os.environ.get("WEBSOCKET_PORT")
print(websocket_port)
def is_simplex_link_valid(simplex_link: str) -> bool: 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. 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}" query = f"/c incognito {simplex_link}"
command = { command = {
'corrId': f"id{random.randint(0,999999)}", 'corrId': f"id{random.randint(0,999999)}",

View file

@ -10,3 +10,5 @@ requests==2.32.3
six==1.17.0 six==1.17.0
tzdata==2025.1 tzdata==2025.1
urllib3==2.3.0 urllib3==2.3.0
python-dotenv==1.0.1
websockets==15.0.1

View file

@ -1,4 +1,5 @@
from utils import * from utils import *
from dotenv import load_dotenv
import os, pwd import os, pwd
import pandas as pd import pandas as pd
@ -8,12 +9,17 @@ import time
import urllib import urllib
import sys import sys
load_dotenv()
tor_host = os.environ.get("TOR_HOST")
tor_port = os.environ.get("TOR_PORT")
def main(): def main():
#os.system('clear') #os.system('clear')
proxies = { proxies = {
'http': 'socks5h://127.0.0.1:9050', 'http': f'{tor_host}:{tor_port}',
'https': 'socks5h://127.0.0.1:9050' 'https': f'{tor_host}:{tor_port}'
} }
rootpath='/srv/darknet-lantern/' rootpath='/srv/darknet-lantern/'
@ -33,7 +39,7 @@ def main():
# check if the directory exists # check if the directory exists
if not os.path.isdir(participantdir): if not os.path.isdir(participantdir):
#if not, create it #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) os.makedirs(participantdir)

View file

@ -1,3 +1,5 @@
from dotenv import load_dotenv
import os,re,pwd import os,re,pwd
import csv import csv
import requests import requests
@ -5,6 +7,11 @@ import json
import pandas as pd import pandas as pd
import glob import glob
load_dotenv()
tor_host = os.environ.get("TOR_HOST")
tor_port = os.environ.get("TOR_PORT")
#apt install python3-pandas python3-requests python3-socks #apt install python3-pandas python3-requests python3-socks
def main(): def main():
@ -36,8 +43,8 @@ def main():
return False return False
proxies = { proxies = {
'http': 'socks5h://127.0.0.1:9050', 'http': f'{tor_host}:{tor_port}',
'https': 'socks5h://127.0.0.1:9050' 'https': f'{tor_host}:{tor_port}'
} }
instancepath=rootpath+'www/participants/'+instance+'/' instancepath=rootpath+'www/participants/'+instance+'/'