diff --git a/VERSION b/VERSION index 9e8baca..40faed9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.7 \ No newline at end of file +1.11.8 diff --git a/src/metkit/mars/DHSProtocol.cc b/src/metkit/mars/DHSProtocol.cc index 5451485..482954f 100644 --- a/src/metkit/mars/DHSProtocol.cc +++ b/src/metkit/mars/DHSProtocol.cc @@ -85,7 +85,7 @@ class SimpleCallback : public BaseCallbackConnection { public: SimpleCallback() : - callbackEndpoint_(net::IPAddress::hostAddress(callback_.localHost()).asString(), callback_.localPort()) { + callbackEndpoint_(computeEndpoint()) { LOG_DEBUG_LIB(LibMetkit) << "Simple callback. host=" << callbackEndpoint_.host() << " port=" << callbackEndpoint_.port() << std::endl; } @@ -105,6 +105,19 @@ class SimpleCallback : public BaseCallbackConnection { net::EphemeralTCPServer callback_; Endpoint callbackEndpoint_; + Endpoint computeEndpoint() const { + static std::string callbackHost = Resource("$MARS_DHS_CALLBACK_HOST", ""); + static int callbackPort = Resource("$MARS_DHS_CALLBACK_PORT", 0); + + if (callbackHost.empty()) { + return Endpoint{net::IPAddress::hostAddress(callback_.localHost()).asString(), callback_.localPort()}; + } + if (callbackPort == 0) { + return Endpoint{callbackHost, callback_.localPort()}; + } + return Endpoint{callbackHost, callbackPort}; + } + public: static const ClassSpec& classSpec() { static ClassSpec spec = {&BaseCallbackConnection::classSpec(), "SimpleCallback"};