Skip to content

Add support for pluggable stream provider to enable SOCKS5 proxies#2251

Open
koepalex wants to merge 3 commits into
dotnet:masterfrom
koepalex:koepalex/socks5-proxy-support
Open

Add support for pluggable stream provider to enable SOCKS5 proxies#2251
koepalex wants to merge 3 commits into
dotnet:masterfrom
koepalex:koepalex/socks5-proxy-support

Conversation

@koepalex
Copy link
Copy Markdown
Contributor

This pull request adds SOCKS5 proxy support to the MQTTnet project, enabling MQTT clients to connect to brokers through SOCKS5 proxies, with or without authentication. It introduces a new extension library, integrates it into the solution and samples, and provides user-friendly configuration methods.

SOCKS5 Proxy Support Integration:

  • Added new project MQTTnet.Extensions.Socks5 with all necessary source files and project configuration, providing SOCKS5 proxy support (RFC 1928/1929) for MQTTnet TCP transport. (Source/MQTTnet.Extensions.Socks5/MQTTnet.Extensions.Socks5.csproj, Source/MQTTnet.Extensions.Socks5/Socks5Protocol.cs, Source/MQTTnet.Extensions.Socks5/Socks5NetworkStream.cs) [1] [2] [3]
  • Implemented extension methods for MqttClientOptionsBuilder to allow easy configuration of SOCKS5 proxies, including support for authentication and advanced options. (Source/MQTTnet.Extensions.Socks5/MqttClientOptionsBuilderExtensions.cs)

Solution and Sample Integration:

  • Registered the new MQTTnet.Extensions.Socks5 and its test project in the main solution file, and added support for additional build configurations (x64, x86). (MQTTnet.sln)
  • Updated the Samples project to reference the new extension and added sample code demonstrating how to connect to MQTT brokers via SOCKS5 proxies, including both unauthenticated and authenticated scenarios. (Samples/MQTTnet.Samples.csproj, Samples/Client/Client_Socks5_Samples.cs) [1] [2]

Copilot and others added 3 commits May 20, 2026 19:43
Introduces MQTTnet.Extensions.Socks5, enabling SOCKS5 proxy support for MQTTnet TCP transport. Adds IMqttClientStreamProvider interface, Socks5StreamProvider implementation, and related configuration options. Updates MqttTcpChannel to support stream providers and TLS layering. Includes unit tests with a fake SOCKS5 server and usage samples. Solution and project references updated accordingly.
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.

1 participant