Skip to content

feat: socks5 proxy server#3336

Merged
qdm12 merged 10 commits into
masterfrom
socks5
May 21, 2026
Merged

feat: socks5 proxy server#3336
qdm12 merged 10 commits into
masterfrom
socks5

Conversation

@qdm12
Copy link
Copy Markdown
Member

@qdm12 qdm12 commented May 19, 2026

Description

New options:

  • SOCKS5_ENABLED=off
  • SOCKS5_LISTENING_ADDRESS=":1080"
  • SOCKS5_USER=
  • SOCKS5_PASSWORD=

Issue

Fixes #234

Assertions

  • I am aware that we do not accept manual changes to the servers.json file
  • I am aware that any changes to settings should be reflected in the wiki

Comment thread internal/socks5/server.go Fixed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new internal SOCKS5 proxy server (with optional username/password auth), wires it into Gluetun startup/shutdown, and adds configuration/env var plumbing plus unit/integration-style tests to support the feature request in #2409.

Changes:

  • Add internal/socks5 package implementing a SOCKS5 CONNECT proxy with RFC1929 username/password auth.
  • Add configuration settings/env vars for SOCKS5 and surface them in the global settings output.
  • Start the SOCKS5 server loop from cmd/gluetun/main.go and add tests for the new package.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
internal/socks5/socks5.go Core SOCKS5 handshake + CONNECT handling and TCP relay.
internal/socks5/server.go TCP listener accept loop and per-connection handling.
internal/socks5/loop.go Restarting loop wrapper around the SOCKS5 server.
internal/socks5/usernamepassword.go RFC1929 username/password subnegotiation.
internal/socks5/response.go SOCKS5 response encoding helpers.
internal/socks5/constants.go SOCKS5 protocol constants and stringers.
internal/socks5/settings.go Internal settings struct for the SOCKS5 package.
internal/socks5/interfaces.go Logger interface for the SOCKS5 package.
internal/socks5/socks5_test.go Unit + end-to-end proxy tests for the SOCKS5 package.
internal/socks5/mocks_generate_test.go / internal/socks5/mocks_test.go Generated GoMock logger for tests.
internal/configuration/settings/socks5.go New config/env parsing + defaults + validation for SOCKS5.
internal/configuration/settings/settings.go Add SOCKS5 settings to the global settings lifecycle (read/validate/defaults/string).
internal/configuration/settings/settings_test.go Update settings string snapshot for SOCKS5 section.
Dockerfile Add default SOCKS5 env vars.
cmd/gluetun/main.go Start/stop SOCKS5 loop and include it in crash monitoring.
Files not reviewed (1)
  • internal/socks5/mocks_test.go: Language not supported
Comments suppressed due to low confidence (1)

internal/socks5/loop.go:41

  • runErrorCh is returned to the caller but nothing ever writes to it (and it is never closed). In cmd/gluetun/main.go the main select waits on this channel, so SOCKS5 loop failures will never be reported and the goroutine can leak. Consider returning runDone directly, or forwarding errors from run/server.Start into runErrorCh and closing it on exit.
	runDone := make(chan error)
	l.runDone = runDone
	runErrorCh := make(chan error)

	go run(runCtx, runDone, l.settings)

	return runErrorCh, nil
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/socks5/loop.go
Comment thread internal/socks5/server.go Outdated
Comment thread internal/socks5/socks5.go Outdated
Comment thread cmd/gluetun/main.go
Comment thread internal/configuration/settings/socks5.go
Comment thread Dockerfile
Comment thread internal/socks5/usernamepassword.go Outdated
Comment thread internal/socks5/socks5_test.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • internal/socks5/mocks_test.go: Language not supported

Comment thread cmd/gluetun/main.go
Comment thread internal/socks5/loop.go Outdated
Comment thread internal/socks5/loop.go
Comment thread internal/configuration/settings/socks5.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • internal/socks5/mocks_test.go: Language not supported

Comment thread cmd/gluetun/main.go
Comment thread cmd/gluetun/main.go
Comment thread internal/socks5/response.go Outdated
Comment thread internal/socks5/loop.go
Comment thread Dockerfile
Comment thread internal/socks5/socks5.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • internal/socks5/mocks_test.go: Language not supported

Comment thread internal/socks5/loop.go
Comment thread internal/socks5/loop.go
Comment thread internal/socks5/server.go
Comment thread internal/socks5/server.go
Comment thread cmd/gluetun/main.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • internal/socks5/mocks_test.go: Language not supported

Comment thread internal/socks5/loop.go
Comment thread internal/socks5/loop.go
Comment thread internal/socks5/server.go
@qdm12 qdm12 marked this pull request as ready for review May 21, 2026 17:18
@qdm12 qdm12 merged commit eb9916f into master May 21, 2026
8 checks passed
@qdm12 qdm12 deleted the socks5 branch May 21, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: SOCKS5 plaintext proxy in Go

3 participants