Skip to content
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

address: use resolveProtoAddress to resolve listener addresses #3039

Merged
merged 4 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ envoy_cc_library(
"//source/common/config:utility_lib",
"//source/common/config:well_known_names",
"//source/common/network:listen_socket_lib",
"//source/common/network:resolver_lib",
"//source/common/network:socket_option_lib",
"//source/common/network:utility_lib",
"//source/common/protobuf:utility_lib",
Expand Down
3 changes: 2 additions & 1 deletion source/server/listener_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "common/config/utility.h"
#include "common/config/well_known_names.h"
#include "common/network/listen_socket_impl.h"
#include "common/network/resolver_impl.h"
#include "common/network/socket_option_impl.h"
#include "common/network/utility.h"
#include "common/protobuf/utility.h"
Expand Down Expand Up @@ -120,7 +121,7 @@ class ListenerSocketOption : public Network::SocketOptionImpl {
ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, ListenerManagerImpl& parent,
const std::string& name, bool modifiable, bool workers_started,
uint64_t hash)
: parent_(parent), address_(Network::Utility::protobufAddressToAddress(config.address())),
: parent_(parent), address_(Network::Address::resolveProtoAddress(config.address())),
global_scope_(parent_.server_.stats().createScope("")),
listener_scope_(
parent_.server_.stats().createScope(fmt::format("listener.{}.", address_->asString()))),
Expand Down
17 changes: 17 additions & 0 deletions test/server/listener_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,23 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, FreebindListenerEnabled) {
}
}

// Set the resolver to the default IP resolver. The address resolver logic is unit tested in
// resolver_impl_test.cc.
TEST_F(ListenerManagerImplWithRealFiltersTest, AddressResolver) {
const std::string yaml = TestEnvironment::substitute(R"EOF(
name: AddressResolverdListener
address:
socket_address: { address: 127.0.0.1, port_value: 1111, resolver_name: envoy.ip }
filter_chains:
- filters:
)EOF",
Network::Address::IpVersion::v4);

EXPECT_CALL(listener_factory_, createListenSocket(_, _, true));
manager_->addOrUpdateListener(parseListenerFromV2Yaml(yaml), true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't test that the resolved address matches what is expected. Is that necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a mock resolver or something to ensure we're at least going through the resolutino process?

EXPECT_EQ(1U, manager_->listeners().size());
}

TEST_F(ListenerManagerImplWithRealFiltersTest, CRLFilename) {
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
Expand Down