You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "SimonWoolf (via GitHub)" <gi...@apache.org> on 2026/08/26 17:36:35 UTC

[PR] [Connection] Add an optional Dialer to ClientOptions [pulsar-client-go]

SimonWoolf opened a new pull request, #1532:
URL: https://github.com/apache/pulsar-client-go/pull/1532

   ### Motivation
   
   There is currently no way for a caller to influence how the client establishes TCP connections to brokers: connection.connect() calls net.Dial/net.DialTimeout/tls.DialWithDialer directly, and ClientOptions exposes no hook. That makes several things impossible from outside the library (in our case, we want to blocklist IPs in a way that isn't trivially avoidable by having a bad actor change DNS resolution for an address they supply after the pulsar producer is constructed).
   
   ### Modifications
   
   This adds an optional ClientOptions.Dialer.
   
   connect() is restructured so the TCP dial and the TLS handshake are separate steps. tls.DialWithDialer does both at once and cannot take an injected dialer, so it becomes a dial followed by tls.Client(...).Handshake(). The dialer therefore returns a plain net.Conn and the library still owns TLS, leaving getTLSConfig() and certificate verification unchanged.
   
   (NB: tls.DialWithDialer infers ServerName from the address being dialed when the config leaves it blank, whereas tls.Client does not and would verify against an empty name. This preserves that behaviour).
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change added tests and can be verified as follows: `go test ./pulsar/internal/ -run TestConnection`
   
   The existing TLS integration tests cover the restructured connection.connect().
   
   ### Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API: yes, in a non-breaking way (adds a client option)
     - The schema:  no
     - The default values of configurations: no
     - The wire protocol: no
   
   ### Documentation
   
     - Does this pull request introduce a new feature? yes (the new dialer)
     - If yes, how is the feature documented? GoDocs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org