libtransport: support service.server also in server-mode
This commit is contained in:
parent
8b225b590a
commit
df369e65d8
5 changed files with 14 additions and 6 deletions
|
@ -38,6 +38,7 @@ Server::Server(
|
|||
NetworkFactories* networkFactories,
|
||||
UserRegistry *userRegistry,
|
||||
const JID& jid,
|
||||
const std::string &address,
|
||||
int port) :
|
||||
userRegistry_(userRegistry),
|
||||
port_(port),
|
||||
|
@ -45,7 +46,8 @@ Server::Server(
|
|||
networkFactories_(networkFactories),
|
||||
stopping(false),
|
||||
selfJID(jid),
|
||||
stanzaChannel_(){
|
||||
stanzaChannel_(),
|
||||
address_(address){
|
||||
stanzaChannel_ = new ServerStanzaChannel();
|
||||
iqRouter_ = new IQRouter(stanzaChannel_);
|
||||
tlsFactory = NULL;
|
||||
|
@ -63,7 +65,12 @@ void Server::start() {
|
|||
if (serverFromClientConnectionServer) {
|
||||
return;
|
||||
}
|
||||
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
|
||||
if (address_ == "0.0.0.0") {
|
||||
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
|
||||
}
|
||||
else {
|
||||
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(Swift::HostAddress(address_), port_);
|
||||
}
|
||||
serverFromClientConnectionServerSignalConnections.push_back(
|
||||
serverFromClientConnectionServer->onNewConnection.connect(
|
||||
boost::bind(&Server::handleNewClientConnection, this, _1)));
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Swift {
|
|||
|
||||
class Server : public Entity {
|
||||
public:
|
||||
Server(EventLoop* eventLoop, NetworkFactories* networkFactories, UserRegistry *userRegistry, const JID& jid, int port);
|
||||
Server(EventLoop* eventLoop, NetworkFactories* networkFactories, UserRegistry *userRegistry, const JID& jid, const std::string &address, int port);
|
||||
~Server();
|
||||
|
||||
void start();
|
||||
|
@ -86,5 +86,6 @@ namespace Swift {
|
|||
TLSServerContextFactory *tlsFactory;
|
||||
CertificateWithKey::ref cert;
|
||||
PlatformXMLParserFactory *parserFactory_;
|
||||
std::string address_;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ jid = localhost
|
|||
password = secret
|
||||
|
||||
# XMPP server to which Spectrum connects in gateway mode.
|
||||
# In server mode, this option is ignored.
|
||||
# To bind to all ipv4 interfaces, use server=0.0.0.0
|
||||
server = 127.0.0.1
|
||||
|
||||
# XMPP server port.
|
||||
|
|
|
@ -36,7 +36,7 @@ class UserRegistryTest : public CPPUNIT_NS :: TestFixture {
|
|||
userRegistry->onConnectUser.connect(bind(&UserRegistryTest::handleConnectUser, this, _1));
|
||||
userRegistry->onDisconnectUser.connect(bind(&UserRegistryTest::handleDisconnectUser, this, _1));
|
||||
|
||||
server = new Swift::Server(loop, factories, userRegistry, "localhost", 5222);
|
||||
server = new Swift::Server(loop, factories, userRegistry, "localhost", "0.0.0.0", 5222);
|
||||
server->start();
|
||||
connectionServer = server->getConnectionServer();
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories,
|
|||
|
||||
if (CONFIG_BOOL(m_config, "service.server_mode")) {
|
||||
LOG4CXX_INFO(logger, "Creating component in server mode on port " << CONFIG_INT(m_config, "service.port"));
|
||||
m_server = new Swift::Server(loop, m_factories, m_userRegistry, m_jid, CONFIG_INT(m_config, "service.port"));
|
||||
m_server = new Swift::Server(loop, m_factories, m_userRegistry, m_jid, CONFIG_STRING(m_config, "service.server"), CONFIG_INT(m_config, "service.port"));
|
||||
if (!CONFIG_STRING(m_config, "service.cert").empty()) {
|
||||
#ifndef _WIN32
|
||||
//TODO: fix
|
||||
|
|
Loading…
Add table
Reference in a new issue