int main(int argc, char* argv[]) { try { rdma::ServerSocket serverSocket(argv[1], argv[2], atoi(argv[3]), atoi(argv[4])); while(1) { rdma::ClientSocket* clientSocket = serverSocket.accept(); try { while(1) { rdma::Buffer readPacket = clientSocket->read(); rdma::Buffer sendPacket = clientSocket->getWriteBuffer(); memcpy(sendPacket.get(), readPacket.get(), readPacket.size); clientSocket->write(sendPacket); clientSocket->returnReadBuffer(readPacket); } } catch(std::exception& e) { std::cerr << "client exception: " << e.what() << std::endl; } delete clientSocket; } } catch(std::exception& e) { std::cerr << "exception: " << e.what() << std::endl; } return 0; }
/*********************************************************************** * Spawn TCP proxy server given server URI **********************************************************************/ void PothosUtilBase::proxyServer(const std::string &, const std::string &uriStr) { //set stdio to be unbuffered to prevent IO backup when this is a subprocess std::cout.setf(std::ios::unitbuf); std::cerr.setf(std::ios::unitbuf); std::clog.setf(std::ios::unitbuf); Pothos::ScopedInit init; //parse the URI const std::string defaultUri = "tcp://"+Pothos::Util::getWildcardAddr(Pothos::RemoteServer::getLocatorPort()); Poco::URI uri(uriStr.empty()?defaultUri:uriStr); const std::string &host = uri.getHost(); const std::string &port = std::to_string(uri.getPort()); if (uri.getScheme() != "tcp") { throw Pothos::Exception("PothosUtil::proxyServer("+uriStr+")", "unsupported URI scheme"); } //create server socket Poco::Net::SocketAddress sa(host, port); Poco::Net::ServerSocket serverSocket(sa); Poco::Net::TCPServerConnectionFactory::Ptr factory; factory = new MyTCPServerConnectionFactory(this->config().hasOption("requireActive")); Poco::Net::TCPServer tcpServer(factory, serverSocket); //start the server tcpServer.start(); std::cout << "Host: " << serverSocket.address().host().toString() << std::endl; std::cout << "Port: " << serverSocket.address().port() << std::endl; //wait here until the term signal is received this->waitForTerminationRequest(); }
int main(int argc, char** argv) { log4cplus::initialize (); if(argc < 3) { std::cout << "Usage: port config_file" << std::endl; return 1; } int port = std::atoi(argv[1]); const log4cplus::tstring configFile = LOG4CPLUS_C_STR_TO_TSTRING(argv[2]); log4cplus::PropertyConfigurator config(configFile); config.configure(); log4cplus::helpers::ServerSocket serverSocket(port); if (!serverSocket.isOpen()) { std::cerr << "Could not open server socket, maybe port " << port << " is already in use." << std::endl; return 2; } loggingserver::Reaper reaper; for (;;) { loggingserver::ClientThread *thr = new loggingserver::ClientThread(serverSocket.accept(), reaper); thr->start(); } log4cplus::Logger::shutdown(); return 0; }
FdEventHandlerPtr do_connect(AtomPtr addr, int index, int port, int (*handler)(int, FdEventHandlerPtr, ConnectRequestPtr), void *data) { ConnectRequestRec request; FdEventHandlerPtr event; int done, fd, af; assert(addr->length > 0 && addr->string[0] == DNS_A); assert(addr->length % sizeof(HostAddressRec) == 1); if(index >= (addr->length - 1)/ sizeof(HostAddressRec)) index = 0; request.firstindex = index; request.port = port; request.handler = handler; request.data = data; again: af = addr->string[1 + index * sizeof(HostAddressRec)]; fd = serverSocket(af); request.fd = fd; request.af = af; request.addr = addr; request.index = index; if(fd < 0) { int n = (addr->length - 1) / sizeof(HostAddressRec); if(errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) { if((index + 1) % n != request.firstindex) { index = (index + 1) % n; goto again; } } do_log_error(L_ERROR, errno, "Couldn't create socket"); done = (*handler)(-errno, NULL, &request); assert(done); return NULL; } /* POLLIN is apparently needed on Windows */ event = registerFdEvent(fd, POLLIN | POLLOUT, do_scheduled_connect, sizeof(ConnectRequestRec), &request); if(event == NULL) { done = (*handler)(-ENOMEM, NULL, &request); assert(done); return NULL; } done = event->handler(0, event); if(done) { unregisterFdEvent(event); return NULL; } return event; }
int main() { Poco::Net::ServerSocket serverSocket(PORT); Poco::Net::SocketReactor reactor; Poco::Net::SocketAcceptor<Session> acceptor(serverSocket, reactor); std::cout << "Reactor: " << "starting..." << std::endl; reactor.run(); return 0; }
void PothosUtilBase::proxyServer(const std::string &, const std::string &uriStr) { Pothos::init(); //parse the URI const std::string defaultUri = "tcp://0.0.0.0:"+Pothos::RemoteServer::getLocatorPort(); Poco::URI uri(uriStr.empty()?defaultUri:uriStr); const std::string &host = uri.getHost(); const std::string &port = std::to_string(uri.getPort()); if (uri.getScheme() != "tcp") { throw Pothos::Exception("PothosUtil::proxyServer("+uriStr+")", "unsupported URI scheme"); } //create server socket Poco::Net::SocketAddress sa(host, port); Poco::Net::ServerSocket serverSocket(sa); Poco::Net::TCPServerConnectionFactory::Ptr factory(new MyTCPServerConnectionFactory()); Poco::Net::TCPServer tcpServer(factory, serverSocket); //start the server std::cout << "Host: " << serverSocket.address().host().toString() << std::endl; std::cout << "Port: " << serverSocket.address().port() << std::endl; serverSocket.listen(); tcpServer.start(); //monitor active connections in monitor mode if (this->config().hasOption("requireActive")) { //create a TCP connection monitor thread MyTCPConnectionMonitor monitor(tcpServer); Poco::Thread monitorThread; monitorThread.start(monitor); //wait here until the term signal is received this->waitForTerminationRequest(); //end the monitor thread monitor.running = false; monitorThread.join(); } else { //wait here until the term signal is received this->waitForTerminationRequest(); } }
int RestServer::main(const vector<string>& args) { if (!_helpRequested) { unsigned short port = (unsigned short)config().getInt("RestServer.port", 9980); std::string format(config().getString("RestServer.format", DateTimeFormat::SORTABLE_FORMAT)); ServerSocket serverSocket(port); HTTPServer server(new RestRequestRouter(), serverSocket, new HTTPServerParams); server.start(); logger().information("Welcome to PatternRester, the server is running in port 9980."); waitForTerminationRequest(); server.stop(); } return Application::EXIT_OK; }
void child() { int server_sockfd, client_sockfd; if((server_sockfd = serverSocket(IPADDR, PORTNM)) == -1) { fprintf(stderr, "serverSocket"); exit(EXIT_FAILURE); } if(listen(server_sockfd, SOMAXCONN) == -1) { perror("listen"); closeSocket(server_sockfd); exit(EXIT_FAILURE); } if((client_sockfd = clientSocket(server_sockfd)) == -1) { fprintf(stderr, "clientSocket"); exit(EXIT_FAILURE); } mesgWnd(client_sockfd); closeSocket(server_sockfd); closeSocket(client_sockfd); exit(EXIT_SUCCESS); }
bool IOSelector::initListenSocket(util::SocketSet &wakeUpSocketSet) { hazelcast::util::ServerSocket serverSocket(0); int p = serverSocket.getPort(); std::string localAddress; if (serverSocket.isIpv4()) localAddress = "127.0.0.1"; else localAddress = "::1"; wakeUpSocket.reset(new Socket(Address(localAddress, p))); int error = wakeUpSocket->connect(5000); if (error == 0) { sleepingSocket.reset(serverSocket.accept()); sleepingSocket->setBlocking(false); wakeUpSocketSet.insertSocket(sleepingSocket.get()); wakeUpListenerSocketId = sleepingSocket->getSocketId(); return true; } else { util::ILogger::getLogger().severe("IOSelector::initListenSocket " + std::string(strerror(errno))); return false; } }
int main(int argc, char* argv[]) { UINT16 serverPort = 0; ProtoAddress serverAddr; if (3 == argc) // "simple listen <portNumber>" { if (!strncmp("listen", argv[1], strlen(argv[1]))) { if (1 != (sscanf(argv[2], "%hu", &serverPort))) { fprintf(stderr, "simple: bad <port>\n"); serverPort = 0; } } } else if (4 == argc) // "simple connect <serverAddr> <serverPort> { if (!strncmp("connect", argv[1], strlen(argv[1]))) { if (1 != (sscanf(argv[3], "%hu", &serverPort))) { fprintf(stderr, "simple: bad <serverPort>\n"); serverPort = 0; } else if (!serverAddr.ResolveFromString(argv[2])) { fprintf(stderr, "simple: bad <serverAddr>\n"); serverPort = 0; } else { serverAddr.SetPort(serverPort); } } } if (!serverAddr.IsValid() && (0 == serverPort)) { usage(); return -1; } if (serverAddr.IsValid()) // connect to server address as a "client" and make a request { ProtoSocket clientSocket(ProtoSocket::TCP); fprintf(stderr, "simple: client connecting to server: %s/%hu ...\n", serverAddr.GetHostString(), serverAddr.GetPort()); if (!clientSocket.Connect(serverAddr)) { fprintf(stderr, "simple: error connecting to server: %s/%hu\n", serverAddr.GetHostString(), serverAddr.GetPort()); return -1; } fprintf(stderr, "simple: client sending request to server ...\n"); char* clientRequest = "Hello Server, this is a simple protolib client!"; unsigned int length = strlen(clientRequest) + 1; unsigned int sent = 0; while (sent < length) { unsigned int numBytes = length - sent; if (!clientSocket.Send(clientRequest+sent, numBytes)) { fprintf(stderr, "simple: error sending to server\n"); clientSocket.Close(); return -1; } else { sent += numBytes; } } fprintf(stderr, "simple: client awaiting response from server ...\n"); bool receiving = true; while (receiving) { char buffer[256]; buffer[256] = '\0'; unsigned int numBytes = 255; if (!clientSocket.Recv(buffer, numBytes)) { fprintf(stderr, "simple: error receiving from server\n"); clientSocket.Close(); return -1; } else if (numBytes > 0) { fprintf(stdout, "simple: client recvd \"%s\" from server: %s/%hu\n", buffer, serverAddr.GetHostString(), serverAddr.GetPort()); } else { fprintf(stderr, "simple: server shutdown connection.\n"); receiving = false; } } // end while(receiving) clientSocket.Close(); } else // act as a "server" listening to the indicated port, responding to requests { for (;;) { ProtoSocket serverSocket(ProtoSocket::TCP); if (!serverSocket.Listen(serverPort)) { fprintf(stderr, "simple: server error listening\n"); serverSocket.Close(); return -1; } else { fprintf(stderr, "simple: server listening on port:%hu ... (use <CTRL-C> to exit)\n", serverPort); if (!serverSocket.Accept()) { fprintf(stderr, "simple: server error accepting connection\n"); serverSocket.Close(); return -1; } fprintf(stderr, "simple: server accepted connection from client: %s/%hu ...\n", serverSocket.GetDestination().GetHostString(), serverSocket.GetDestination().GetPort()); bool receiving = true; while (receiving) { char buffer[256]; buffer[256] = '\0'; unsigned int numBytes = 255; if (!serverSocket.Recv(buffer, numBytes)) { fprintf(stderr, "simple: error receiving from client\n"); serverSocket.Close(); return -1; } else if (numBytes > 0) { fprintf(stdout, "simple: server recvd \"%s\" from client: %s/%hu\n", buffer, serverSocket.GetDestination().GetHostString(), serverSocket.GetDestination().GetPort()); if (NULL != strchr(buffer, '!')) { fprintf(stderr, "simple: server recvd EOT character '!' from client ...\n"); receiving = false; } break; } else { fprintf(stderr, "simple: client closed connection\n"); receiving = false; } } fprintf(stderr, "simple: server sending response to client ...\n"); char* serverResponse = "Hi there Client, this is a simple protolib server"; unsigned int length = strlen(serverResponse) + 1; unsigned int sent = 0; while (sent < length) { unsigned int numBytes = length - sent; if (!serverSocket.Send(serverResponse+sent, numBytes)) { fprintf(stderr, "simple: error sending to client\n"); serverSocket.Close(); return -1; } else { sent += numBytes; } } serverSocket.Shutdown(); // After "Shutdown" on a blocking socket, ProtoSocket::Recv() will unblock upon // receiving "FIN" from client TCP char buffer[8]; unsigned int numBytes = 8; serverSocket.Recv(buffer, numBytes); if (0!= numBytes) fprintf(stderr, "simple: server received extra data from client?\n\n"); else fprintf(stderr, "simple: server transmission complete.\n\n"); } serverSocket.Close(); } // end for (;;) } } // end main();
int StartServer(const char *nssCertDBDir, SSLSNISocketConfig sniSocketConfig, void *sniSocketConfigArg) { const char *debugLevel = PR_GetEnv("MOZ_TLS_SERVER_DEBUG_LEVEL"); if (debugLevel) { int level = atoi(debugLevel); switch (level) { case DEBUG_ERRORS: gDebugLevel = DEBUG_ERRORS; break; case DEBUG_WARNINGS: gDebugLevel = DEBUG_WARNINGS; break; case DEBUG_VERBOSE: gDebugLevel = DEBUG_VERBOSE; break; default: PrintPRError("invalid MOZ_TLS_SERVER_DEBUG_LEVEL"); return 1; } } const char *callbackPort = PR_GetEnv("MOZ_TLS_SERVER_CALLBACK_PORT"); if (callbackPort) { gCallbackPort = atoi(callbackPort); } if (InitializeNSS(nssCertDBDir) != SECSuccess) { PR_fprintf(PR_STDERR, "InitializeNSS failed"); return 1; } if (NSS_SetDomesticPolicy() != SECSuccess) { PrintPRError("NSS_SetDomesticPolicy failed"); return 1; } if (SSL_ConfigServerSessionIDCache(0, 0, 0, nullptr) != SECSuccess) { PrintPRError("SSL_ConfigServerSessionIDCache failed"); return 1; } UniquePRFileDesc serverSocket(PR_NewTCPSocket()); if (!serverSocket) { PrintPRError("PR_NewTCPSocket failed"); return 1; } PRSocketOptionData socketOption; socketOption.option = PR_SockOpt_Reuseaddr; socketOption.value.reuse_addr = true; PR_SetSocketOption(serverSocket.get(), &socketOption); PRNetAddr serverAddr; PR_InitializeNetAddr(PR_IpAddrLoopback, LISTEN_PORT, &serverAddr); if (PR_Bind(serverSocket.get(), &serverAddr) != PR_SUCCESS) { PrintPRError("PR_Bind failed"); return 1; } if (PR_Listen(serverSocket.get(), 1) != PR_SUCCESS) { PrintPRError("PR_Listen failed"); return 1; } UniquePRFileDesc rawModelSocket(PR_NewTCPSocket()); if (!rawModelSocket) { PrintPRError("PR_NewTCPSocket failed for rawModelSocket"); return 1; } UniquePRFileDesc modelSocket(SSL_ImportFD(nullptr, rawModelSocket.release())); if (!modelSocket) { PrintPRError("SSL_ImportFD of rawModelSocket failed"); return 1; } if (SSL_SNISocketConfigHook(modelSocket.get(), sniSocketConfig, sniSocketConfigArg) != SECSuccess) { PrintPRError("SSL_SNISocketConfigHook failed"); return 1; } // We have to configure the server with a certificate, but it's not one // we're actually going to end up using. In the SNI callback, we pick // the right certificate for the connection. if (ConfigSecureServerWithNamedCert(modelSocket.get(), DEFAULT_CERT_NICKNAME, nullptr, nullptr) != SECSuccess) { return 1; } if (gCallbackPort != 0) { if (DoCallback()) { return 1; } } while (true) { PRNetAddr clientAddr; PRFileDesc* clientSocket = PR_Accept(serverSocket.get(), &clientAddr, PR_INTERVAL_NO_TIMEOUT); HandleConnection(clientSocket, modelSocket); } return 0; }
int do_scheduled_connect(int status, FdEventHandlerPtr event) { ConnectRequestPtr request = (ConnectRequestPtr)&event->data; AtomPtr addr = request->addr; int done; int rc; HostAddressPtr host; struct sockaddr_in servaddr; #ifdef HAVE_IPv6 struct sockaddr_in6 servaddr6; #endif assert(addr->length > 0 && addr->string[0] == DNS_A); assert(addr->length % sizeof(HostAddressRec) == 1); assert(request->index < (addr->length - 1) / sizeof(HostAddressRec)); if(status) { done = request->handler(status, event, request); if(done) { releaseAtom(addr); request->addr = NULL; return 1; } return 0; } again: host = (HostAddressPtr)&addr->string[1 + request->index * sizeof(HostAddressRec)]; if(host->af != request->af) { int newfd; /* Ouch. Our socket has a different protocol than the host address. */ CLOSE(request->fd); newfd = serverSocket(host->af); if(newfd < 0) { if(errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) { int n = request->addr->length / sizeof(HostAddressRec); if((request->index + 1) % n != request->firstindex) { request->index = (request->index + 1) % n; goto again; } } request->fd = -1; done = request->handler(-errno, event, request); assert(done); return 1; } if(newfd != request->fd) { request->fd = dup2(newfd, request->fd); CLOSE(newfd); if(request->fd < 0) { done = request->handler(-errno, event, request); assert(done); return 1; } } request->af = host->af; } switch(host->af) { case 4: memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(request->port); memcpy(&servaddr.sin_addr, &host->data, sizeof(struct in_addr)); rc = connect(request->fd, (struct sockaddr*)&servaddr, sizeof(servaddr)); break; case 6: #ifdef HAVE_IPv6 memset(&servaddr6, 0, sizeof(servaddr6)); servaddr6.sin6_family = AF_INET6; servaddr6.sin6_port = htons(request->port); memcpy(&servaddr6.sin6_addr, &host->data, sizeof(struct in6_addr)); rc = connect(request->fd, (struct sockaddr*)&servaddr6, sizeof(servaddr6)); #else rc = -1; errno = EAFNOSUPPORT; #endif break; default: abort(); } if(rc >= 0 || errno == EISCONN) { done = request->handler(1, event, request); assert(done); releaseAtom(request->addr); request->addr = NULL; return 1; } if(errno == EINPROGRESS || errno == EINTR) { return 0; } else if(errno == EFAULT || errno == EBADF) { abort(); } else { int n = request->addr->length / sizeof(HostAddressRec); if((request->index + 1) % n != request->firstindex) { request->index = (request->index + 1) % n; goto again; } done = request->handler(-errno, event, request); assert(done); releaseAtom(request->addr); request->addr = NULL; return 1; } }
int supervisorMain(bool bOriginalSupervisor) { // Create forked process which will do nothing unless parent dies. Parent continues with initialization. forkSupervisorInWaiting(); // Drop privileges down to the specified user & group const char * sipxpbxuser = SipXecsService::User(); const char * sipxpbxgroup = SipXecsService::Group(); if (NULL == sipxpbxuser || 0 == strlen(sipxpbxuser)) { osPrintf("sipXsupervisor: Failed to setuid(%s), username not defined.\n", sipxpbxuser); return 2; } if (NULL == sipxpbxgroup || 0 == strlen(sipxpbxgroup)) { osPrintf("sipXsupervisor: Failed to setgid(%s), groupname not defined.\n", sipxpbxgroup); return 2; } struct group * grp = getgrnam(sipxpbxgroup); if (NULL == grp) { if (0 != errno) { osPrintf("getgrnam(%s) failed, errno = %d.", sipxpbxgroup, errno); } else { osPrintf( "sipXsupervisor: getgrnam(%s) failed, user does not exist.", sipxpbxgroup); } return 3; } struct passwd * pwd = getpwnam(sipxpbxuser); if (NULL == pwd) { if (0 != errno) { osPrintf("getpwnam(%s) failed, errno = %d.", sipxpbxuser, errno); } else { osPrintf( "sipXsupervisor: getpwnam(%s) failed, user does not exist.", sipxpbxuser); } return 3; } // Change group first, cause once user is changed this cannot be done. if (0 != setgid(grp->gr_gid)) { osPrintf("sipXsupervisor: setgid(%d) failed, errno = %d.", (int)grp->gr_gid, errno); return 4; } if (0 != setuid(pwd->pw_uid)) { osPrintf("sipXsupervisor: setuid(%d) failed, errno = %d.", (int)pwd->pw_uid, errno); return 4; } # if 0 // Only output problems. This keeps the startup output clean. osPrintf("sipXsupervisor: Dropped privileges with setuid(%s)/setgid(%s).", sipxpbxuser, sipxpbxgroup); #endif OsMsgQShared::setQueuePreference(OsMsgQShared::QUEUE_UNLIMITED); // Block all signals in this the main thread // Any threads created after this will have all signals masked. OsTask::blockSignals(); // Create a new task to wait for signals. Only that task // will ever see a signal from the outside. SignalTask* signalTask = new SignalTask(); signalTask->start() ; // All osPrintf output should go to the console until the log file is initialized. enableConsoleOutput(true); // Initialize the log file. Os::LoggerHelper::instance().processName = "Supervisor"; UtlString logFile = SipXecsService::Path(SipXecsService::LogDirType, "sipxsupervisor.log"); Os::LoggerHelper::instance().initialize(PRI_DEBUG, logFile.data()); if (!bOriginalSupervisor) { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_CRIT, "Restarting sipxsupervisor after unexpected shutdown"); } Os::Logger::instance().log(FAC_SUPERVISOR, PRI_NOTICE, ">>>>> Starting sipxsupervisor version %s", VERSION); // Now that the log file is initialized, stop sending osPrintf to the console. // All relevant log messages from this point on must use Os::Logger::instance().log(). enableConsoleOutput(false); fflush(NULL); // Flush all output so children don't get a buffer of output // Open the supervisor configuration file OsConfigDb supervisorConfiguration; OsPath supervisorConfigPath = SipXecsService::Path(SipXecsService::ConfigurationDirType, CONFIG_SETTINGS_FILE); if (OS_SUCCESS != supervisorConfiguration.loadFromFile(supervisorConfigPath.data())) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_WARNING, "Failed to open supervisor configuration file at '%s'", supervisorConfigPath.data() ); } // Set logging based on the supervisor configuration - TODO change default to "NOTICE" ? OsSysLogPriority logPri = SipXecsService::setLogPriority(supervisorConfiguration, SUPERVISOR_PREFIX, PRI_INFO ); Os::Logger::instance().setLoggingPriorityForFacility(FAC_ALARM, logPri); // Open the domain configuration file OsConfigDb domainConfiguration; OsPath domainConfigPath = SipXecsService::domainConfigPath(); if (OS_SUCCESS != domainConfiguration.loadFromFile(domainConfigPath.data())) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_ERR, "Failed to open domain configuration '%s'", domainConfigPath.data() ); } // @TODO const char* managementIpBindAddress; int managementPortNumber; managementPortNumber = domainConfiguration.getPort(SipXecsService::DomainDbKey::SUPERVISOR_PORT); if (PORT_NONE == managementPortNumber) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_WARNING, "%s not configured in '%s', using default: %d", SipXecsService::DomainDbKey::SUPERVISOR_PORT, domainConfigPath.data(), DEFAULT_SUPERVISOR_PORT ); managementPortNumber=DEFAULT_SUPERVISOR_PORT; } else if (PORT_DEFAULT == managementPortNumber) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_NOTICE,"%s set to default: %d", SipXecsService::DomainDbKey::SUPERVISOR_PORT, DEFAULT_SUPERVISOR_PORT ); managementPortNumber=DEFAULT_SUPERVISOR_PORT; } UtlSList allowedPeers; UtlString configHosts; domainConfiguration.get(SipXecsService::DomainDbKey::CONFIG_HOSTS, configHosts); if (!configHosts.isNull()) { UtlString hostName; for (int hostIndex = 0; NameValueTokenizer::getSubField(configHosts.data(), hostIndex, ", \t", &hostName); hostIndex++) { // Found at least one config hostname. if (!allowedPeers.contains(&hostName)) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_DEBUG, "%s value '%s'", SipXecsService::DomainDbKey::CONFIG_HOSTS, hostName.data() ); allowedPeers.insert(new UtlString(hostName)); } } } else { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_ERR, "%s not configured in '%s'", SipXecsService::DomainDbKey::CONFIG_HOSTS, domainConfigPath.data() ); } UtlString superHost; supervisorConfiguration.get(SUPERVISOR_HOST, superHost); if (!superHost.isNull()) { if (!allowedPeers.contains(&superHost)) { allowedPeers.insert(new UtlString(superHost)); } } else { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_ERR, "%s not configured in '%s'", SUPERVISOR_HOST, supervisorConfigPath.data() ); } if (allowedPeers.isEmpty()) { Os::Logger::instance().log(FAC_SUPERVISOR,PRI_ERR, "No configuration peers configured."); } if (!cAlarmServer::getInstance()->init()) { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_ERR, "sipXsupervisor failed to init AlarmServer"); } // Initialize management interfaces on the TLS socket OsSSLServerSocket serverSocket(50, managementPortNumber /*@TODO managementIpBindAddress */); HttpServer httpServer(&serverSocket); // set up but don't start https server XmlRpcDispatch xmlRpcDispatcher(&httpServer); // attach xml-rpc service to https pSipxRpcImpl = new SipxRpc(&xmlRpcDispatcher, allowedPeers); // register xml-rpc methods HttpFileAccess fileAccessService(&httpServer, pSipxRpcImpl); // attach file xfer to https if (serverSocket.isOk()) { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG, "Starting Management HTTP Server"); httpServer.start(); } else { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_ERR, "Management listening socket failure"); } // Read the process definitions. UtlString processDefinitionDirectory = SipXecsService::Path(SipXecsService::DataDirType, "process.d"); SipxProcessManager* processManager = SipxProcessManager::getInstance(); processManager->instantiateProcesses(processDefinitionDirectory); // 3.0 had different process def files. The only important thing in them is the // state of the services. Transfer this state to the new process def files. upgradeFrom3_0(); doWaitLoop(); // Successful run. return 0; }