-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Listener: Add listener filters. #2346
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
Changes from all commits
2fb53f1
11766c4
ee60ccf
6874568
bc51bf8
0a8fd6f
da0c39b
044a089
d97257a
efdf2f1
31ea8a0
c6f4fb2
a7845db
f9c5650
d42ce02
aa81333
add8512
c32fcaa
818858a
228ac19
0703ecc
84854b2
ad6f413
d4b2140
597d05a
1ad7886
8bd512f
dca40d8
ab098f3
d0ad3d5
7f77eb0
4d72b93
07629cb
de46c3b
f047852
13cba72
7d82bbe
61da63f
3503579
b7e16d3
e75f50d
9a2c62a
94751c0
1021213
a390886
ae07e0f
393e2bc
f5c19a9
6b3e81d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,5 +34,65 @@ class ListenSocket { | |
| typedef std::unique_ptr<ListenSocket> ListenSocketPtr; | ||
| typedef std::shared_ptr<ListenSocket> ListenSocketSharedPtr; | ||
|
|
||
| /** | ||
| * A socket passed to a connection. For server connections this represents the accepted socket, and | ||
| * for client connections this represents the socket being connected to a remote address. | ||
| * | ||
| * TODO(jrajahalme): Hide internals (e.g., fd) from listener filters by providing callbacks filters | ||
| * may need (set/getsockopt(), peek(), recv(), etc.) | ||
| */ | ||
| class ConnectionSocket { | ||
| public: | ||
| virtual ~ConnectionSocket() {} | ||
|
|
||
| /** | ||
| * @return the local address of the socket. | ||
| */ | ||
| virtual const Address::InstanceConstSharedPtr& localAddress() const PURE; | ||
|
|
||
| /** | ||
| * @return the remote address of the socket. | ||
| */ | ||
| virtual const Address::InstanceConstSharedPtr& remoteAddress() const PURE; | ||
|
|
||
| /** | ||
| * Set the local address of the socket. On accepted sockets the local address defaults to the | ||
| * one at which the connection was received at, which is the same as the listener's address, if | ||
| * the listener is bound to a specific address. | ||
| * | ||
| * @param local_address the new local address. | ||
| * @param restored a flag marking the local address as being restored to a value that is | ||
| * different from the one the socket was initially accepted at. This should only be set | ||
| * to 'true' when restoring the original destination address of a connection redirected | ||
| * by iptables REDIRECT. The caller is responsible for making sure the new address is | ||
| * actually different when passing restored as 'true'. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also give an example of when someone would call this function but set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reverted the meaning of this boolean and renamed it as "hand_off_restored_destinations", should be clearer now, see the new commit. |
||
| */ | ||
| virtual void setLocalAddress(const Address::InstanceConstSharedPtr& local_address, | ||
| bool restored = false) PURE; | ||
|
|
||
| /** | ||
| * Set the remote address of the socket. | ||
| */ | ||
| virtual void setRemoteAddress(const Address::InstanceConstSharedPtr& remote_address) PURE; | ||
|
|
||
| /** | ||
| * @return true if the local address has been restored to a value that is different from the | ||
| * address the socket was initially accepted at. | ||
| */ | ||
| virtual bool localAddressRestored() const PURE; | ||
|
|
||
| /** | ||
| * @return fd the socket's file descriptor. | ||
| */ | ||
| virtual int fd() const PURE; | ||
|
|
||
| /** | ||
| * Close the underlying socket. | ||
| */ | ||
| virtual void close() PURE; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need an explicit
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I'll remove the explicit close().
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to reintroduce this in order to remove takeFd(), which was more offensive. |
||
| }; | ||
|
|
||
| typedef std::unique_ptr<ConnectionSocket> ConnectionSocketPtr; | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy | ||
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.
please fix doc comments above
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.
OK, sorry for the sloppiness...