A Golang-based Windows application to switch proxy settings
Go to file
2024-10-28 21:25:16 +01:00
.github bugfix: copy entire configs directory to build output 2024-09-24 15:52:44 +02:00
assets moved icons to assets 2024-08-30 18:11:21 +02:00
cmd bugfix: added user input for confirming new config 2024-09-24 15:24:17 +02:00
configs added pip proxy configuration 2024-09-24 15:42:03 +02:00
proxy add build constraint for windows OS where necessary 2024-10-28 21:25:16 +01:00
util saving new config file only, use name.json as filename 2024-09-24 15:25:11 +02:00
.gitignore ignore build output, see CICD 2024-09-24 15:54:48 +02:00
go.mod explicitly require golang sys package for registry 2024-09-01 12:48:31 +02:00
go.sum reading and setting system proxy 2024-08-31 18:26:24 +02:00
install.ps1 Merge pull request #17 from Baipyrus/fix-path-variable 2024-09-23 18:58:32 +02:00
LICENSE Initial commit 2024-08-29 22:54:40 +02:00
main.go initialize cobra-cli 2024-08-29 23:06:10 +02:00
README.md Updated README in regards to #2 and #6 2024-10-01 20:39:14 +02:00
run.ps1 bugfix: using executable instead of go runtime 2024-09-02 09:43:27 +02:00

ProxySwitcher

ProxySwitcher is a Golang-based Windows application that allows you to easily switch internet proxy settings for various programs including the system settings. The application provides a command-line interface (CLI) through the usage of a library called cobra. This CLI then provides commands to set, unset, and save proxy configurations, as well as a system tray icon for quick access to settings and toggling proxies.

Features

  • Switch internet proxy settings for various applications and the system.
  • Manage configurations through a configs.json file.
  • Command-line interface with commands like set, unset, and save.
  • System tray icon with options to enable and disable proxies, open settings, save configurations, or exit the application.

Installation

You should download the latest release archive, extract all contents to a dedicated directory and then simply execute the .\install.ps1 script within a Windows Powershell.

Alternatively, you could simply run the following command in a Windows PowerShell:

# Using 'Invoke-RestMethod' and 'Invoke-Expression'
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1' | iex

Usage

Generally, the Installation step will install both the program, its assets, and a shortcut for the Windows Startmenu for your current userprofile. Additionally, the program will also be added to the user's %PATH% Variable and will this be executable from within the command-line. However, you will either need to navigate into the program directory (C:\Users\[Username]\AppData\Local\Programs\ProxySwitcher\) manually or specify a path to any directory containing configuration files using the flag -c, --configs string configurations path (default "configs/"). To keep it simple, it is still recommended to use the program in system tray or directly via code. This latter option will be explained next:

  • Clone the repository:

    git clone https://github.com/Baipyrus/ProxySwitcher.git
    

CLI Commands

  • set: Enable all saved proxies including system proxy.

    # .\ProxySwitcher.exe set
    go run . set
    
  • unset: Disable all saved proxies including system proxy.

    # .\ProxySwitcher.exe unset
    go run . unset
    
  • save: Saves a new configuration to set a proxy for.

    # .\ProxySwitcher.exe save
    go run . save
    
  • debug: Prints all proxy configurations after generating corresponding commands.

    # .\ProxySwitcher.exe debug
    go run . save
    

Configuration

The programs for which the proxy settings should be managed are stored in configs/, wherein you can then create a JSON file per command group. These files can easily be modified directly or generated through the save command. For examples, please take a look at the default config or at the following block:

[
    {
        "name": "test1", // Default CMD Name
        "cmd": "echo 'Hello, World!'", // Optional
        "set": [
            {
                "args": [
                    "http"
                ], // Optionally empty
                "type": "text" // Default; Optional
                "equator": " " // Default; Optional
            }, // Writes "echo 'Hello, World!' http ", followed
               // by your system proxy, to a powershell process.
            {
                "args": [
                    "https"
                ], // Optionally empty
                "equator": "=" // Optional
            }  // Writes "echo 'Hello, World!' https=", followed
               // by your system proxy, to a powershell process.
        ], // Optional
        "unset": []
        // "unset" has the contents as "set" above
        // and it is also optional.
    }, {
        "name": "test2", // Default CMD Name
        "cmd": "echo '$PRSW_ARG $PRSW_ARG'", // Optional
        "set": [
            {
                "args": [
                    "https"
                ], // Optionally empty
                "type": "variable" // Optional
            }  // Writes "echo 'https <Your System Proxy>'"
               // to a powershell process.
        ] // Optional
    }
]

System Tray Icon

Right-click the system tray icon to:

  • Properties: View and modify system proxy settings.
  • Enable Proxy: Enable all saved proxies including system proxy.
  • Disable Proxy: Disable all saved proxies including system proxy.
  • Save New Config: Open a prompt to save a new proxy configuration.
  • Exit: Close the application.

Building

  1. Clone the repository as seen above in Usage

  2. Run the following command:

    GOOS=windows GOARCH=amd64 go build -o build/ -v ./...