@@ -43,6 +43,7 @@ class PooledDialer {
4343 photon::mutex init_mtx;
4444 bool initialized = false ;
4545 bool tls_ctx_ownership = false ;
46+ std::vector<IPAddr> src_ips;
4647
4748 // If there is a photon thread switch during construction, the constructor might be called
4849 // multiple times, even for a thread_local instance. Therefore, ensure that there is no photon
@@ -52,7 +53,7 @@ class PooledDialer {
5253 photon::fini_hook ({this , &PooledDialer::at_photon_fini});
5354 }
5455
55- int init (TLSContext *_tls_ctx) {
56+ int init (TLSContext *_tls_ctx, std::vector<IPAddr> &src_ips ) {
5657 if (initialized)
5758 return 0 ;
5859 SCOPED_LOCK (init_mtx);
@@ -63,8 +64,8 @@ class PooledDialer {
6364 tls_ctx_ownership = true ;
6465 tls_ctx = new_tls_context (nullptr , nullptr , nullptr );
6566 }
66- auto tcp_cli = new_tcp_socket_client ();
67- auto tls_cli = new_tls_client (tls_ctx, new_tcp_socket_client (), true );
67+ auto tcp_cli = new_tcp_socket_client (src_ips. data (), src_ips. size () );
68+ auto tls_cli = new_tls_client (tls_ctx, new_tcp_socket_client (src_ips. data (), src_ips. size () ), true );
6869 tcpsock.reset (new_tcp_socket_pool (tcp_cli, -1 , true ));
6970 tlssock.reset (new_tcp_socket_pool (tls_cli, -1 , true ));
7071 udssock.reset (new_uds_client ());
@@ -158,10 +159,9 @@ class ClientImpl : public Client {
158159 m_tls_ctx (tls_ctx),
159160 m_cookie_jar (cookie_jar) {
160161 }
161-
162162 PooledDialer& get_dialer () {
163163 thread_local PooledDialer dialer;
164- dialer.init (m_tls_ctx);
164+ dialer.init (m_tls_ctx, m_bind_ips );
165165 return dialer;
166166 }
167167
0 commit comments