feat(socks5): add SOCKS5 proxy support with configuration and logging.#3333
Closed
adjscent wants to merge 1 commit into
Closed
feat(socks5): add SOCKS5 proxy support with configuration and logging.#3333adjscent wants to merge 1 commit into
adjscent wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a built-in SOCKS5 proxy server to Gluetun, including configuration via environment variables/secret files, container port exposure, and startup integration alongside existing proxy components.
Changes:
- Introduces a new
internal/socks5package implementing a SOCKS5 server with optional user/password auth and optional logging. - Adds SOCKS5 settings to the global configuration model and settings summary output.
- Wires the SOCKS5 loop into
cmd/gluetun/main.go, and exposes port/env defaults in the Dockerfile + README.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents SOCKS5 support and docker-compose port mapping. |
| internal/socks5/state.go | Adds status/settings state management for the SOCKS5 loop. |
| internal/socks5/server.go | Implements SOCKS5 server creation, auth config, and logging adapter. |
| internal/socks5/server_test.go | Adds basic handshake tests for no-auth and user/pass auth. |
| internal/socks5/loop.go | Adds the long-running loop supervising the SOCKS5 server lifecycle. |
| internal/socks5/logger.go | Defines the logger interface for the SOCKS5 component. |
| internal/configuration/settings/socks5.go | Adds SOCKS5 settings parsing/defaults/validation/string formatting. |
| internal/configuration/settings/settings.go | Plumbs SOCKS5 into global settings (read/default/validate/copy/string). |
| internal/configuration/settings/settings_test.go | Updates settings string snapshot to include SOCKS5 section. |
| go.mod | Adds dependency on github.com/armon/go-socks5. |
| go.sum | Adds checksums for the new SOCKS5 dependency. |
| Dockerfile | Adds SOCKS5 env defaults + secretfile envs and exposes port 1080/tcp. |
| cmd/gluetun/main.go | Starts the SOCKS5 loop and includes it in shutdown handling. |
Comments suppressed due to low confidence (1)
internal/socks5/loop.go:133
- The timer drain logic
if !isStableTimer.Stop() { <-isStableTimer.C }can block if the timer already fired and its value was already received earlier (soStop()returns false but the channel is empty). Use a non-blocking drain (e.g.select { case <-isStableTimer.C: default: }) to avoid deadlocks on restart/shutdown paths that exit the inner loop after the stable timer already fired.
if !isStableTimer.Stop() {
<-isStableTimer.C
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| l.logger.Info("stopping") | ||
| _ = listener.Close() | ||
| <-waitError | ||
| close(waitError) |
Comment on lines
+89
to
+107
| isStableTimer := time.NewTimer(time.Second) | ||
|
|
||
| stayHere := true | ||
| for stayHere { | ||
| select { | ||
| case <-ctx.Done(): | ||
| _ = listener.Close() | ||
| <-waitError | ||
| close(waitError) | ||
| return | ||
| case <-isStableTimer.C: | ||
| if !crashed { | ||
| l.running <- constants.Running | ||
| crashed = false | ||
| } else { | ||
| l.backoffTime = defaultBackoffTime | ||
| l.state.setStatusWithLock(constants.Running) | ||
| } | ||
| case <-l.start: |
Comment on lines
+99
to
+106
| case <-isStableTimer.C: | ||
| if !crashed { | ||
| l.running <- constants.Running | ||
| crashed = false | ||
| } else { | ||
| l.backoffTime = defaultBackoffTime | ||
| l.state.setStatusWithLock(constants.Running) | ||
| } |
| } | ||
| l.state.statusMu.Lock() | ||
| l.state.status = newStatus | ||
| return status.String(), nil |
Member
|
closed in favor of no-dependency #3336 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Working for me. Added SOCKS5 support with authentication.
Shadowsocks is good but it breaks a lot of socks5 clients.