summaryrefslogtreecommitdiff
path: root/src/servers.c
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-02-08 03:09:19 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-02-08 03:09:19 +0000
commit512b5bdaf3b9de1c1cb1d78b921269f78b82e97b (patch)
tree2435caac310109ddcc04bcef4595b60245f5fb8a /src/servers.c
parentf4db8c5360a71bf2c815602ade39800033f7ae16 (diff)
Rewrote & fixed CAPAB support
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2786 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/servers.c')
-rw-r--r--src/servers.c85
1 files changed, 52 insertions, 33 deletions
diff --git a/src/servers.c b/src/servers.c
index 474f4f3e1..959e2be2d 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -18,7 +18,7 @@
Server *servlist = NULL;
Server *me_server = NULL; /* This are we */
Server *serv_uplink = NULL; /* This is our uplink */
-uint32 uplink_capab;
+Flags<CapabType> Capab;
char *uplink;
char *TS6UPLINK;
char *TS6SID;
@@ -26,7 +26,7 @@ char *TS6SID;
/* For first_server / next_server */
static Server *server_cur;
-CapabInfo capab_info[] = {
+CapabInfo Capab_Info[] = {
{"NOQUIT", CAPAB_NOQUIT},
{"TSMODE", CAPAB_TSMODE},
{"UNCONNECT", CAPAB_UNCONNECT},
@@ -53,7 +53,7 @@ CapabInfo capab_info[] = {
{"SJB64", CAPAB_SJB64},
{"CHANMODES", CAPAB_CHANMODE},
{"NICKCHARS", CAPAB_NICKCHARS},
- {NULL, CAPAB_END}
+ {"", CAPAB_END}
};
/*************************************************************************/
@@ -204,33 +204,30 @@ static void delete_server(Server * serv, const char *quitreason)
<< (serv->uplink ? serv->uplink->name : "NOTHING") << "("
<< (serv->uplink ? serv->uplink->suid : "NOSUIDUPLINK") << ")";
- if (ircdcap->noquit || ircdcap->qs) {
- if ((uplink_capab & ircdcap->noquit)
- || (uplink_capab & ircdcap->qs)) {
- u = firstuser();
- while (u) {
- unext = nextuser();
- if (u->server == serv)
- {
- if ((na = findnick(u->nick)) && !na->HasFlag(NS_FORBIDDEN)
- && (!na->nc->HasFlag(NI_SUSPENDED))
- && (u->IsRecognized() || u->IsIdentified())) {
- na->last_seen = time(NULL);
- if (na->last_quit)
- delete [] na->last_quit;
- na->last_quit =
- (quitreason ? sstrdup(quitreason) : NULL);
- }
-
+ if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS))
+ {
+ u = firstuser();
+ while (u)
+ {
+ unext = nextuser();
+ if (u->server == serv)
+ {
+ if ((na = findnick(u->nick)) && !na->HasFlag(NS_FORBIDDEN)
+ && (!na->nc->HasFlag(NI_SUSPENDED))
+ && (u->IsRecognized() || u->IsIdentified())) {
+ na->last_seen = time(NULL);
+ if (na->last_quit)
+ delete [] na->last_quit;
+ na->last_quit = (quitreason ? sstrdup(quitreason) : NULL);
+ }
if (Config.LimitSessions && !is_ulined(u->server->name)) {
- del_session(u->host);
- }
- delete u;
+ del_session(u->host);
}
- u = unext;
+ delete u;
}
- Alog(LOG_DEBUG) << "delete_server() cleared all users";
+ u = unext;
}
+ Alog(LOG_DEBUG) << "delete_server() cleared all users";
}
s = serv->links;
@@ -445,13 +442,11 @@ void do_squit(const char *source, int ac, const char **av)
snprintf(buf, sizeof(buf), "%s %s", s->name,
(s->uplink ? s->uplink->name : ""));
- if (ircdcap->unconnect) {
- if ((s->uplink == me_server)
- && (uplink_capab & ircdcap->unconnect)) {
- Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->name;
- /* need to fix */
- ircdproto->SendSquit(s->name, buf);
- }
+ if (s->uplink == me_server && Capab.HasFlag(CAPAB_UNCONNECT))
+ {
+ Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->name;
+ /* need to fix */
+ ircdproto->SendSquit(s->name, buf);
}
delete_server(s, buf);
@@ -459,6 +454,30 @@ void do_squit(const char *source, int ac, const char **av)
/*************************************************************************/
+/** Handle parsing the CAPAB/PROTOCTL messages
+ * @param ac Number of args
+ * @param av Args
+ */
+void CapabParse(int ac, const char **av)
+{
+ for (int i = 0; i < ac; ++i)
+ {
+ for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j)
+ {
+ if (av[i] == Capab_Info[j].Token)
+ {
+ Capab.SetFlag(Capab_Info[j].Flag);
+
+ if (Capab_Info[j].Token == "NICKIP" && !ircd->nickip)
+ ircd->nickip = 1;
+ break;
+ }
+ }
+ }
+}
+
+/*************************************************************************/
+
/**
* Search the uline servers array to find out if the server that just set the
* mode is in our uline list