-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftp_config.py
executable file
·56 lines (48 loc) · 1.56 KB
/
ftp_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
import os
import sys
folder_path = os.path.dirname(os.path.abspath(__file__))
if not os.path.exists("ftp_secret.py"):
with open("ftp_secret.py", 'w+') as f:
print("DATABASE_URL_ASYNC = 'postgresql+asyncpg://<database username>:<password>@localhost:5432/<db_name>'", file=f)
print("Please, edit ftp_secret.py")
exit(0)
else:
from ftp_secret import DATABASE_URL_ASYNC
DEFAULT_CONFIG = {
"ftp_hub": {
"output_folder": f"{folder_path}/output/",
"input_folder": f"{folder_path}/input/",
"ranges": f"./ranges.txt",
"crack_file": "./ftp_default_user_pass_list.txt",
"old_delay_days": 7,
"color_output": True
},
"ftp_forest": {
"save_trees": True,
"connect_timeout": 30,
"forest_timeout": 3600, #hour
"max_workers": 300,
"max_tree_level": 50,
"quiet": False
},
"ftp_db": {
"DATABASE_URL_ASYNC": DATABASE_URL_ASYNC,
"db_path": f"{folder_path}/ftp_hub.db"
}
}
global CONFIG
def generate_default():
with open("config.json", 'w') as f:
json.dump(CONFIG, f, indent=4)
def load_config(config_file="config.json"):
global CONFIG
CONFIG = DEFAULT_CONFIG.copy()
if os.path.exists(config_file):
with open(config_file, 'r') as f:
file_config = json.load(f)
CONFIG.update(file_config)
load_config()
if __name__ == "__main__":
if '--generate_default' in sys.argv:
generate_default()