diff --git a/README.md b/README.md index 11fc3de..85c9693 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,12 @@ In single node (self hosted) Pangolin deployments this can be bypassed by using ## CLI Args +Important: - `reachableAt`: How should the remote server reach Gerbil's API? - `generateAndSaveKeyTo`: Where to save the generated WireGuard private key to persist across restarts. -- `remoteConfig` (optional): Remote config location to HTTP get the JSON based config from. See `example_config.json` -- `config` (optional): Local JSON file path to load config. Used if remote config is not supplied. See `example_config.json` - -Note: You must use either `config` or `remoteConfig` to configure WireGuard. +- `remoteConfig`: Remote config location to HTTP get the JSON based config from. +Others: - `reportBandwidthTo` (optional): **DEPRECATED** - Use `remoteConfig` instead. Remote HTTP endpoint to send peer bandwidth data - `interface` (optional): Name of the WireGuard interface created by Gerbil. Default: `wg0` - `listen` (optional): Port to listen on for HTTP server. Default: `:3004` @@ -66,7 +65,6 @@ Note: You must use either `config` or `remoteConfig` to configure WireGuard. All CLI arguments can also be provided via environment variables: - `INTERFACE`: Name of the WireGuard interface -- `CONFIG`: Path to local configuration file - `REMOTE_CONFIG`: URL of the remote config server - `LISTEN`: Address to listen on for HTTP server - `GENERATE_AND_SAVE_KEY_TO`: Path to save generated private key diff --git a/config_example.json b/config_example.json deleted file mode 100644 index 4b20271..0000000 --- a/config_example.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "privateKey": "kBGTgk7c+zncEEoSnMl+jsLjVh5ZVoL/HwBSQem+d1M=", - "listenPort": 51820, - "ipAddress": "10.0.0.1/24", - "peers": [ - { - "publicKey": "5UzzoeveFVSzuqK3nTMS5bA1jIMs1fQffVQzJ8MXUQM=", - "allowedIps": ["10.0.0.0/28"] - }, - { - "publicKey": "kYrZpuO2NsrFoBh1GMNgkhd1i9Rgtu1rAjbJ7qsfngU=", - "allowedIps": ["10.0.0.16/28"] - }, - { - "publicKey": "1YfPUVr9ZF4zehkbI2BQhCxaRLz+Vtwa4vJwH+mpK0A=", - "allowedIps": ["10.0.0.32/28"] - }, - { - "publicKey": "2/U4oyZ+sai336Dal/yExCphL8AxyqvIxMk4qsUy4iI=", - "allowedIps": ["10.0.0.48/28"] - } - ] -} \ No newline at end of file diff --git a/main.go b/main.go index b0f8ca3..a6309b7 100644 --- a/main.go +++ b/main.go @@ -47,6 +47,7 @@ var ( type WgConfig struct { PrivateKey string `json:"privateKey"` ListenPort int `json:"listenPort"` + RelayPort int `json:"relayPort"` IpAddress string `json:"ipAddress"` Peers []Peer `json:"peers"` } @@ -346,7 +347,11 @@ func main() { }) // Start the UDP proxy server - proxyRelay = relay.NewUDPProxyServer(groupCtx, ":21820", remoteConfigURL, key, reachableAt) + relayPort := wgconfig.RelayPort + if relayPort == 0 { + relayPort = 21820 // in case there is no relay port set, use 21820 + } + proxyRelay = relay.NewUDPProxyServer(groupCtx, fmt.Sprintf(":%d", relayPort), remoteConfigURL, key, reachableAt) err = proxyRelay.Start() if err != nil { logger.Fatal("Failed to start UDP proxy server: %v", err)