Skip to content
Snippets Groups Projects
Commit f81584d7 authored by Reiner Hauser's avatar Reiner Hauser
Browse files

Leave endpoint hostname empty if it does not resolve

If the hostname does not resolve to a valid IP address the
function from the system package reports "0.0.0.0". In this
case we leave endpoint host/ip part empty to fall back to
the default behaviour.
parent b6eee615
No related tags found
1 merge request!14Draft: Leave endpoint hostname empty if it does not resolve
Pipeline #10958784 passed
......@@ -62,14 +62,25 @@ int main(int argc, char** argv) {
try {
// Get the port number to use in CORBA communications, maybe 0
portNumber = daq::pmg::utils::serverPort();
std::ostringstream portNumber_str;
// Get numerical host IP - this may fail if the gethostname() does not
// resolve to one of the network interfaces. In this case leave the
// hostname port of the endpoint empty.
std::string ip = System::LocalHost::instance()->ip_string();
if(ip == "0.0.0.0") {
ip = "";
}
// Note: always use TLS
portNumber_str << "giop:ssl:" << System::LocalHost::instance()->ip_string() << ":" << portNumber;
std::pair<std::string, std::string> addedOpt = std::make_pair("endPoint", portNumber_str.str());
std::ostringstream endpoint_str;
endpoint_str << "giop:ssl:" << ip << ":";
if(portNumber != 0) {
endpoint_str << portNumber;
}
std::pair<std::string, std::string> addedOpt = std::make_pair("endPoint", endpoint_str.str());
optList.push_back(addedOpt);
// Only publish the TLS endpoint, and only on the 'control' interface, i.e. the one that reverse resolves to the hostname
optList.push_back(std::pair("endPointPublish", "giop:ssl:" + System::LocalHost::instance()->ip_string() + ":"));
optList.push_back(std::pair("endPointPublish", "giop:ssl:" + ip + ":"));
}
catch(daq::pmg::IPC_Port_Error &ex) {
ers::fatal(ex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment