Skip to content

Commit

Permalink
namizun v1.2
Browse files Browse the repository at this point in the history
- in menu speed deleted and buffer size and uploader threads count added
- range_ips added (It can be customized)
  • Loading branch information
malkemit committed Dec 4, 2022
1 parent 273ce11 commit 9cac9c1
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 317 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/.git
/venv
/venv
range_ips
50 changes: 50 additions & 0 deletions else/range_ips
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
2.176.1.0
5.22.1.0
5.23.112.0
5.52.1.0
5.56.132.0
5.56.134.0
5.57.32.0
5.61.24.0
5.61.26.0
5.61.28.0
5.62.192.0
5.63.8.0
5.72.1.0
5.106.1.0
5.112.1.0
5.134.128.0
5.134.192.0
5.144.128.0
5.145.112.0
5.159.48.0
5.160.1.0
5.198.160.0
5.200.64.0
5.201.128.0
5.202.1.0
5.208.1.0
5.250.1.0
5.252.216.0
5.253.24.0
5.253.225.0
31.2.128.0
31.7.64.0
31.7.72.0
31.7.76.0
31.7.88.0
31.7.96.0
31.24.200.0
31.24.232.0
31.25.90.0
31.25.92.0
31.25.104.0
31.25.128.0
31.40.1.0
31.40.2.0
31.41.35.0
31.47.32.0
31.56.1.0
31.130.176.0
31.170.48.0
31.184.128.0
128 changes: 88 additions & 40 deletions menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,68 @@
from namizun_core.monitor import get_size
from threading import Thread
from namizun_core.monitor import monitor
from os import system, path


def running_setter():
def fake_udp__uploader_running_setter():
display.banner()
print(f"\n{display.cornsilk}Do you want uploader to be activated?")
print(f"\n{display.cornsilk}Do you want fake udp uploader to be activated?\n")
selection = input(f"\n{display.green}y{display.cornsilk}/{display.red}n{display.cornsilk}?\n")
if selection.lower() == 'y':
database.set_parameter('running', True)
database.set_parameter('fake_udp_uploader_running', True)
return main_menu()
elif selection.lower() == 'n':
database.set_parameter('running', False)
database.set_parameter('fake_udp_uploader_running', False)
return main_menu()
else:
return running_setter()
return fake_udp__uploader_running_setter()


def speed_setter():
def coefficient_of_buffer_size_setter():
display.banner()
print(f"\n{display.cornsilk}Choose upload speed? (max = 5, min = 1)\n"
f"{display.red}Warning: The higher the speed, the higher the CPU consumption{display.cornsilk}\n")
print(f"\n{display.cornsilk}Choose coefficient of buffer size? (max = 5, min = 1)\n\n"
f"{display.red}Warning: The larger the buffer size, the more likely the provider will notice that "
f"your traffic is fake, BE CAREFUL!{display.cornsilk}\n")
selection = int(input(f"\n{display.cyan}1{display.cornsilk} to {display.cyan}5{display.cornsilk}?"))
if selection in range(1, 6):
database.set_parameter('speed', selection)
database.set_parameter('coefficient_buffer_size', selection)
return main_menu()
else:
return speed_setter()
return coefficient_of_buffer_size_setter()


def coefficient_setter():
def coefficient_uploader_threads_count_setter():
display.banner()
print(f"\n{display.cornsilk}Choose coefficient of uploader threads count? (max = 25, min = 1)\n\n"
f"{display.red}Warning: The higher the speed, the higher the CPU consumption!{display.cornsilk}\n")
selection = int(input(f"\n{display.cyan}1{display.cornsilk} to {display.cyan}25{display.cornsilk}?"))
if selection in range(1, 26):
database.set_parameter('coefficient_uploader_threads_count', selection)
return main_menu()
else:
return coefficient_uploader_threads_count_setter()


