-
Notifications
You must be signed in to change notification settings - Fork 4.1k
support bind client ip #3179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
support bind client ip #3179
Conversation
2571ebd to
2578b05
Compare
|
The unit test is broken, please fix. |
There was a problem hiding this 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 adds support for binding client sockets to a specific IP address or hostname before connecting to a server, addressing issue #3157. The feature allows users to control which local network interface is used for outgoing connections.
- Adds
client_hostfield toChannelOptionsfor user configuration - Propagates client endpoint information through
SocketOptions,GetNamingServiceThreadOptions, and channel signature computation - Implements socket binding in
Socket::Connect()to bind the client socket to the specified IP before connecting
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/brpc/channel.h | Adds client_host string field to ChannelOptions for specifying client IP/hostname |
| src/brpc/channel.cpp | Implements parsing of client_host to EndPoint and includes it in channel signature; handles both InitSingle and Init paths |
| src/brpc/socket.h | Adds local_side field to SocketOptions to store the client endpoint |
| src/brpc/socket.cpp | Implements bind() call in Connect() to bind socket to client IP; initializes local_side from options |
| src/brpc/socket_map.h | Updates function signatures to accept client_end_point parameter |
| src/brpc/socket_map.cpp | Passes client_end_point through to SocketOptions when creating sockets |
| src/brpc/details/naming_service_thread.h | Adds client_end_point field to GetNamingServiceThreadOptions |
| src/brpc/details/naming_service_thread.cpp | Passes client_end_point to SocketMapInsert when adding servers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
11468f5 to
8bd8610
Compare
8bd8610 to
4aac92d
Compare
|
Please add some unit tests for this feature. |
What problem does this PR solve?
Issue Number: #3157, #3178
Problem Summary:
What is changed and the side effects?
Changed:
1.在ChannelOptions中添加client_host,让用户设置client的ip或hostname
2.在SocketOptions 中添加butil::EndPoint local_side,由 client_host:0 -> local_side
3.在GetNamingServiceThreadOptions添加butil::EndPoint client_end_point,由 client_host:0 -> client_end_point
4.在ComputeChannelSignature中append "clih=client_host", 进行hash
5.在系统调用socket创建socket后,调用bind绑定ip
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: