83 lines
1.9 KiB
Python
83 lines
1.9 KiB
Python
import src.tools as tools
|
|
import src.monitor as monitor
|
|
import src.proxy as proxy
|
|
|
|
import os
|
|
import glob
|
|
import json
|
|
from dotenv import load_dotenv
|
|
from colorama import Style, Fore, init
|
|
|
|
|
|
def initialize():
|
|
|
|
# Init Environment
|
|
load_dotenv()
|
|
|
|
# Init Colorama
|
|
init(autoreset=True)
|
|
|
|
|
|
def readsites(sitepath=None):
|
|
print(f"{tools.heading('Checking Sitedata')}\n{tools.spacer}")
|
|
|
|
dod = {}
|
|
if sitepath:
|
|
sitedir = sitepath
|
|
else:
|
|
rootdir = os.path.dirname(os.path.abspath(__file__))
|
|
sitedir = rootdir + r"\sites"
|
|
|
|
for sitefile in glob.glob(sitedir + r"\*.json"):
|
|
sfn = os.path.basename(sitefile)
|
|
site, ext = os.path.splitext(sfn)
|
|
print(f"> {sfn}", end=" | ")
|
|
with open(sitefile, 'r') as f:
|
|
data = json.load(f)
|
|
print(f"data:{data}")
|
|
dod[site] = data
|
|
|
|
# print(f"DEBUG: {dod}")
|
|
|
|
print(tools.spacer)
|
|
|
|
|
|
def proxytest():
|
|
print(f"{tools.heading('Creating Proxy(s)')}\n{tools.spacer}")
|
|
|
|
one = proxy.Proxy(
|
|
name="One",
|
|
url=os.getenv("PROXYURL"),
|
|
port=os.getenv("PROXYPORT"),
|
|
usr=os.getenv("PROXYUSR"),
|
|
pwd=os.getenv("PROXYPW")
|
|
)
|
|
print(f"> {Fore.MAGENTA}{one.name}{Style.RESET_ALL} |"
|
|
f" {tools.keyword('PROXYIP')}({one.ip}) {tools.keyword('WORKING')}({one.isworking})")
|
|
|
|
# one.testurl("http://www.whatismyproxy.com/")
|
|
|
|
print(tools.spacer)
|
|
|
|
|
|
def monitortest(n=1):
|
|
print(f"{tools.heading(f'Creating Monitor(s)')}\n{tools.spacer}")
|
|
|
|
for i in range(0, n):
|
|
mon = monitor.Monitor()
|
|
mon.name = f"Monitor {i}"
|
|
mon.url = "test"
|
|
print(f"> {Fore.MAGENTA}{mon.name}{Style.RESET_ALL} |"
|
|
f" {tools.keyword('URL')}({mon.url}) {tools.keyword('PROXY')}({mon.proxy})")
|
|
|
|
print(tools.spacer)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
tools.clear()
|
|
initialize()
|
|
readsites()
|
|
proxytest()
|
|
monitortest()
|