def coefficient_of_limitation_setter():
display.banner()
print(f"\n{display.cornsilk}What is your limit coefficient?"
f"(max = {display.cyan}12{display.cornsilk}, min = {display.cyan}3{display.cornsilk})\n")
selection = int(input(f"\n{display.cyan}3{display.cornsilk} to {display.cyan}12{display.cornsilk}?"))
if selection in range(3, 13):
database.set_parameter('coefficient', selection)
f"(max = {display.cyan}15{display.cornsilk}, min = {display.cyan}3{display.cornsilk})\n\n"
f"For example, if you need to observe the ratio of {display.cyan}1{display.cornsilk} to "
f"{display.cyan}10{display.cornsilk}, enter the value of {display.cyan}10{display.cornsilk}")
selection = int(input(f"\n{display.cyan}3{display.cornsilk} to {display.cyan}15{display.cornsilk}?"))
if selection in range(3, 16):
database.set_parameter('coefficient_limitation', selection)
return main_menu()
else:
return coefficient_setter()
return coefficient_of_limitation_setter()


def total_upload_before_reboot_setter():
display.banner()
print(f"\n{display.cornsilk}How much did you upload before the last reboot?"
f"(max = {display.cyan}50000{display.cornsilk}GB)\n")
f"(max = {display.cyan}100000{display.cornsilk}GB)\n")
selection = int(input("\nJust enter GB amount?"))
if selection <= 50000:
if selection <= 100000:
database.set_parameter('total_upload_before_reboot', selection * 1024 * 1024 * 1024)
return main_menu()
else:
Expand All @@ -58,57 +74,89 @@ def total_upload_before_reboot_setter():
def total_download_before_reboot_setter():
display.banner()
print(f"\n{display.cornsilk}How much did you download before the last reboot?"
f"(max = {display.cyan}5000{display.cornsilk}GB)\n")
f"(max = {display.cyan}10000{display.cornsilk}GB)\n")
selection = int(input("\nJust enter GB amount?"))
if selection <= 5000:
if selection <= 10000:
database.set_parameter('total_download_before_reboot', selection * 1024 * 1024 * 1024)
return main_menu()
else:
return total_download_before_reboot_setter()


def running_status():
if database.get_parameter('running'):
def reload_namizun_service():
if path.isfile('range_ips'):
database.set_parameter('range_ips', open('range_ips').read())
else:
system('ln -s /var/www/namizun/else/range_ips /var/www/namizun/range_ips')
database.set_parameter('range_ips', open('range_ips').read())
system('systemctl restart namizun.service')


def fake_udp_uploader_running_status():
if database.get_parameter('fake_udp_uploader_running'):
return display.green + "True"
else:
return display.red + "False"


def speedtest_uploader_running_status():
if database.get_parameter('speedtest_uploader_running'):
return display.green + "True"
else:
return display.red + "False"


