├── .gitignore ├── Program.cs ├── ProxyToggle.csproj ├── ProxyToggle.exe ├── README.md └── node-web-proxy ├── bin └── ProxyToggle.exe ├── main.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | bin 3 | obj -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Runtime.InteropServices; 5 | using Microsoft.Win32; 6 | 7 | namespace ProxyToggle 8 | { 9 | 10 | class Program 11 | { 12 | 13 | [DllImport("wininet.dll")] 14 | public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength); 15 | public const int INTERNET_OPTION_SETTINGS_CHANGED = 39; 16 | public const int INTERNET_OPTION_REFRESH = 37; 17 | 18 | 19 | static void setProxy(string proxyhost, bool proxyEnabled) 20 | { 21 | const string userRoot = "HKEY_CURRENT_USER"; 22 | const string subkey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; 23 | const string keyName = userRoot + "\\" + subkey; 24 | 25 | Registry.SetValue(keyName, "ProxyServer", proxyhost); 26 | Console.Error.WriteLine("ProxyServer set to '{0}'", proxyhost); 27 | Registry.SetValue(keyName, "ProxyEnable", proxyEnabled ? 1 : 0); 28 | Console.Error.WriteLine("ProxyEnable set to '{0}'", proxyEnabled ? 1 : 0); 29 | 30 | // These lines implement the Interface in the beginning of program 31 | // They cause the OS to refresh the settings, causing IP to realy update 32 | InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0); 33 | InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0); 34 | } 35 | 36 | static void Main(string[] args) 37 | { 38 | if (args.Length == 0) 39 | { 40 | setProxy("", false); 41 | return; 42 | } 43 | 44 | setProxy(args[0], true); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ProxyToggle.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {43BEB03F-12EC-4A82-BC7D-F03D9BC1AA2F} 9 | Exe 10 | Properties 11 | ProxyToggle 12 | ProxyToggle 13 | v2.0 14 | 512 15 | 16 | 17 | x86 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | x86 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /ProxyToggle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repository-vault/proxytoggle/007a2210e85b70f4cb00fe38549347d46a22ae49/ProxyToggle.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Proxy toggle 2 | Allows you to activate / deactivate system wide proxy configuration for windows (xp/7/ ??) 3 | * no administrator access required (10 lines of code) 4 | 5 | # Usage (nodejs npm) 6 | ## Install the module 7 | 8 | ```npm install node-web-proxy``` 9 | 10 | ## Example 11 | ``` 12 | var proxy = require('node-web-proxy'); 13 | 14 | if(false) proxy.disable(function(){ 15 | console.log("Proxy disabed"); 16 | }); 17 | 18 | proxy.enable("socks=127.0.0.1:8080", function(){ 19 | console.log("Proxy enabled"); 20 | }); 21 | ``` 22 | 23 | 24 | # Usage (cli) 25 | 26 | ## disable current proxy 27 | ```R:\> ProxyToggle ``` 28 | 29 | ## Activate http proxy 30 | ```R:\> ProxyToggle.exe http=127.0.0.1:8080``` 31 | 32 | 33 | ## Activate socks proxy 34 | ```R:\> ProxyToggle.exe socks=127.0.0.1:8080``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /node-web-proxy/bin/ProxyToggle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repository-vault/proxytoggle/007a2210e85b70f4cb00fe38549347d46a22ae49/node-web-proxy/bin/ProxyToggle.exe -------------------------------------------------------------------------------- /node-web-proxy/main.js: -------------------------------------------------------------------------------- 1 | var cp = require('child_process'); 2 | 3 | 4 | var _exec = function(args, cb){ 5 | cp.exec("ProxyToggle.exe " + args, {cwd:__dirname + "/bin"}, function (error, stdout, stderr) { 6 | if (error !== null) 7 | throw ('exec error: ' + error); 8 | cb(); 9 | }) 10 | }; 11 | 12 | var Proxy = { 13 | disable : function(cb){ 14 | _exec("", cb); 15 | }, 16 | 17 | enable : function(proxyString, cb){ 18 | _exec(proxyString, cb); 19 | }, 20 | 21 | }; 22 | 23 | module.exports = Proxy; -------------------------------------------------------------------------------- /node-web-proxy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-web-proxy", 3 | "version": "0.0.0", 4 | "description": "System wide proxy management tool", 5 | "main": "main.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:131/proxytoggle.git" 12 | }, 13 | "keywords": [ 14 | "node-webkit", 15 | "proxy" 16 | ], 17 | "author": "Francois Leurent <131.php@cloudyks.org>", 18 | "license": "BSD-2-Clause", 19 | "bugs": { 20 | "url": "https://github.com/131/proxytoggle/issues" 21 | } 22 | } 23 | --------------------------------------------------------------------------------