Skip to content

Conversation

k-shlomi
Copy link

@k-shlomi k-shlomi commented Sep 25, 2025

Adds SOCKS5 proxy support for Rust EventHubs client, enabling connections through corporate proxies and restricted network environments.

Changes

Core Implementation

  • azure_core_amqp/src/socks5.rs - New SOCKS5 connection module
    • SocksConnection struct with validate_proxy_url(), connect(), mask_credentials()
    • Support for socks5:// and socks5h:// protocols
    • Username/password authentication via URL
    • Automatic credential masking in logs
  • azure_core_amqp/src/connection.rs - AMQP integration
    • Modified open_with_stream() to detect SOCKS5 URLs in custom_endpoint
    • Zero breaking changes, backward compatible

Dependencies

  • tokio-socks = "0.5"
  • tokio-native-tls = "0.3"
  • native-tls = "0.2"

Documentation & Examples

  • azure_core_amqp/README.md - Added SOCKS5 feature documentation
  • eventhubs/examples/eventhubs_socks5_proxy.rs - Complete usage example
  • Comprehensive rustdoc with examples and troubleshooting

Usage

  let client = ProducerClient::builder()
      .with_custom_endpoint("socks5h://proxy.corp.com:1080")
      .open(host, eventhub, credential)
      .await?;

Resolves enterprise customer requirements for proxy support in restricted network environments.

@github-actions github-actions bot added Azure.Core The azure_core crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Sep 25, 2025
Copy link

Thank you for your contribution @k-shlomi! We will review the pull request and get back to you soon.

@k-shlomi
Copy link
Author

@microsoft-github-policy-service agree company="Sweet Security"

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

A few notes, but @LarryOsterman should definitely have a look. Thanks for the contribution!

@LarryOsterman
Copy link
Member

/azp run rust - eventhubs - weekly

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@LarryOsterman LarryOsterman left a comment

Choose a reason for hiding this comment

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

In general, I'm singularly impressed. I have one significant concern, which is that I believe that these new tests will fail in our weekly test runs because we run our tests with --all-features and the CI pipeline doesn't have a SOCKS5 proxy available to work.

Also I'd like to have someone from the EventHubs service team take a look to confirm that they want SOCKS5 proxy support as a feature (it's complicated).

@k-shlomi k-shlomi force-pushed the support-eventhub-proxy branch from ed8db60 to 2ece6c7 Compare September 28, 2025 15:06
@k-shlomi
Copy link
Author

Hi @heaths and @LarryOsterman
thank you for the review.
I believe I addressed all your comments. let me know if anything else is needed.

@heaths
Copy link
Member

heaths commented Sep 29, 2025

@weshaggard @hallipr what's going on with the vcpkg install on Windows?

From the logs,

%VCPKG_BINARY_SOURCES%: error: invalid argument: binary config 'azblob' requires a SAS token without a preceeding '?' as the second argument

We're using the same setup that other repos are using, so did something break recently?

@heaths
Copy link
Member

heaths commented Sep 29, 2025

@k-shlomi please address my comments as well. See our root CONTRIBUTING.md for more information as well.

@k-shlomi
Copy link
Author

@heaths I believe I did fix your comments. can you point me out to comments I missed?

@weshaggard
Copy link
Member

@weshaggard @hallipr what's going on with the vcpkg install on Windows?

From the logs,

%VCPKG_BINARY_SOURCES%: error: invalid argument: binary config 'azblob' requires a SAS token without a preceeding '?' as the second argument

We're using the same setup that other repos are using, so did something break recently?

@danieljurek is investigating the vcpkg issue.

@danieljurek
Copy link
Member

danieljurek commented Sep 30, 2025

Notes from investigation so far:

  • vcpkg install shouldn't be failing here
  • Other pipelines are not failing because vcpkg install is invoked differently
  • Successful invocations in rust - pullrequest use vcpkg at version 2025-07-21-d4b65a2b83ae6c3526acd1c6f3b51aff2a884533, failing pipeline runs are showing version 2025-09-03-4580816534ed8fd9634ac83d46471440edd82dfe
  • There was a recent update to the image that moved vcpkg up. Looks like vcpkg is running from the image.

@danieljurek
Copy link
Member

There was a breaking change to binary caching for vcpkg in this version. I have a fix working locally... PR coming soon

@danieljurek
Copy link
Member

danieljurek commented Sep 30, 2025

Fix is in. Rebase on main then push to re-run and get past the vcpkg install issues.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

You can't take direct dependencies in a crate. There are also some sanitization concerns.

@k-shlomi k-shlomi force-pushed the support-eventhub-proxy branch from 727fc0d to 93fe99f Compare October 2, 2025 11:46
@k-shlomi
Copy link
Author

k-shlomi commented Oct 2, 2025

@heaths one question for you in regards to your last comments.
fixed the rest
pulled from main so now build passes

@k-shlomi k-shlomi force-pushed the support-eventhub-proxy branch from e72dc50 to 15d7ba3 Compare October 5, 2025 08:30
@heaths
Copy link
Member

heaths commented Oct 6, 2025

I don't see a question I haven't answered already. Could you resolve PR comments as you fix/respond to them? Might be easier to see what's still considered an open issue. That's how we do it on our team.

@k-shlomi k-shlomi force-pushed the support-eventhub-proxy branch from 15d7ba3 to 99f8264 Compare October 7, 2025 08:27
@k-shlomi
Copy link
Author

k-shlomi commented Oct 7, 2025

@heaths I missed your comment about making sanitize public a few days ago... fixed it now.
could you verify I did it as you meant to?
also, I resolved the comments
I also pulled from main to make sure the PR is up to date.
hopefully, that will resolve all issues that were still open.

@j7nw4r j7nw4r self-requested a review October 7, 2025 13:33
@j7nw4r
Copy link
Member

j7nw4r commented Oct 7, 2025

@k-shlomi

Hey. I'm on the Event Hubs team that is managing this sdk going forward. Thanks a lot for this work.

I'm currently speaking with our PM about how to consider this additional functionality. To integrate this change, we'd need to also add it to all of the other language SDKs (and probably the Service Bus SDKs) for parity. We're trying to determine if that (and the maintenance burden) is something we can take on.

@k-shlomi
Copy link
Author

k-shlomi commented Oct 7, 2025

got it @j7nw4r thanks.
I will say that for organizations that have deployments on-prem or without direct internet access this probably a required feature.
please keep me posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants