MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / network_enable_vpn

Function network_enable_vpn

Scripts/Settings.py:7430–7459  ·  view source on GitHub ↗
(force_refresh=False)

Source from the content-addressed store, hash-verified

7428 os.makedirs(DEDSEC_OS_RUNTIME_DIR, exist_ok=True)
7429 if not os.path.exists(DEDSEC_OS_CONFIG_PATH):
7430 with open(DEDSEC_OS_CONFIG_PATH, 'w', encoding='utf-8') as handle:
7431 json.dump({'display_name': get_user(), 'wallpaper': '', 'wallpaper_name': '', 'terminal_theme': 'dedsec', 'login_enabled': False, 'password_hash': '', 'totp_enabled': False, 'totp_secret': '', 'security_questions': []}, handle, indent=4, ensure_ascii=False)
7432 server_source = dedsec_os_server_source()
7433 with open(DEDSEC_OS_SERVER_PATH, 'w', encoding='utf-8') as handle:
7434 handle.write(server_source)
7435 os.chmod(DEDSEC_OS_SERVER_PATH, 0o700)
7436 return DEDSEC_OS_SERVER_PATH
7437
7438
7439def find_free_local_port(start_port=DEDSEC_OS_DEFAULT_PORT, end_port=18949):
7440 for port in range(start_port, end_port + 1):
7441 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
7442 sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
7443 if sock.connect_ex(('127.0.0.1', port)) != 0:
7444 return port
7445 raise RuntimeError('No free local port available for DedSec OS.')
7446
7447
7448def is_port_listening(port):
7449 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
7450 sock.settimeout(0.5)
7451 return sock.connect_ex(('127.0.0.1', port)) == 0
7452
7453
7454def open_local_url(url):
7455 commands = []
7456 if shutil.which('termux-open-url'):
7457 commands.append(['termux-open-url', url])
7458 if shutil.which('am') or os.path.exists('/system/bin/am'):
7459 am_bin = shutil.which('am') or '/system/bin/am'
7460 commands.append([am_bin, 'start', '--user', '0', '-a', 'android.intent.action.VIEW', '-d', url])
7461 if shutil.which('xdg-open'):
7462 commands.append(['xdg-open', url])

Callers 4

network_utilities_menuFunction · 0.70

Calls 7

printFunction · 0.85
network_load_configFunction · 0.70
network_save_configFunction · 0.70
_Function · 0.70

Tested by

no test coverage detected