Skip to content

Commit

Permalink
DHS protocol, override callback host/port
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Apr 2, 2024
1 parent 236b255 commit c4d4e27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.7
1.11.8
15 changes: 14 additions & 1 deletion src/metkit/mars/DHSProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -105,6 +105,19 @@ class SimpleCallback : public BaseCallbackConnection {
net::EphemeralTCPServer callback_;
Endpoint callbackEndpoint_;

Endpoint computeEndpoint() const {
static std::string callbackHost = Resource<std::string>("$MARS_DHS_CALLBACK_HOST", "");
static int callbackPort = Resource<int>("$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"};
Expand Down

0 comments on commit c4d4e27

Please sign in to comment.