Skip to content

Commit

Permalink
DHS protocol - select same host for passive proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Jan 5, 2024
1 parent 36406fd commit 2cfe587
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/metkit/mars/DHSProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace {
return selectProxyHost(config.getStringVector("proxyHosts"));
}

throw UserError("Neither proxyHost nor proxyPort specified in configuration");
throw UserError("Neither proxyHosts nor proxyHost specified in configuration");
}
}

Expand Down Expand Up @@ -278,9 +278,12 @@ const ClassSpec& BaseCallbackConnection::classSpec() {
return spec;
}

BaseCallbackConnection* BaseCallbackConnection::build(const Configuration& config) {
if (config.has("proxyHost") || config.has("proxyHosts")) {
BaseCallbackConnection* BaseCallbackConnection::build(const Configuration& config, const std::string& host) {
if (config.has("proxyHost") || config.has("proxyHosts") || (config.getBool("passiveProxy", true) && config.getBool("useHostAsProxy", false))) {
if (config.getBool("passiveProxy", true)) {
if (config.getBool("useHostAsProxy", false)) {
return new PassiveProxyCallback{unpackHostPort(host)};
}
return new PassiveProxyCallback{config};
}
return new ProxyCallback{config};
Expand Down Expand Up @@ -319,7 +322,6 @@ DHSProtocol::DHSProtocol(const std::string& name,

DHSProtocol::DHSProtocol(const Configuration& params):
BaseProtocol(params),
callback_(BaseCallbackConnection::build(params)),
name_(params.getString("name")),
port_(params.getInt("port", 9000)),
done_(false),
Expand All @@ -334,6 +336,7 @@ DHSProtocol::DHSProtocol(const Configuration& params):
ASSERT(params.has("host"));
host_ = params.getString("host");
}
callback_.reset(BaseCallbackConnection::build(params, host_));
}

DHSProtocol::DHSProtocol(Stream& s):
Expand Down
2 changes: 1 addition & 1 deletion src/metkit/mars/DHSProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BaseCallbackConnection : public eckit::Streamable {
BaseCallbackConnection() {}
virtual ~BaseCallbackConnection() {}

static BaseCallbackConnection* build(const eckit::Configuration& config);
static BaseCallbackConnection* build(const eckit::Configuration& config, const std::string& host = "");

virtual const eckit::net::Endpoint& endpoint() const = 0;

Expand Down

0 comments on commit 2cfe587

Please sign in to comment.