summaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-08 20:23:00 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-08 20:23:00 +0000
commit973ecb7058325931d14a9537e5e3e57595347a10 (patch)
tree43585f36085949a1b494374572fa4e3dc25b0960 /src/init.c
parente1ff14e0c44d0a115372a821559b782c57c793f3 (diff)
Rewrote sockets. This adds support for IPv6 and makes Anope capable of reconnecting if it loses connection to the uplink.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2862 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c55
1 files changed, 7 insertions, 48 deletions
diff --git a/src/init.c b/src/init.c
index 5a819dcfe..e527f32c5 100644
--- a/src/init.c
+++ b/src/init.c
@@ -367,14 +367,6 @@ int init_secondary(int ac, char **av)
}
}
#else
- /* Initialize winsocks -- codemastr */
- {
- WSADATA wsa;
- if (WSAStartup(MAKEWORD(1, 1), &wsa)) {
- Alog() << "Failed to initialized WinSock library";
- return -1;
- }
- }
if (!SupportedWindowsVersion()) {
char *winver = GetWindowsVersion();
@@ -487,56 +479,23 @@ int init_secondary(int ac, char **av)
if (!bi)
{
if (Config.s_OperServ)
- bi = new BotInfo(Config.s_OperServ, Config.ServiceUser, Config.ServiceHost, Config.desc_OperServ);
+ new BotInfo(Config.s_OperServ, Config.ServiceUser, Config.ServiceHost, Config.desc_OperServ);
if (Config.s_NickServ)
- bi = new BotInfo(Config.s_NickServ, Config.ServiceUser, Config.ServiceHost, Config.desc_NickServ);
+ new BotInfo(Config.s_NickServ, Config.ServiceUser, Config.ServiceHost, Config.desc_NickServ);
if (Config.s_ChanServ)
- bi = new BotInfo(Config.s_ChanServ, Config.ServiceUser, Config.ServiceHost, Config.desc_ChanServ);
+ new BotInfo(Config.s_ChanServ, Config.ServiceUser, Config.ServiceHost, Config.desc_ChanServ);
if (Config.s_HostServ)
- bi = new BotInfo(Config.s_HostServ, Config.ServiceUser, Config.ServiceHost, Config.desc_HostServ);
+ new BotInfo(Config.s_HostServ, Config.ServiceUser, Config.ServiceHost, Config.desc_HostServ);
if (Config.s_MemoServ)
- bi = new BotInfo(Config.s_MemoServ, Config.ServiceUser, Config.ServiceHost, Config.desc_MemoServ);
+ new BotInfo(Config.s_MemoServ, Config.ServiceUser, Config.ServiceHost, Config.desc_MemoServ);
if (Config.s_BotServ)
- bi = new BotInfo(Config.s_BotServ, Config.ServiceUser, Config.ServiceHost, Config.desc_BotServ);
+ new BotInfo(Config.s_BotServ, Config.ServiceUser, Config.ServiceHost, Config.desc_BotServ);
if (Config.s_GlobalNoticer)
- bi = new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer);
+ new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer);
}
FOREACH_MOD(I_OnPostLoadDatabases, OnPostLoadDatabases());
- FOREACH_MOD(I_OnPreServerConnect, OnPreServerConnect());
-
- /* Connect to the remote server */
- std::list<Uplink *>::iterator curr_uplink = Config.Uplinks.begin(), end_uplink = Config.Uplinks.end();
- int servernum = 1;
- for (; curr_uplink != end_uplink; ++curr_uplink, ++servernum) {
- uplink_server = *curr_uplink;
- servsock = conn(uplink_server->host, uplink_server->port, Config.LocalHost, Config.LocalPort);
- if (servsock >= 0) {
- Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")";
- break;
- }
- }
- if (curr_uplink == end_uplink) fatal_perror("Can't connect to any servers");
-
- ircdproto->SendConnect();
- FOREACH_MOD(I_OnServerConnect, OnServerConnect());
-
- sgets2(inbuf, sizeof(inbuf), servsock);
- if (strnicmp(inbuf, "ERROR", 5) == 0) {
- /* Close server socket first to stop wallops, since the other
- * server doesn't want to listen to us anyway */
- disconn(servsock);
- servsock = -1;
- fatal("Remote server returned: %s", inbuf);
- }
-
- /* Announce a logfile error if there was one */
- if (openlog_failed) {
- ircdproto->SendGlobops(NULL, "Warning: couldn't open logfile: %s",
- strerror(openlog_errno));
- }
- /* Success! */
return 0;
}