diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-06-04 15:53:35 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-06-04 15:53:35 +0000 |
commit | 512d5d6ee8737edc9dbc82773532ae9a54a7cfcd (patch) | |
tree | af479386298a1914edec879859341e507d0e7326 /cpp/src/Ice/TcpEndpointI.cpp | |
parent | Bug 1597. (diff) | |
download | ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.tar.bz2 ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.tar.xz ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.zip |
Bug 1658 - listen on 0.0.0.0 rather than expanding endpoints
Diffstat (limited to 'cpp/src/Ice/TcpEndpointI.cpp')
-rw-r--r-- | cpp/src/Ice/TcpEndpointI.cpp | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 0d0573840fa..b7552308727 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -22,23 +22,23 @@ using namespace Ice; using namespace IceInternal; IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, - const string& conId, bool co, bool pub) : + const string& conId, bool co, bool oae) : _instance(instance), _host(ho), _port(po), _timeout(ti), _connectionId(conId), _compress(co), - _publish(pub) + _oaEndpoint(oae) { } -IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& str) : +IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : _instance(instance), _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(oaEndpoint) { const string delim = " \t\n\r"; @@ -138,6 +138,26 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin } } } + + if(_host.empty()) + { + const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; + if(_host.empty()) + { + if(oaEndpoint) + { + const_cast<string&>(_host) = "0.0.0.0"; + } + else + { + const_cast<string&>(_host) = "127.0.0.1"; + } + } + } + else if(_host == "*") + { + const_cast<string&>(_host) = "0.0.0.0"; + } } IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : @@ -145,7 +165,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : _port(0), _timeout(-1), _compress(false), - _publish(true) + _oaEndpoint(false) { s->startReadEncaps(); s->read(const_cast<string&>(_host), false); @@ -211,7 +231,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -224,7 +244,7 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -243,7 +263,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -295,57 +315,35 @@ AcceptorPtr IceInternal::TcpEndpointI::acceptor(EndpointIPtr& endp, const string&) const { TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port); - endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _publish); + endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress, _oaEndpoint); return p; } + vector<EndpointIPtr> -IceInternal::TcpEndpointI::expand(bool server) const +IceInternal::TcpEndpointI::expand() const { - if(_host.empty()) - { - const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; - if(_host.empty()) - { - if(server) - { - const_cast<string&>(_host) = "0.0.0.0"; - } - else - { - const_cast<string&>(_host) = "127.0.0.1"; - } - } - } - else if(_host == "*") - { - const_cast<string&>(_host) = "0.0.0.0"; - } - vector<EndpointIPtr> endps; if(_host == "0.0.0.0") { vector<string> hosts = getLocalHosts(); for(unsigned int i = 0; i < hosts.size(); ++i) { - endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || hosts[i] != "127.0.0.1")); + if(!_oaEndpoint || hosts.size() == 1 || hosts[i] != "127.0.0.1") + { + endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else { endps.push_back(const_cast<TcpEndpointI*>(this)); - } + } return endps; } bool -IceInternal::TcpEndpointI::publish() const -{ - return _publish; -} - -bool IceInternal::TcpEndpointI::equivalent(const TransceiverPtr&) const { return false; @@ -533,9 +531,9 @@ IceInternal::TcpEndpointFactory::protocol() const } EndpointIPtr -IceInternal::TcpEndpointFactory::create(const std::string& str) const +IceInternal::TcpEndpointFactory::create(const std::string& str, bool oaEndpoint) const { - return new TcpEndpointI(_instance, str); + return new TcpEndpointI(_instance, str, oaEndpoint); } EndpointIPtr |