forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing UDP listener. (envoyproxy#5473)
Signed-off-by: Jojy G Varghese <jojy_varghese@apple.com> Signed-off-by: Fred Douglas <fredlas@google.com>
- Loading branch information
1 parent
b22ef87
commit 0ce6578
Showing
17 changed files
with
949 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "common/network/base_listener_impl.h" | ||
|
||
#include <sys/un.h> | ||
|
||
#include "envoy/common/exception.h" | ||
|
||
#include "common/common/assert.h" | ||
#include "common/common/empty_string.h" | ||
#include "common/common/fmt.h" | ||
#include "common/event/dispatcher_impl.h" | ||
#include "common/event/file_event_impl.h" | ||
#include "common/network/address_impl.h" | ||
|
||
#include "event2/listener.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
Address::InstanceConstSharedPtr BaseListenerImpl::getLocalAddress(int fd) { | ||
return Address::addressFromFd(fd); | ||
} | ||
|
||
BaseListenerImpl::BaseListenerImpl(Event::DispatcherImpl& dispatcher, Socket& socket) | ||
: local_address_(nullptr), dispatcher_(dispatcher), socket_(socket) { | ||
const auto ip = socket.localAddress()->ip(); | ||
|
||
// Only use the listen socket's local address for new connections if it is not the all hosts | ||
// address (e.g., 0.0.0.0 for IPv4). | ||
if (!(ip && ip->isAnyAddress())) { | ||
local_address_ = socket.localAddress(); | ||
} | ||
} | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "envoy/network/listener.h" | ||
|
||
#include "common/event/dispatcher_impl.h" | ||
#include "common/event/libevent.h" | ||
#include "common/network/listen_socket_impl.h" | ||
|
||
#include "event2/event.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
/** | ||
* Base libevent implementation of Network::Listener. | ||
*/ | ||
class BaseListenerImpl : public Listener { | ||
public: | ||
BaseListenerImpl(Event::DispatcherImpl& dispatcher, Socket& socket); | ||
|
||
protected: | ||
virtual Address::InstanceConstSharedPtr getLocalAddress(int fd); | ||
|
||
Address::InstanceConstSharedPtr local_address_; | ||
Event::DispatcherImpl& dispatcher_; | ||
Socket& socket_; | ||
}; | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.