def main_menu():
sleep(0.5)
display.banner()
database.set_parameter('in_submenu', False)
print(
f"\n{display.gold}--------------{display.magenta}Control menu{display.gold}-------------\n\n{display.cornsilk}"
f"[1] - Uploader Running : {running_status() + display.cornsilk}\n"
f"[2] - Speed : {display.cyan + str(database.get_parameter('speed')) + display.cornsilk}\n"
f"[3] - Coefficient : {display.cyan + str(database.get_parameter('coefficient')) + display.cornsilk}\n"
f"[4] - Total Upload Before Reboot : "
f"\n\n\n\n\n\n\n"
f"{display.gold}--------------{display.magenta}Control menu{display.gold}-------------\n\n{display.cornsilk}"
f"[1] - Fake udp uploader running : "
f"{fake_udp_uploader_running_status() + display.cornsilk}\n"
f"[2] - Speedtest uploader running : "
f"{speedtest_uploader_running_status() + display.cornsilk} (coming soon)\n\n"
f"[3] - Coefficient of buffer size : "
f"{display.cyan + str(database.get_parameter('coefficient_buffer_size')) + display.cornsilk}\n"
f"[4] - Coefficient of uploader threads count : "
f"{display.cyan + str(database.get_parameter('coefficient_uploader_threads_count')) + display.cornsilk}\n"
f"[5] - Coefficient of upload/download : "
f"{display.cyan + str(database.get_parameter('coefficient_limitation')) + display.cornsilk}\n\n"
f"[6] - Total Upload Before Reboot : "
f"{display.cyan + str(get_size(database.get_parameter('total_upload_before_reboot'))) + display.cornsilk}\n"
f"[5] - Total Download Before Reboot : "
f"[7] - Total Download Before Reboot : "
f"{display.cyan + str(get_size(database.get_parameter('total_download_before_reboot'))) + display.cornsilk}\n\n"
f"[9] - Reload\n"
f"[0] - Exit\n\n"
f"ENTER YOUR SELECTION: \n\n")
display.description()
display.line_jumper(-9)
user_choice = int(input())
if user_choice == 1:
user_choice = input()
if user_choice == '1':
database.set_parameter('in_submenu', True)
return running_setter()
elif user_choice == 2:
return fake_udp__uploader_running_setter()
elif user_choice == '3':
database.set_parameter('in_submenu', True)
return speed_setter()
elif user_choice == 3:
return coefficient_of_buffer_size_setter()
elif user_choice == '4':
database.set_parameter('in_submenu', True)
return coefficient_setter()
elif user_choice == 4:
return coefficient_uploader_threads_count_setter()
elif user_choice == '5':
database.set_parameter('in_submenu', True)
return coefficient_of_limitation_setter()
elif user_choice == '6':
database.set_parameter('in_submenu', True)
return total_upload_before_reboot_setter()
elif user_choice == 5:
elif user_choice == '7':
database.set_parameter('in_submenu', True)
return total_download_before_reboot_setter()
elif user_choice == 0:
elif user_choice == '9':
reload_namizun_service()
return main_menu()
elif user_choice == '0':
database.set_parameter('in_submenu', None)
return print(display.reset) + exit()
print(display.reset)
return exit()
else:
return main_menu()

Expand Down
3 changes: 1 addition & 2 deletions namizun_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .database import get_parameter, set_parameter, get_cache_parameter, set_parameters_to_cache
from .database import get_parameter, set_parameter, get_cache_parameter, set_parameters_to_cache, get_random_range_ip
from .display import cornsilk, cyan, gold, green, magenta, red, reset, yellow, \
clear, line_remover, line_jumper, banner, description
from .ip import ips
from .monitor import get_size, get_network_io, monitor
from .udp import multi_udp_uploader
37 changes: 28 additions & 9 deletions namizun_core/database.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import redis
from redis import Redis
from os import system, path
from random import choice

parameters = [
'running', 'speed', 'coefficient', 'total_upload_before_reboot', 'total_download_before_reboot', 'in_submenu']
'range_ips', 'fake_udp_uploader_running', 'speedtest_uploader_running',
'coefficient_buffer_size', 'coefficient_uploader_threads_count', 'coefficient_limitation',
'total_upload_before_reboot', 'total_download_before_reboot', 'in_submenu']
namizun_db = None
prefix = 'namizun_'

cache_parameters = {}


def singleton():
global namizun_db
if namizun_db is None:
namizun_db = redis.Redis()
namizun_db = Redis()
return namizun_db


def get_default(key):
if key == 'running':
if key == 'range_ips':
if path.isfile('range_ips'):
return open('range_ips').read()
else:
system('ln -s /var/www/namizun/else/range_ips /var/www/namizun/')
return get_default(key)
elif key == 'fake_udp_uploader_running':
return True
elif key == 'speed':
return 3
elif key == 'coefficient':
elif key == 'speedtest_uploader_running':
return False
elif key == 'coefficient_buffer_size':
return 2
elif key == 'coefficient_uploader_threads_count':
return 5
elif key == 'coefficient_limitation':
return 10
elif key == 'total_upload_before_reboot':
return 0
Expand All @@ -39,8 +52,10 @@ def check_datatype(value):
return True
elif value == 'None':
return None
else:
elif value.isdigit():
return int(value)
else:
return value


def get_parameter(key):
Expand Down Expand Up @@ -73,3 +88,7 @@ def get_cache_parameter(key):
def set_parameters_to_cache():
for key in parameters:
cache_parameters[key] = get_parameter(key)


def get_random_range_ip():
return choice(get_cache_parameter('range_ips').split('\n'))
Loading

0 comments on commit 9cac9c1

Please sign in to comment.