diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-14 17:57:12 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-14 17:57:12 +0000 |
commit | 6de0aaaef692aa6a30e77cc76cf6e80bbc6e4500 (patch) | |
tree | 40b6fbcf60c75d5307bce5e96335395c6d3c0954 | |
parent | 417432f2be811573326b8366783020fa1fd63eec (diff) |
Moved BindPorts out of main file into inspircd_io.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2430 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/inspircd_io.h | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 51 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 50 | ||||
-rw-r--r-- | src/inspircd_util.cpp | 2 |
4 files changed, 53 insertions, 51 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h index 62086f265..58c018c25 100644 --- a/include/inspircd_io.h +++ b/include/inspircd_io.h @@ -275,5 +275,6 @@ bool FileExists (const char* file); int OpenTCPSocket (void); int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr); void WritePID(std::string filename); +int BindPorts(); #endif diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 4cab20c52..cb2360c41 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -469,7 +469,7 @@ InspIRCd::InspIRCd(int argc, char** argv) lowermap[(unsigned)'\\'] = '|'; - OpenLog(argc, argv); + OpenLog(argv, argc); Config->ClearStack(); Config->Read(true,NULL); CheckRoot(); @@ -1519,55 +1519,6 @@ bool LoadModule(const char* filename) return true; } -int BindPorts() -{ - char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; - int clientportcount = 0; - for (int count = 0; count < Config->ConfValueEnum("bind",&Config->config_f); count++) - { - Config->ConfValue("bind","port",count,configToken,&Config->config_f); - Config->ConfValue("bind","address",count,Addr,&Config->config_f); - Config->ConfValue("bind","type",count,Type,&Config->config_f); - if (strcmp(Type,"servers")) - { - // modules handle server bind types now, - // its not a typo in the strcmp. - ports[clientportcount] = atoi(configToken); - strlcpy(Config->addrs[clientportcount],Addr,256); - clientportcount++; - log(DEBUG,"InspIRCd: startup: read binding %s:%s [%s] from config",Addr,configToken, Type); - } - } - portCount = clientportcount; - - for (int count = 0; count < portCount; count++) - { - if ((openSockfd[boundPortCount] = OpenTCPSocket()) == ERROR) - { - log(DEBUG,"InspIRCd: startup: bad fd %lu",(unsigned long)openSockfd[boundPortCount]); - return(ERROR); - } - if (BindSocket(openSockfd[boundPortCount],client,server,ports[count],Config->addrs[count]) == ERROR) - { - log(DEFAULT,"InspIRCd: startup: failed to bind port %lu",(unsigned long)ports[count]); - } - else /* well we at least bound to one socket so we'll continue */ - { - boundPortCount++; - } - } - - /* if we didn't bind to anything then abort */ - if (!boundPortCount) - { - log(DEFAULT,"InspIRCd: startup: no ports bound, bailing!"); - printf("\nERROR: Was not able to bind any of %lu ports! Please check your configuration.\n\n", (unsigned long)portCount); - return (ERROR); - } - - return boundPortCount; -} - int InspIRCd::Run() { bool expire_run = false; diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index c435de383..631cf397a 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -1023,3 +1023,53 @@ int OpenTCPSocket (void) return (sockfd); } } + +int BindPorts() +{ + char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; + int clientportcount = 0; + for (int count = 0; count < Config->ConfValueEnum("bind",&Config->config_f); count++) + { + Config->ConfValue("bind","port",count,configToken,&Config->config_f); + Config->ConfValue("bind","address",count,Addr,&Config->config_f); + Config->ConfValue("bind","type",count,Type,&Config->config_f); + if (strcmp(Type,"servers")) + { + // modules handle server bind types now, + // its not a typo in the strcmp. + ports[clientportcount] = atoi(configToken); + strlcpy(Config->addrs[clientportcount],Addr,256); + clientportcount++; + log(DEBUG,"InspIRCd: startup: read binding %s:%s [%s] from config",Addr,configToken, Type); + } + } + portCount = clientportcount; + + for (int count = 0; count < portCount; count++) + { + if ((openSockfd[boundPortCount] = OpenTCPSocket()) == ERROR) + { + log(DEBUG,"InspIRCd: startup: bad fd %lu",(unsigned long)openSockfd[boundPortCount]); + return(ERROR); + } + if (BindSocket(openSockfd[boundPortCount],client,server,ports[count],Config->addrs[count]) == ERROR) + { + log(DEFAULT,"InspIRCd: startup: failed to bind port %lu",(unsigned long)ports[count]); + } + else /* well we at least bound to one socket so we'll continue */ + { + boundPortCount++; + } + } + + /* if we didn't bind to anything then abort */ + if (!boundPortCount) + { + log(DEFAULT,"InspIRCd: startup: no ports bound, bailing!"); + printf("\nERROR: Was not able to bind any of %lu ports! Please check your configuration.\n\n", (unsigned long)portCount); + return (ERROR); + } + + return boundPortCount; +} + diff --git a/src/inspircd_util.cpp b/src/inspircd_util.cpp index d75ca0a11..0636c614b 100644 --- a/src/inspircd_util.cpp +++ b/src/inspircd_util.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * Inspire is copyright (C) 2002-2005 ChatSpike-Dev. * E-mail: * <brain@chatspike.net> * <Craig@chatspike.net> |