You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2019/07/05 12:08:32 UTC
[mesos] 03/12: Added optional 'host' string member to UPID.
This is an automated email from the ASF dual-hosted git repository.
bennoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit ba2bac706753fe1da68227c8ec15acd293f1154a
Author: Benno Evers <be...@mesosphere.com>
AuthorDate: Wed Jun 19 16:37:41 2019 +0200
Added optional 'host' string member to UPID.
This allows client code to access the original hostname
that was used to specify a libprocess address.
Review: https://reviews.apache.org/r/70884
---
3rdparty/libprocess/include/process/pid.hpp | 10 ++++++++++
3rdparty/libprocess/src/pid.cpp | 9 ++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/3rdparty/libprocess/include/process/pid.hpp b/3rdparty/libprocess/include/process/pid.hpp
index 9f09ab4..f12ad34 100644
--- a/3rdparty/libprocess/include/process/pid.hpp
+++ b/3rdparty/libprocess/include/process/pid.hpp
@@ -193,6 +193,16 @@ struct UPID
Option<network::inet6::Address> v6;
} addresses = {None()};
+ // The hostname that was used to create this UPID, if any. This is useful
+ // both for display purposes and when making outgoing connections on a TLS
+ // socket, where the name recorded here can be used for hostname validation
+ // checks against the X509 certificate presented by the server.
+ //
+ // NOTE: In the context of TLS hostname validation, this can also be set
+ // manually to override the result of DNS resolution before trying to
+ // `connect()` to this UPID, similar to `curl --resolve`.
+ Option<std::string> host;
+
protected:
friend class ProcessBase;
friend class ProcessManager;
diff --git a/3rdparty/libprocess/src/pid.cpp b/3rdparty/libprocess/src/pid.cpp
index fdc61b5..44f56c8 100644
--- a/3rdparty/libprocess/src/pid.cpp
+++ b/3rdparty/libprocess/src/pid.cpp
@@ -119,8 +119,15 @@ istream& operator>>(istream& stream, UPID& pid)
return stream;
}
+ // First try to see if we can parse `host` as a raw IP address literal,
+ // if not use `net::getIP()` to resolve the hostname.
+ //
// TODO(evelinad): Extend this to support IPv6.
- Try<net::IP> ip = net::getIP(host, AF_INET);
+ Try<net::IP> ip = net::IP::parse(host.c_str(), AF_INET);
+ if (ip.isError()) {
+ pid.host = host;
+ ip = net::getIP(host, AF_INET);
+ }
if (ip.isError()) {
VLOG(2) << ip.error();