MCPcopy Create free account
hub / github.com/code3-dev/dengvpn / disableSystemProxy

Function disableSystemProxy

main.js:620–717  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

618
619// Function to disable system proxy (run as admin)
620function disableSystemProxy() {
621 try {
622 // Check if the script file exists
623 if (!fs.existsSync(disableProxyScriptPath)) {
624 console.error(`Disable proxy script file not found at: ${disableProxyScriptPath}`);
625
626 // Create the script file in the core directory if it doesn't exist
627 const corePath = getResourcePath('core');
628 if (!fs.existsSync(corePath)) {
629 fs.mkdirSync(corePath, { recursive: true });
630 }
631
632 if (isWindows) {
633 const disableBatContent = `@echo off
634REM Script to disable Windows system proxy
635REM This script needs to be run as administrator
636
637REM Disable system proxy
638reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
639reg delete "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyServer /f 2>nul
640reg delete "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyOverride /f 2>nul
641
642REM Notify user
643echo Windows system proxy has been disabled.
644echo.
645echo This window will close in 3 seconds...
646timeout /t 3 > nul`;
647
648 fs.writeFileSync(disableProxyScriptPath, disableBatContent);
649 console.log(`Created disable proxy BAT file at: ${disableProxyScriptPath}`);
650 } else if (isLinux) {
651 const disableShContent = `#!/bin/bash
652# Script to disable system proxy on Linux
653# This script may need to be run with sudo privileges depending on your desktop environment
654
655# Check if script is run as root
656if [ "$EUID" -ne 0 ]; then
657 echo "This script may need to be run with sudo privileges depending on your desktop environment"
658fi
659
660# Disable system proxy for GNOME
661gsettings set org.gnome.system.proxy mode 'none' 2>/dev/null
662gsettings reset org.gnome.system.proxy.http host 2>/dev/null
663gsettings reset org.gnome.system.proxy.http port 2>/dev/null
664gsettings reset org.gnome.system.proxy.https host 2>/dev/null
665gsettings reset org.gnome.system.proxy.https port 2>/dev/null
666
667# Disable system proxy for KDE (if kwriteconfig5 is available)
668if command -v kwriteconfig5 &> /dev/null; then
669 kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType 0 2>/dev/null
670 kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key httpProxy --delete 2>/dev/null
671 kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key httpsProxy --delete 2>/dev/null
672fi
673
674# Also unset environment variables that might be set
675unset http_proxy
676unset https_proxy
677unset ftp_proxy

Callers 2

stopV2rayFunction · 0.85
main.jsFile · 0.85

Calls 1

getResourcePathFunction · 0.85

Tested by

no test coverage detected