mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
Compare commits
6 Commits
36aef5e0d3
...
3690f58d15
Author | SHA1 | Date | |
---|---|---|---|
|
3690f58d15 | ||
|
5008813e5a | ||
|
ff25926e0f | ||
|
e2451a3197 | ||
|
2f23a36517 | ||
|
bfb40684ee |
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "gomod" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
96
.github/workflows/codeql.yml
vendored
Normal file
96
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL Advanced"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "*" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
schedule:
|
||||||
|
- cron: '17 8 * * 2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze (${{ matrix.language }})
|
||||||
|
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||||
|
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||||
|
# - https://gh.io/supported-runners-and-hardware-resources
|
||||||
|
# - https://gh.io/using-larger-runners (GitHub.com only)
|
||||||
|
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
||||||
|
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
||||||
|
permissions:
|
||||||
|
# required for all workflows
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
# required to fetch internal or private CodeQL packs
|
||||||
|
packages: read
|
||||||
|
|
||||||
|
# only required for workflows in private repositories
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
# Required build flags for this project
|
||||||
|
env:
|
||||||
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- language: go
|
||||||
|
build-mode: autobuild
|
||||||
|
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
|
||||||
|
# Use `c-cpp` to analyze code written in C, C++ or both
|
||||||
|
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
||||||
|
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
||||||
|
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
||||||
|
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
||||||
|
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
||||||
|
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
build-mode: ${{ matrix.build-mode }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
|
||||||
|
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||||
|
# queries: security-extended,security-and-quality
|
||||||
|
|
||||||
|
# If the analyze step fails for one of the languages you are analyzing with
|
||||||
|
# "We were unable to automatically build your code", modify the matrix above
|
||||||
|
# to set the build mode to "manual" for that language. Then modify this step
|
||||||
|
# to build your code.
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||||
|
- if: matrix.build-mode == 'manual'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo 'If you are using a "manual" build mode for one or more of the' \
|
||||||
|
'languages you are analyzing, replace this with the commands to build' \
|
||||||
|
'your code, for example:'
|
||||||
|
echo ' make bootstrap'
|
||||||
|
echo ' make release'
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
|
with:
|
||||||
|
category: "/language:${{matrix.language}}"
|
142
README.md
142
README.md
@ -10,35 +10,40 @@ access to settings and toggling proxies.
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Switch internet proxy settings for various applications and the system.
|
- Switch internet proxy settings for various applications and the system.
|
||||||
- Manage configurations through a `configs.json` file.
|
- Configuration files stored in `configs/` for better organization and flexibility.
|
||||||
- Command-line interface with commands like `set`, `unset`, and `save`.
|
- CLI commands (`set`, `unset`, `save`, `debug`) for managing proxy settings.
|
||||||
- System tray icon with options to enable and disable proxies, open settings,
|
- System tray icon for fast access to all functionality.
|
||||||
save configurations, or exit the application.
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
You should download the [latest release](https://github.com/Baipyrus/ProxySwitcher/releases)
|
This project offers two installation methods: via PowerShell or manually. In the
|
||||||
archive, **extract all contents** to a dedicated directory and then simply execute
|
end, you will always be using the [`.\install.ps1`](./install.ps1) script which will
|
||||||
the [`.\install.ps1`](./install.ps1) script within a Windows Powershell.
|
automatically download the Project if necessary and adds it to `%PATH%`. All contents
|
||||||
|
will then be installed to `%LOCALAPPDATA%/Programs` for a user installation.
|
||||||
|
|
||||||
Alternatively, you could simply run the following command in a Windows PowerShell:
|
### PowerShell Installation
|
||||||
|
|
||||||
|
Run the following command in Windows PowerShell:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# Using 'Invoke-RestMethod' and 'Invoke-Expression'
|
|
||||||
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1' | iex
|
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1' | iex
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Manual Installation
|
||||||
|
|
||||||
|
1. Download the [latest release](https://github.com/Baipyrus/ProxySwitcher/releases).
|
||||||
|
2. Extract the archive to somewhere accessible to your user.
|
||||||
|
3. Run the [`.\install.ps1`](./install.ps1) script within a Windows Powershell instance.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Generally, the [Installation](#installation) step will install both the program,
|
First, you will either need to navigate into the program directory (`C:\Users\[Username]\AppData\Local\Programs\ProxySwitcher\`)
|
||||||
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
|
manually or specify a path to any directory containing configuration files using
|
||||||
the flag `-c, --configs string configurations path (default "configs/")`.
|
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
|
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:
|
directly via code.
|
||||||
|
|
||||||
|
In case you want to run the code directly:
|
||||||
|
|
||||||
- Clone the repository:
|
- Clone the repository:
|
||||||
|
|
||||||
@ -51,83 +56,87 @@ directly via code. This latter option will be explained next:
|
|||||||
- **set**: Enable all saved proxies including system proxy.
|
- **set**: Enable all saved proxies including system proxy.
|
||||||
|
|
||||||
```powersell
|
```powersell
|
||||||
# .\ProxySwitcher.exe set
|
# ProxySwitcher.exe set
|
||||||
go run . set
|
go run . set
|
||||||
```
|
```
|
||||||
|
|
||||||
- **unset**: Disable all saved proxies including system proxy.
|
- **unset**: Disable all saved proxies including system proxy.
|
||||||
|
|
||||||
```powersell
|
```powersell
|
||||||
# .\ProxySwitcher.exe unset
|
# ProxySwitcher.exe unset
|
||||||
go run . unset
|
go run . unset
|
||||||
```
|
```
|
||||||
|
|
||||||
- **save**: Saves a new configuration to set a proxy for.
|
- **save**: Saves a new configuration to set a proxy for.
|
||||||
|
|
||||||
```powersell
|
```powersell
|
||||||
# .\ProxySwitcher.exe save
|
# ProxySwitcher.exe save
|
||||||
go run . save
|
go run . save
|
||||||
```
|
```
|
||||||
|
|
||||||
- **debug**: Prints all proxy configurations after generating corresponding commands.
|
- **debug**: Prints all proxy configurations after generating corresponding commands.
|
||||||
|
|
||||||
```powersell
|
```powersell
|
||||||
# .\ProxySwitcher.exe debug
|
# ProxySwitcher.exe debug
|
||||||
go run . save
|
go run . save
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
The programs for which the proxy settings should be managed are stored in [`configs/`](https://github.com/Baipyrus/ProxySwitcher/tree/main/configs),
|
Proxy configurations are organized within the [`configs/`](https://github.com/Baipyrus/ProxySwitcher/tree/main/configs),
|
||||||
wherein you can then create a JSON file per command group. These files can easily
|
directory, with each JSON file representing a configuration for a specific command
|
||||||
be modified directly or generated through the `save` command. For examples,
|
group. You can modify or add your own configurations in any JSON file in this directory
|
||||||
please take a look at the [default config](https://github.com/Baipyrus/ProxySwitcher/tree/main/configs)
|
directly, or you could use the `save` command in a CLI to save settings for you.
|
||||||
or at the following block:
|
For examples configurations, please take a look at the [default config](https://github.com/Baipyrus/ProxySwitcher/tree/main/configs).
|
||||||
|
|
||||||
|
#### Structure
|
||||||
|
|
||||||
|
Any of these JSON files are used to build commands that the program can run to `set`
|
||||||
|
and `unset` the proxy configuration of other programs. The system proxy will be set
|
||||||
|
automatically upon calling the respective commands. The actual proxy address and
|
||||||
|
port will be automatically detected from your system settings, if available.
|
||||||
|
|
||||||
|
Once in one of these JSON files, you will need to create an object (`{}`) with the
|
||||||
|
following properties:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
// Either "name" or "cmd" or both is required:
|
||||||
|
"name": "npm",
|
||||||
|
// Use a custom '$PRSW_ARG' variable to inject
|
||||||
|
// arguments into "cmd" at given positions:
|
||||||
|
// "cmd": "npm",
|
||||||
|
|
||||||
```js
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "test1", // Default CMD Name
|
|
||||||
"cmd": "echo 'Hello, World!'", // Optional
|
|
||||||
"set": [
|
"set": [
|
||||||
{
|
{
|
||||||
"args": [
|
"args": [
|
||||||
"http"
|
"config",
|
||||||
], // Optionally empty
|
"set",
|
||||||
"type": "text" // Default; Optional
|
"proxy"
|
||||||
"equator": " " // Default; Optional
|
],
|
||||||
}, // Writes "echo 'Hello, World!' http ", followed
|
// Optionally specify a separator between the
|
||||||
// by your system proxy, to a powershell process.
|
// last argument and the injected proxy string:
|
||||||
{
|
"equator": "=", // Default: " "
|
||||||
"args": [
|
// Optionally specify a surrounding character
|
||||||
"https"
|
// for injected proxy string:
|
||||||
], // Optionally empty
|
"surround": "\"",
|
||||||
"equator": "=" // Optional
|
// Optionally specify the type of command. If
|
||||||
} // Writes "echo 'Hello, World!' https=", followed
|
// using '$PRSW_ARG' in "cmd", set to "variable".
|
||||||
// by your system proxy, to a powershell process.
|
"type": "variable", // Default: "text"
|
||||||
], // Optional
|
// Optionally choose to skip injecting the
|
||||||
"unset": []
|
// proxy string for pre-config commands.
|
||||||
// "unset" has the contents as "set" above
|
"discard": "true" // Default: "false"
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
|
||||||
|
// Use the same structure as "set":
|
||||||
|
"unset" []
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### System Tray Icon
|
### System Tray Icon
|
||||||
|
|
||||||
Right-click the system tray icon to:
|
The system tray icon provides a context menu for all commands:
|
||||||
|
|
||||||
- **Properties**: View and modify system proxy settings.
|
- **Properties**: View and modify system proxy settings.
|
||||||
- **Enable Proxy**: Enable all saved proxies including system proxy.
|
- **Enable Proxy**: Enable all saved proxies including system proxy.
|
||||||
@ -138,8 +147,17 @@ Right-click the system tray icon to:
|
|||||||
## Building
|
## Building
|
||||||
|
|
||||||
1. Clone the repository as seen above in [Usage](#usage)
|
1. Clone the repository as seen above in [Usage](#usage)
|
||||||
2. Run the following command:
|
2. If running on Windows Subsystem for Linux:
|
||||||
|
- Set environment variables to build for windows:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GOOS=windows
|
||||||
|
GOARCH=amd64
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run the following command:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
GOOS=windows GOARCH=amd64 go build -o build/ -v ./...
|
# Remove-Item -Recurse -Force -ErrorAction SilentlyContinue build/
|
||||||
|
go build -o build/ -v ./...
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user