diff options
| author | Adam <Adam@drink-coca-cola.info> | 2010-04-29 17:31:34 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-06-18 20:58:52 -0400 |
| commit | c1d161dec451ea790ff87078b5d80b1f71a3e9f0 (patch) | |
| tree | 2ada0230d0411d10bb1e710d701874d253a4d4aa /src/protocol | |
| parent | 73e93305c10f349742fad3b2197c6c5dd3aea34e (diff) | |
Rewrote all of the server handling code
Diffstat (limited to 'src/protocol')
| -rw-r--r-- | src/protocol/bahamut.c | 23 | ||||
| -rw-r--r-- | src/protocol/inspircd11.c | 13 | ||||
| -rw-r--r-- | src/protocol/inspircd12.cpp | 29 | ||||
| -rw-r--r-- | src/protocol/ratbox.c | 26 | ||||
| -rw-r--r-- | src/protocol/unreal32.c | 23 |
5 files changed, 50 insertions, 64 deletions
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index 1e38a4aa2..d84d3f25a 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -273,15 +273,15 @@ class BahamutIRCdProto : public IRCDProto /* SERVER */ void SendServer(Server *server) { - send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc); + send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str()); } void SendConnect() { + Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, ""); bahamut_cmd_pass(uplink_server->password); bahamut_cmd_capab(); - me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, ""); - SendServer(me_server); + SendServer(Me); bahamut_cmd_svinfo(); bahamut_cmd_burst(); } @@ -575,11 +575,7 @@ int anope_event_436(const char *source, int ac, const char **av) /* EVENT : SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - - do_server(source, av[0], av[1], av[2], ""); + do_server(source, av[0], atoi(av[1]), av[2], ""); return MOD_CONT; } @@ -711,8 +707,8 @@ int anope_event_error(const char *source, int ac, const char **av) int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); + Server *s = Server::Find(source ? source : ""); + if (!ac) { /* for future use - start burst */ } else { @@ -720,9 +716,10 @@ int anope_event_burst(const char *source, int ac, const char **av) * finished bursting. If there was no source, then our uplink * server finished bursting. -GD */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); + if (!s) + s = Me->GetUplink(); + if (s) + s->Sync(true); } return MOD_CONT; } diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index b5c55cfa8..764b887de 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -204,7 +204,7 @@ class InspIRCdProto : public IRCDProto /* SERVER services-dev.chatspike.net password 0 :Description here */ void SendServer(Server *server) { - send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->name, currentpass, server->hops, server->desc); + send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetDescription().c_str()); } /* JOIN */ @@ -248,9 +248,9 @@ class InspIRCdProto : public IRCDProto void SendConnect() { + Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, ""); inspircd_cmd_pass(uplink_server->password); - me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, ""); - SendServer(me_server); + SendServer(Me); send_cmd(NULL, "BURST"); send_cmd(Config.ServerName, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, Config.ServerName, ircd->name, version_flags, Config.EncModuleList.begin()->c_str(), version_build); } @@ -823,10 +823,7 @@ int anope_event_chghost(const char *source, int ac, const char **av) /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], ""); + do_server(source, av[0], atoi(av[1]), av[2], ""); return MOD_CONT; } @@ -1100,7 +1097,7 @@ int anope_event_capab(const char *source, int ac, const char **av) int anope_event_endburst(const char *source, int ac, const char **av) { - finish_sync(serv_uplink, 1); + Me->GetUplink()->Sync(true); return MOD_CONT; } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 4ad390f00..5ff9db94b 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -209,7 +209,7 @@ class InspIRCdProto : public IRCDProto /* SERVER services-dev.chatspike.net password 0 :Description here */ void SendServer(Server *server) { - send_cmd(NULL, "SERVER %s %s %d %s :%s", server->name, currentpass, server->hops, server->suid, server->desc); + send_cmd(NULL, "SERVER %s %s %d %s :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str()); } /* JOIN */ @@ -252,9 +252,9 @@ class InspIRCdProto : public IRCDProto void SendConnect() { + Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, TS6SID); inspircd_cmd_pass(uplink_server->password); - me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, TS6SID); - SendServer(me_server); + SendServer(Me); send_cmd(TS6SID, "BURST"); send_cmd(TS6SID, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, Config.ServerName, ircd->name, version_flags, Config.EncModuleList.begin()->c_str(), version_build); } @@ -837,7 +837,7 @@ int anope_event_uid(const char *source, int ac, const char **av) User *user; NickAlias *na; struct in_addr addy; - Server *s = findserver_uid(servlist, source); + Server *s = Server::Find(source ? source : ""); uint32 *ad = reinterpret_cast<uint32 *>(&addy); int ts = strtoul(av[1], NULL, 10); @@ -846,7 +846,7 @@ int anope_event_uid(const char *source, int ac, const char **av) user = prev_u_intro; prev_u_intro = NULL; if (user) na = findnick(user->nick); - if (user && user->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != user->Account())) + if (user && !user->server->IsSynced() && (!na || na->nc != user->Account())) { validate_user(user); if (user->HasMode(UMODE_REGISTERED)) @@ -858,14 +858,14 @@ int anope_event_uid(const char *source, int ac, const char **av) user = do_nick("", av[2], /* nick */ av[5], /* username */ av[3], /* realhost */ - s->name, /* server */ + s->GetName().c_str(), /* server */ av[ac - 1], /* realname */ ts, htonl(*ad), av[4], av[0]); if (user) { UserSetInternalModes(user, 1, &av[8]); user->SetCloakedHost(av[4]); - if (user->server->sync == SSYNC_IN_PROGRESS) + if (!user->server->IsSynced()) { prev_u_intro = user; } @@ -903,11 +903,7 @@ int anope_event_chghost(const char *source, int ac, const char **av) */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[2], "0")) - { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[2], av[4], av[3]); + do_server(source, av[0], atoi(av[2]), av[4], av[3]); return MOD_CONT; } @@ -1308,7 +1304,8 @@ int anope_event_endburst(const char *source, int ac, const char **av) { NickAlias *na; User *u = prev_u_intro; - Server *s = findserver_uid(servlist, source); + Server *s = Server::Find(source ? source : ""); + if (!s) { throw new CoreException("Got ENDBURST without a source"); @@ -1318,16 +1315,16 @@ int anope_event_endburst(const char *source, int ac, const char **av) * If not, validate the user. ~ Viper*/ prev_u_intro = NULL; if (u) na = findnick(u->nick); - if (u && u->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != u->Account())) + if (u && !u->server->IsSynced() && (!na || na->nc != u->Account())) { validate_user(u); if (u->HasMode(UMODE_REGISTERED)) u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED); } - Alog() << "Processed ENDBURST for " << s->name; + Alog() << "Processed ENDBURST for " << s->GetName(); - finish_sync(s, 1); + s->Sync(true); return MOD_CONT; } diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index 8d0a84826..ace2a650c 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -14,6 +14,8 @@ #include "services.h" #include "pseudo.h" +static char *TS6UPLINK = NULL; // XXX is this needed? + IRCDVar myIrcd[] = { {"Ratbox 2.0+", /* ircd name */ "+oi", /* Modes used by pseudoclients */ @@ -190,16 +192,16 @@ class RatboxProto : public IRCDTS6Proto /* SERVER name hop descript */ void SendServer(Server *server) { - send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc); + send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str()); } void SendConnect() { + Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, TS6SID); ratbox_cmd_pass(uplink_server->password); ratbox_cmd_capab(); /* Make myself known to myself in the serverlist */ - me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, TS6SID); - SendServer(me_server); + SendServer(Me); ratbox_cmd_svinfo(); } @@ -457,14 +459,13 @@ int anope_event_sjoin(const char *source, int ac, const char **av) */ int anope_event_nick(const char *source, int ac, const char **av) { - Server *s; User *user; if (ac == 9) { - s = findserver_uid(servlist, source); + Server *s = Server::Find(source ? source : ""); /* Source is always the server */ - user = do_nick("", av[0], av[4], av[5], s->name, av[8], + user = do_nick("", av[0], av[4], av[5], s->GetName().c_str(), av[8], strtoul(av[2], NULL, 10), 0, "*", av[7]); if (user) { @@ -681,27 +682,24 @@ int anope_event_whois(const char *source, int ac, const char **av) int anope_event_server(const char *source, int ac, const char **av) { if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); if (TS6UPLINK) { - do_server(source, av[0], av[1], av[2], TS6UPLINK); + do_server(source, av[0], atoi(av[1]), av[2], TS6UPLINK); } else { - do_server(source, av[0], av[1], av[2], ""); + do_server(source, av[0], atoi(av[1]), av[2], ""); } } else { - do_server(source, av[0], av[1], av[2], ""); + do_server(source, av[0], atoi(av[1]), av[2], ""); } return MOD_CONT; } int anope_event_sid(const char *source, int ac, const char **av) { - Server *s; - /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ - s = findserver_uid(servlist, source); + Server *s = Server::Find(source); - do_server(s->name, av[0], av[1], av[3], av[2]); + do_server(s->GetName(), av[0], atoi(av[1]), av[3], av[2]); return MOD_CONT; } diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 3564fecd6..aeb35ee88 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -216,9 +216,9 @@ class UnrealIRCdProto : public IRCDProto void SendServer(Server *server) { if (Config.Numeric) - send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", server->name, server->hops, Config.Numeric, server->desc); + send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", server->GetName().c_str(), server->GetHops(), Config.Numeric, server->GetDescription().c_str()); else - send_cmd(NULL, "SERVER %s %d :%s", server->name, server->hops, server->desc); + send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str()); } /* JOIN */ @@ -286,10 +286,10 @@ class UnrealIRCdProto : public IRCDProto void SendConnect() { + Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, (Config.Numeric ? Config.Numeric : "")); unreal_cmd_capab(); unreal_cmd_pass(uplink_server->password); - me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, (Config.Numeric ? Config.Numeric : "")); - SendServer(me_server); + SendServer(Me); } /* SVSHOLD - set */ @@ -701,7 +701,7 @@ int anope_event_mode(const char *source, int ac, const char **av) /* This is used to strip the TS from the end of the mode stirng */ int anope_event_gmode(const char *source, int ac, const char **av) { - if (findserver(servlist, source)) + if (Server::Find(source)) --ac; return anope_event_mode(source, ac, av); } @@ -966,16 +966,15 @@ int anope_event_server(const char *source, int ac, const char **av) char *upnumeric; if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); vl = myStrGetToken(av[2], ' ', 0); upnumeric = myStrGetToken(vl, '-', 2); desc = myStrGetTokenRemainder(av[2], ' ', 1); - do_server(source, av[0], av[1], desc, upnumeric); + do_server(source, av[0], atoi(av[1]), desc, upnumeric); delete [] vl; delete [] desc; delete [] upnumeric; } else { - do_server(source, av[0], av[1], av[2], ""); + do_server(source, av[0], atoi(av[1]), av[2], ""); } ircdproto->SendPing(Config.ServerName, av[0]); @@ -1021,12 +1020,10 @@ int anope_event_error(const char *source, int ac, const char **av) int anope_event_sdesc(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); + Server *s = Server::Find(source ? source : ""); - if (s) { - s->desc = const_cast<char *>(av[0]); // XXX Unsafe cast -- CyberBotX - } + if (s) + s->SetDescription(av[0]); return MOD_CONT; } |
