Conversation
Signed-off-by: JP Simard <jp@jpsim.com>
| transformed_headers->setFormatter( | ||
| std::make_unique< | ||
| Extensions::Http::HeaderFormatters::PreserveCase::PreserveCaseHeaderFormatter>()); | ||
| Extensions::Http::HeaderFormatters::PreserveCase::PreserveCaseHeaderFormatter>(false)); |
There was a problem hiding this comment.
To account for envoyproxy/envoy#18997
Considering it's designed to be off by default, I imagine that we can disable it for our use cases until we have reason to do otherwise.
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
It should be rewritten now that getifaddrs works. Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| #if !defined(SUPPORTS_GETIFADDRS) && defined(INCLUDE_IFADDRS) |
There was a problem hiding this comment.
In my version of this work I had then created a network/android/utility namespace where I created a function that sets the android getifaddrs impl. Then I called that function early in the engine's lifecycle before the network configurator is constructed.
This was my implementation:
#include "library/common/network/utility.h"
#include "source/common/api/os_sys_calls_impl.h"
#include "source/common/network/address_impl.h"
namespace Envoy {
namespace Network {
namespace Android {
namespace Utility {
#if defined(INCLUDE_ANDROID_IFADDRS)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
namespace {
#include "third_party/android/ifaddrs-android.h"
}
#pragma clang diagnostic pop
#endif
/**
*/
void setAlternateGetifaddrs() {
#if defined(INCLUDE_ANDROID_IFADDRS)
auto& os_syscalls = Api::OsSysCallsSingleton::get();
if (!os_syscalls.supportsGetifaddrs()) {
Api::AlternateGetifaddrs android_getifaddrs =
[](Api::InterfaceAddressVector& interfaces) -> Api::SysCallIntResult {
struct ifaddrs* ifaddr;
struct ifaddrs* ifa;
const int rc = getifaddrs(&ifaddr);
if (rc == -1) {
return {rc, errno};
}
for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == nullptr) {
continue;
}
if (ifa->ifa_addr->sa_family == AF_INET || ifa->ifa_addr->sa_family == AF_INET6) {
const sockaddr_storage* ss = reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr);
size_t ss_len =
ifa->ifa_addr->sa_family == AF_INET ? sizeof(sockaddr_in) : sizeof(sockaddr_in6);
StatusOr<Address::InstanceConstSharedPtr> address =
Address::addressFromSockAddr(*ss, ss_len, ifa->ifa_addr->sa_family == AF_INET6);
if (address.ok()) {
interfaces.emplace_back(ifa->ifa_name, ifa->ifa_flags, *address);
}
}
}
if (ifaddr) {
freeifaddrs(ifaddr);
}
return {rc, 0};
};
os_syscalls.setAlternateGetifaddrs(android_getifaddrs);
} else {
// FIXME: assert that this function is not called more than once?
}
#endif
}
} // namespace Utility
} // namespace Android
} // namespace Network
} // namespace Envoy
There was a problem hiding this comment.
Thanks for saving me the trouble of writing this 😄
I've pushed it up with minor modifications and addressing the TODO in eb6a57b. I'm working on running the Android sample app locally to confirm this works.
There was a problem hiding this comment.
I've confirmed that this ifaddrs implementation is used on Android by manually adding logs and confirming they're emitted when running the sample app locally.
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: JP Simard <jp@jpsim.com>
junr03
left a comment
There was a problem hiding this comment.
lgtm, looking forward to test.
Did you run the example app to look for the interface log line in Android as a sanity check?
Yes: #1962 (comment) PS: I can’t merge this PR myself |
|
Thanks for merging @alyssawilk ! |
Changes: envoyproxy/envoy@23e5fc2...70a5f29 Signed-off-by: JP Simard <jp@jpsim.com>
Changes: envoyproxy/envoy@23e5fc2...70a5f29