summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/helperfuncs.h7
-rw-r--r--include/inspircd.h5
-rw-r--r--include/socketengine.h74
-rw-r--r--src/commands.cpp53
-rw-r--r--src/connection.cpp4
-rw-r--r--src/helperfuncs.cpp231
-rw-r--r--src/inspircd.cpp308
-rw-r--r--src/message.cpp13
-rw-r--r--src/mode.cpp16
-rw-r--r--src/servers.cpp27
10 files changed, 76 insertions, 662 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h
index 0e8ba33ff..53a3d233b 100644
--- a/include/helperfuncs.h
+++ b/include/helperfuncs.h
@@ -43,13 +43,6 @@ void WriteOpers(char* text, ...);
void NoticeAllOpers(userrec *source, bool local_only, char* text, ...);
bool ChanAnyOnThisServer(chanrec *c,char* servername);
bool CommonOnThisServer(userrec* u,const char* servername);
-void NetSendToCommon(userrec* u, char* s);
-void NetSendToAll(char* s);
-void NetSendToAll_WithSum(char* s,char* u);
-void NetSendToAllAlive(char* s);
-void NetSendToOne(char* target,char* s);
-void NetSendToAllExcept(const char* target,char* s);
-void NetSendToAllExcept_WithSum(const char* target,char* s,char* u);
void WriteMode(const char* modes, int flags, const char* text, ...);
void NoticeAll(userrec *source, bool local_only, char* text, ...);
void WriteWallOps(userrec *source, bool local_only, char* text, ...);
diff --git a/include/inspircd.h b/include/inspircd.h
index 7880b72fc..742205fe5 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -109,11 +109,6 @@ char* ModuleError();
void NoticeAll(userrec *source, bool local_only, char* text, ...);
void NoticeAllOpers(userrec *source, bool local_only, char* text, ...);
-void NetSendMyRoutingTable();
-void DoSplit(const char* params);
-void RemoveServer(const char* name);
-void DoSync(serverrec* serv, char* tcp_host);
-
// optimization tricks to save us walking the user hash
void AddOper(userrec* user);
diff --git a/include/socketengine.h b/include/socketengine.h
index 5c5eca1d2..33dc77894 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -264,6 +264,80 @@
#define engine_add_fd select_add_fd
#endif
+#define select_server_fill log(DEFAULT,"Using standard select socket engine.");
+
+#define epoll_server_fill log(DEFAULT,"epoll socket engine is enabled. Filling listen list. boundPortcount=%d",boundPortCount); \
+ for (count = 0; count < boundPortCount; count++) \
+ { \
+ struct epoll_event ev; \
+ log(DEBUG,"epoll: Add listening socket to events, ep=%d socket=%d",lep,openSockfd[count]); \
+ ev.events = EPOLLIN | EPOLLET; \
+ ev.data.fd = openSockfd[count]; \
+ int i = epoll_ctl(lep, EPOLL_CTL_ADD, openSockfd[count], &ev); \
+ if (i < 0) \
+ { \
+ log(DEFAULT,"main: add listen ports, epoll_ctl failed!"); \
+ printf("ERROR: could not initialise listening sockets in epoll list. Shutting down.\n"); \
+ Exit(ERROR); \
+ } \
+ } \
+ for (int t = 0; t != SERVERportCount; t++) \
+ { \
+ struct epoll_event ev; \
+ log(DEBUG,"epoll: Add listening server socket to events, ep=%d socket=%d",sep,me[t]->fd); \
+ ev.events = EPOLLIN | EPOLLET; \
+ ev.data.fd = me[t]->fd; \
+ int i = epoll_ctl(sep, EPOLL_CTL_ADD, me[t]->fd, &ev); \
+ if (i == -1) \
+ { \
+ log(DEFAULT,"main: add server listen ports, epoll_ctl failed!"); \
+ printf("ERROR: could not initialise server listening sockets in epoll list. Shutting down.\n"); \
+ Exit(ERROR); \
+ } \
+ }
+
+#define kqueue_server_fill log(DEFAULT,"kqueue socket engine is enabled. Filling listen list."); \
+ for (count = 0; count < boundPortCount; count++) \
+ { \
+ struct kevent ke; \
+ log(DEBUG,"kqueue: Add listening socket to events, kq=%d socket=%d",lkq,openSockfd[count]); \
+ EV_SET(&ke, openSockfd[count], EVFILT_READ, EV_ADD, 0, MaxConn, NULL); \
+ int i = kevent(lkq, &ke, 1, 0, 0, NULL); \
+ if (i == -1) \
+ { \
+ log(DEFAULT,"main: add listen ports to kqueue failed!"); \
+ printf("ERROR: could not initialise listening sockets in kqueue. Shutting down.\n"); \
+ Exit(ERROR); \
+ } \
+ } \
+ for (int t = 0; t != SERVERportCount; t++) \
+ { \
+ struct kevent ke; \
+ if (me[t]) \
+ { \
+ log(DEBUG,"kqueue: Add listening SERVER socket to events, kq=%d socket=%d",skq,me[t]->fd); \
+ EV_SET(&ke, me[t]->fd, EVFILT_READ, EV_ADD, 0, MaxConn, NULL); \
+ int i = kevent(skq, &ke, 1, 0, 0, NULL); \
+ if (i == -1) \
+ { \
+ log(DEFAULT,"main: add server listen ports to kqueue failed!"); \
+ printf("ERROR: could not initialise listening server sockets in kqueue. Shutting down.\n"); \
+ Exit(ERROR); \
+ } \
+ } \
+ }
+
+#ifdef USE_EPOLL
+#define engine_server_fill epoll_server_fill
+#endif
+#ifdef USE_KQUEUE
+#define engine_server_fill kqueue_server_fill
+#endif
+#ifdef USE_SELECT
+#define engine_server_fill select_server_fill
+#endif
+
+
// what is this engine called?
#ifdef USE_KQUEUE
diff --git a/src/commands.cpp b/src/commands.cpp
index d61c77f74..d286a31e3 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -231,10 +231,6 @@ void handle_kick(char **parameters, int pcnt, userrec *user)
kick_channel(user,u,Ptr,reason);
}
- // this must be propogated so that channel membership is kept in step network-wide
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"k %s %s %s :%s",user->nick,u->nick,Ptr->name,reason);
- NetSendToAll(buffer);
}
void handle_loadmodule(char **parameters, int pcnt, userrec *user)
@@ -340,10 +336,6 @@ void handle_kill(char **parameters, int pcnt, userrec *user)
WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
snprintf(killreason,MAXBUF,"[%s] Killed (%s (%s))",ServerName,user->nick,parameters[1]);
WriteCommonExcept(u,"QUIT :%s",killreason);
- // K token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"K %s %s :%s",user->nick,u->nick,killreason);
- NetSendToAll(buffer);
user_hash::iterator iter = clientlist.find(u->nick);
if (iter != clientlist.end())
@@ -453,10 +445,6 @@ void handle_invite(char **parameters, int pcnt, userrec *user)
WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
WriteServ(user->fd,"341 %s %s %s",user->nick,u->nick,c->name);
- // i token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"i %s %s %s",u->nick,user->nick,c->name);
- NetSendToAll(buffer);
}
else
{
@@ -544,10 +532,6 @@ void handle_topic(char **parameters, int pcnt, userrec *user)
Ptr->topicset = TIME;
WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
- // t token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"t %s %s :%s",user->nick,Ptr->name,topic);
- NetSendToAll(buffer);
}
else
{
@@ -628,10 +612,6 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user)
ChanExceptSender(chan, user, "PRIVMSG %s :%s", chan->name, parameters[1]);
- // if any users of this channel are on remote servers, broadcast the packet
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"P %s %s :%s",user->nick,chan->name,parameters[1]);
- NetSendToCommon(user,buffer);
}
else
{
@@ -666,12 +646,6 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user)
// direct write, same server
WriteTo(user, dest, "PRIVMSG %s :%s", dest->nick, parameters[1]);
}
- else
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"P %s %s :%s",user->nick,dest->nick,parameters[1]);
- NetSendToOne(dest->server,buffer);
- }
}
else
{
@@ -722,10 +696,6 @@ void handle_notice(char **parameters, int pcnt, userrec *user)
ChanExceptSender(chan, user, "NOTICE %s :%s", chan->name, parameters[1]);
- // if any users of this channel are on remote servers, broadcast the packet
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"V %s %s :%s",user->nick,chan->name,parameters[1]);
- NetSendToCommon(user,buffer);
}
else
{
@@ -752,12 +722,6 @@ void handle_notice(char **parameters, int pcnt, userrec *user)
// direct write, same server
WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
}
- else
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"V %s %s :%s",user->nick,dest->nick,parameters[1]);
- NetSendToOne(dest->server,buffer);
- }
}
else
{
@@ -902,9 +866,6 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,PrefixQuit,parameters[0]);
WriteCommonExcept(user,"QUIT :%s%s",PrefixQuit,parameters[0]);
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"Q %s :%s%s",user->nick,PrefixQuit,parameters[0]);
- NetSendToAll(buffer);
}
else
{
@@ -912,9 +873,6 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
WriteCommonExcept(user,"QUIT :Client exited");
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"Q %s :Client exited",user->nick);
- NetSendToAll(buffer);
}
FOREACH_MOD OnUserQuit(user);
AddWhoWas(user);
@@ -1606,8 +1564,6 @@ void handle_oper(char **parameters, int pcnt, userrec *user)
if (!strcmp(TypeName,OperType))
{
/* found this oper's opertype */
- snprintf(global,MAXBUF,"| %s %s",user->nick,TypeName);
- NetSendToAll(global);
ConfValue("type","host",j,HostName,&config_f);
if (*HostName)
ChangeDisplayedHost(user,HostName);
@@ -1630,8 +1586,6 @@ void handle_oper(char **parameters, int pcnt, userrec *user)
{
strcat(user->modes,"o");
WriteServ(user->fd,"MODE %s :+o",user->nick);
- snprintf(global,MAXBUF,"M %s +o",user->nick);
- NetSendToAll(global);
FOREACH_MOD OnOper(user);
log(DEFAULT,"OPER: %s!%s@%s opered as type: %s",user->nick,user->ident,user->host,OperType);
AddOper(user);
@@ -1725,10 +1679,6 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
WriteCommon(user,"NICK %s",parameters[0]);
- // N token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"n %s %s",user->nick,parameters[0]);
- NetSendToAll(buffer);
}
char oldnick[NICKMAX];
@@ -1881,9 +1831,6 @@ void handle_gline(char **parameters, int pcnt, userrec *user)
if (pcnt >= 3)
{
add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- // # <mask> <who-set-it> <time-set> <duration> :<reason>
- snprintf(netdata,MAXBUF,"# %s %s %lu %lu :%s",parameters[0],user->nick,(unsigned long)TIME,(unsigned long)duration(parameters[1]),parameters[2]);
- NetSendToAll(netdata);
if (!duration(parameters[1]))
{
WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]);
diff --git a/src/connection.cpp b/src/connection.cpp
index 14c108fd5..d8ebefdf5 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -384,10 +384,6 @@ int ircd_connector::GetState()
void ircd_connector::SetState(int newstate)
{
this->state = newstate;
- if (state == STATE_DISCONNECTED)
- {
- NetSendMyRoutingTable();
- }
}
void ircd_connector::CloseConnection()
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 736ca14f8..d6df39dbb 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -548,12 +548,6 @@ void NoticeAllOpers(userrec *source, bool local_only, char* text, ...)
}
}
- if (!local_only)
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"V %s @* :%s",source->nick,textbuffer);
- NetSendToAll(buffer);
- }
}
// returns TRUE of any users on channel C occupy server 'servername'.
@@ -595,217 +589,6 @@ bool CommonOnThisServer(userrec* u,const char* servername)
return false;
}
-void NetSendToCommon(userrec* u, char* s)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,"%s %s",CreateSum().c_str(),s);
-
- log(DEBUG,"NetSendToCommon: '%s' '%s'",u->nick,s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (CommonOnThisServer(u,me[j]->connectors[k].GetServerName().c_str()))
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
- }
-}
-
-
-void NetSendToAll(char* s)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,"%s %s",CreateSum().c_str(),s);
-
- log(DEBUG,"NetSendToAll: '%s'",s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
-}
-
-
-void NetSendToAll_WithSum(char* s,char* u)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,":%s %s",u,s);
-
- log(DEBUG,"NetSendToAll: '%s'",s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
-}
-
-void NetSendToAllAlive(char* s)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,"%s %s",CreateSum().c_str(),s);
-
- log(DEBUG,"NetSendToAllAlive: '%s'",s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (me[j]->connectors[k].GetState() != STATE_DISCONNECTED)
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- else
- {
- log(DEBUG,"%s is dead, not sending to it.",me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
- }
-}
-
-
-void NetSendToOne(char* target,char* s)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,"%s %s",CreateSum().c_str(),s);
-
- log(DEBUG,"NetSendToOne: '%s' '%s'",target,s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),target))
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
- }
-}
-
-void NetSendToAllExcept(const char* target,char* s)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,"%s %s",CreateSum().c_str(),s);
-
- log(DEBUG,"NetSendToAllExcept: '%s' '%s'",target,s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (strcasecmp(me[j]->connectors[k].GetServerName().c_str(),target))
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
- }
-}
-
-void NetSendToAllExcept_WithSum(const char* target,char* s,char* u)
-{
- char buffer[MAXBUF];
- if (*s == ':')
- {
- snprintf(buffer,MAXBUF,"%s",s);
- }
- else snprintf(buffer,MAXBUF,":%s %s",u,s);
-
- log(DEBUG,"NetSendToAllExcept: '%s' '%s'",target,s);
-
- std::string msg = buffer;
- FOREACH_MOD OnPacketTransmit(msg,s);
- strlcpy(buffer,msg.c_str(),MAXBUF);
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (strcasecmp(me[j]->connectors[k].GetServerName().c_str(),target))
- {
- me[j]->SendPacket(buffer,me[j]->connectors[k].GetServerName().c_str());
- }
- }
- }
- }
-}
-
void WriteMode(const char* modes, int flags, const char* text, ...)
{
@@ -883,13 +666,6 @@ void NoticeAll(userrec *source, bool local_only, char* text, ...)
}
}
- if (!local_only)
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"V %s * :%s",source->nick,textbuffer);
- NetSendToAll(buffer);
- }
-
}
@@ -917,13 +693,6 @@ void WriteWallOps(userrec *source, bool local_only, char* text, ...)
}
}
}
-
- if (!local_only)
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"@ %s :%s",source->nick,textbuffer);
- NetSendToAll(buffer);
- }
}
/* convert a string to lowercase. Note following special circumstances
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 03002ae55..04bfbbabc 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -741,21 +741,6 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
Ptr->AddUser((char*)user);
WriteChannel(Ptr,user,"JOIN :%s",Ptr->name);
- if (!override) // we're not overriding... so this isnt part of a netburst, broadcast it.
- {
- // use the stamdard J token with no privilages.
- char buffer[MAXBUF];
- if (created == 2)
- {
- snprintf(buffer,MAXBUF,"J %s @%s",user->nick,Ptr->name);
- }
- else
- {
- snprintf(buffer,MAXBUF,"J %s %s",user->nick,Ptr->name);
- }
- NetSendToAll(buffer);
- }
-
log(DEBUG,"Sent JOIN to client");
if (Ptr->topicset)
@@ -812,25 +797,9 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
if (reason)
{
WriteChannel(Ptr,user,"PART %s :%s",Ptr->name, reason);
-
- if (!local)
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"L %s %s :%s",user->nick,Ptr->name,reason);
- NetSendToAll(buffer);
- }
-
-
}
else
{
- if (!local)
- {
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"L %s %s :",user->nick,Ptr->name);
- NetSendToAll(buffer);
- }
-
WriteChannel(Ptr,user,"PART :%s",Ptr->name);
}
user->chans[i].uc_modes = 0;
@@ -1132,11 +1101,6 @@ void kill_link(userrec *user,const char* r)
if (user->registered == 7) {
FOREACH_MOD OnUserQuit(user);
WriteCommonExcept(user,"QUIT :%s",reason);
-
- // Q token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"Q %s :%s",user->nick,reason);
- NetSendToAll(buffer);
}
user->FlushWriteBuf();
@@ -1192,11 +1156,6 @@ void kill_link_silent(userrec *user,const char* r)
if (user->registered == 7) {
FOREACH_MOD OnUserQuit(user);
WriteCommonExcept(user,"QUIT :%s",reason);
-
- // Q token must go to ALL servers!!!
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"Q %s :%s",user->nick,reason);
- NetSendToAll(buffer);
}
FOREACH_MOD OnUserDisconnect(user);
@@ -1565,10 +1524,6 @@ void FullConnectUser(userrec* user)
}
ShowMOTD(user);
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"N %lu %s %s %s %s +%s %s %s :%s",(unsigned long)user->age,user->nick,user->host,user->dhost,user->ident,user->modes,user->ip,ServerName,user->fullname);
- NetSendToAll(buffer);
-
// fix by brain: these should be AFTER the N token, so other servers know what the HELL we're on about... :)
FOREACH_MOD OnUserConnect(user);
FOREACH_MOD OnGlobalConnect(user);
@@ -1683,55 +1638,6 @@ void call_handler(const char* commandname,char **parameters, int pcnt, userrec *
}
}
-void DoSplitEveryone()
-{
- bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
- {
- if (strcasecmp(j->GetServerName().c_str(),ServerName))
- {
- j->routes.clear();
- j->CloseConnection();
- me[i]->connectors.erase(j);
- go_again = true;
- break;
- }
- }
- }
- }
- }
- log(DEBUG,"Removed server. Will remove clients...");
- // iterate through the userlist and remove all users on this server.
- // because we're dealing with a mesh, we dont have to deal with anything
- // "down-route" from this server (nice huh)
- go_again = true;
- char reason[MAXBUF];
- while (go_again)
- {
- go_again = false;
- for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
- {
- if (strcasecmp(u->second->server,ServerName))
- {
- snprintf(reason,MAXBUF,"%s %s",ServerName,u->second->server);
- kill_link(u->second,reason);
- go_again = true;
- break;
- }
- }
- }
- has_been_netsplit = true;
- log(DEBUG,"Clients removed.");
-}
-
-
void force_nickchange(userrec* user,const char* newnick)
{
@@ -2154,218 +2060,6 @@ void process_buffer(const char* cmdbuf,userrec *user)
}
}
-void DoSync(serverrec* serv, char* tcp_host)
-{
- char data[MAXBUF];
- log(DEBUG,"Sending sync");
- // send start of sync marker: Y <timestamp>
- // at this point the ircd receiving it starts broadcasting this netburst to all ircds
- // except the ones its receiving it from.
- snprintf(data,MAXBUF,"%s Y %lu",CreateSum().c_str(),(unsigned long)TIME);
- serv->SendPacket(data,tcp_host);
- // send users and channels
-
- NetSendMyRoutingTable();
-
- // send all routing table and uline voodoo. The ordering of these commands is IMPORTANT!
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (is_uline(me[j]->connectors[k].GetServerName().c_str()))
- {
- snprintf(data,MAXBUF,"%s H %s",CreateSum().c_str(),me[j]->connectors[k].GetServerName().c_str());
- serv->SendPacket(data,tcp_host);
- }
- }
- }
- }
-
- // send our version for the remote side to cache
- snprintf(data,MAXBUF,"%s v %s %s",CreateSum().c_str(),ServerName,GetVersionString().c_str());
- serv->SendPacket(data,tcp_host);
-
- // sync the users and channels, give the modules a look-in.
- for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
- {
- snprintf(data,MAXBUF,"%s N %lu %s %s %s %s +%s %s %s :%s",CreateSum().c_str(),(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,u->second->ip,u->second->server,u->second->fullname);
- serv->SendPacket(data,tcp_host);
- if (strchr(u->second->modes,'o'))
- {
- snprintf(data,MAXBUF,"%s | %s %s",CreateSum().c_str(),u->second->nick,u->second->oper);
- serv->SendPacket(data,tcp_host);
- }
- for (int i = 0; i <= MODCOUNT; i++)
- {
- string_list l = modules[i]->OnUserSync(u->second);
- for (unsigned int j = 0; j < l.size(); j++)
- {
- snprintf(data,MAXBUF,"%s %s",CreateSum().c_str(),l[j].c_str());
- serv->SendPacket(data,tcp_host);
- }
- }
- char* chl = chlist(u->second,u->second);
- if (strcmp(chl,""))
- {
- snprintf(data,MAXBUF,"%s J %s %s",CreateSum().c_str(),u->second->nick,chl);
- serv->SendPacket(data,tcp_host);
- }
- }
- // send channel modes, topics etc...
- for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
- {
- snprintf(data,MAXBUF,"M %s +%s",c->second->name,chanmodes(c->second));
- serv->SendPacket(data,tcp_host);
- for (int i = 0; i <= MODCOUNT; i++)
- {
- string_list l = modules[i]->OnChannelSync(c->second);
- for (unsigned int j = 0; j < l.size(); j++)
- {
- snprintf(data,MAXBUF,"%s %s",CreateSum().c_str(),l[j].c_str());
- serv->SendPacket(data,tcp_host);
- }
- }
- if (c->second->topic[0])
- {
- snprintf(data,MAXBUF,"%s T %lu %s %s :%s",CreateSum().c_str(),(unsigned long)c->second->topicset,c->second->setby,c->second->name,c->second->topic);
- serv->SendPacket(data,tcp_host);
- }
- // send current banlist
-
- for (BanList::iterator b = c->second->bans.begin(); b != c->second->bans.end(); b++)
- {
- snprintf(data,MAXBUF,"%s M %s +b %s",CreateSum().c_str(),c->second->name,b->data);
- serv->SendPacket(data,tcp_host);
- }
- }
- // sync global zlines, glines, etc
- sync_xlines(serv,tcp_host);
-
- snprintf(data,MAXBUF,"%s F %lu",CreateSum().c_str(),(unsigned long)TIME);
- serv->SendPacket(data,tcp_host);
- log(DEBUG,"Sent sync");
- // ircd sends its serverlist after the end of sync here
-}
-
-
-void NetSendMyRoutingTable()
-{
- // send out a line saying what is reachable to us.
- // E.g. if A is linked to B C and D, send out:
- // $ A B C D
- // if its only linked to B and D send out:
- // $ A B D
- // if it has no links, dont even send out the line at all.
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"$ %s",ServerName);
- bool sendit = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (unsigned int j = 0; j < me[i]->connectors.size(); j++)
- {
- if ((me[i]->connectors[j].GetState() != STATE_DISCONNECTED) || (is_uline(me[i]->connectors[j].GetServerName().c_str())))
- {
- strlcat(buffer," ",MAXBUF);
- strlcat(buffer,me[i]->connectors[j].GetServerName().c_str(),MAXBUF);
- sendit = true;
- }
- }
- }
- }
- if (sendit)
- NetSendToAll(buffer);
-}
-
-
-void DoSplit(const char* params)
-{
- bool go_again = true;
- int x = 0;
- while (go_again)
- {
- go_again = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
- {
- if (!strcasecmp(j->GetServerName().c_str(),params))
- {
- log(DEBUG,"Removing %s",j->GetServerName().c_str());
- j->routes.clear();
- j->CloseConnection();
- me[i]->connectors.erase(j);
- go_again = true;
- x++;
- break;
- }
- }
- }
- }
- }
- if (!x)
- {
- log(DEBUG,"No clients to remove.");
- return;
- }
- log(DEBUG,"Removed server. Will remove clients...");
- // iterate through the userlist and remove all users on this server.
- // because we're dealing with a mesh, we dont have to deal with anything
- // "down-route" from this server (nice huh)
- go_again = true;
- char reason[MAXBUF];
- snprintf(reason,MAXBUF,"%s %s",ServerName,params);
- while (go_again)
- {
- go_again = false;
- for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
- {
- if (!strcasecmp(u->second->server,params))
- {
- kill_link(u->second,reason);
- go_again = true;
- break;
- }
- }
- }
- has_been_netsplit = true;
- log(DEBUG,"Removed clients (DoSplit)");
-}
-
-// removes a server. Will NOT remove its users!
-
-void RemoveServer(const char* name)
-{
- bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
- {
- if (!strcasecmp(j->GetServerName().c_str(),name))
- {
- j->routes.clear();
- j->CloseConnection();
- me[i]->connectors.erase(j);
- go_again = true;
- break;
- }
- }
- }
- }
- }
-}
-
-
char MODERR[MAXBUF];
char* ModuleError()
@@ -2683,6 +2377,7 @@ int InspIRCd(char** argv, int argc)
}
engine_init;
+ engine_server_fill;
WritePID(PID);
@@ -3085,6 +2780,7 @@ int InspIRCd(char** argv, int argc)
char target[MAXBUF], resolved[MAXBUF];
length = sizeof (client);
incomingSockfd = accept (openSockfd[count], (struct sockaddr *) &client, &length);
+ log(DEBUG,"Accepted socket %d",incomingSockfd);
strlcpy (target, (char *) inet_ntoa (client.sin_addr), MAXBUF);
strlcpy (resolved, target, MAXBUF);
diff --git a/src/message.cpp b/src/message.cpp
index 6e024b027..e8d55150a 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -221,9 +221,6 @@ void ChangeName(userrec* user, const char* gecos)
return;
}
strlcpy(user->fullname,gecos,MAXBUF);
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"a %s :%s",user->nick,gecos);
- NetSendToAll(buffer);
}
void ChangeDisplayedHost(userrec* user, const char* host)
@@ -236,9 +233,6 @@ void ChangeDisplayedHost(userrec* user, const char* host)
return;
}
strlcpy(user->dhost,host,160);
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"b %s %s",user->nick,host);
- NetSendToAll(buffer);
}
/* verify that a user's ident and nickname is valid */
@@ -466,11 +460,4 @@ char* chlist(userrec *user,userrec* source)
}
-void send_network_quit(const char* nick, const char* reason)
-{
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"Q %s :%s",nick,reason);
- NetSendToAll(buffer);
-}
-
diff --git a/src/mode.cpp b/src/mode.cpp
index 011fe513d..5d6d65094 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1149,10 +1149,6 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int
if (!silent)
{
WriteChannelWithServ(ServerName,chan,"MODE %s %s",chan->name,outstr);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"M %s %s",chan->name, outstr);
- NetSendToAll(buffer);
}
}
@@ -1161,10 +1157,6 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int
if (!silent)
{
WriteChannel(chan,user,"MODE %s %s",chan->name,outstr);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick,chan->name, outstr);
- NetSendToAll(buffer);
}
}
}
@@ -1468,10 +1460,6 @@ void handle_mode(char **parameters, int pcnt, userrec *user)
if (strcmp(b,""))
{
WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick, dest->nick, b);
- NetSendToAll(buffer);
}
if (strlen(dmodes)>MAXMODES)
@@ -1725,10 +1713,6 @@ void server_mode(char **parameters, int pcnt, userrec *user)
if (strcmp(b,""))
{
WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick, dest->nick, b);
- NetSendToAll(buffer);
}
if (strlen(dmodes)>MAXMODES)
diff --git a/src/servers.cpp b/src/servers.cpp
index bb652f77b..f392c9510 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -282,17 +282,11 @@ void serverrec::FlushWriteBuffers()
{
// however if we reach this timer its connected timed out :)
WriteOpers("*** Connection to %s timed out",this->connectors[i].GetServerName().c_str());
- snprintf(buffer,MAXBUF,"& %s",this->connectors[i].GetServerName().c_str());
- NetSendToAllExcept(this->connectors[i].GetServerName().c_str(),buffer);
- DoSplit(this->connectors[i].GetServerName().c_str());
return;
}
if ((this->connectors[i].GetState() == STATE_NOAUTH_INBOUND) && (TIME > this->connectors[i].age+30))
{
WriteOpers("*** Connection from %s timed out",this->connectors[i].GetServerName().c_str());
- snprintf(buffer,MAXBUF,"& %s",this->connectors[i].GetServerName().c_str());
- NetSendToAllExcept(this->connectors[i].GetServerName().c_str(),buffer);
- DoSplit(this->connectors[i].GetServerName().c_str());
return;
}
if (this->connectors[i].GetState() != STATE_DISCONNECTED)
@@ -304,9 +298,6 @@ void serverrec::FlushWriteBuffers()
if (!IsRoutable(this->connectors[i].GetServerName()))
{
WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
- snprintf(buffer,MAXBUF,"& %s",this->connectors[i].GetServerName().c_str());
- NetSendToAllExcept(this->connectors[i].GetServerName().c_str(),buffer);
- DoSplit(this->connectors[i].GetServerName().c_str());
}
this->connectors[i].CloseConnection();
has_been_netsplit = true;
@@ -320,9 +311,6 @@ void serverrec::FlushWriteBuffers()
if (!IsRoutable(this->connectors[i].GetServerName()))
{
WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
- snprintf(buffer,MAXBUF,"& %s",this->connectors[i].GetServerName().c_str());
- NetSendToAllExcept(this->connectors[i].GetServerName().c_str(),buffer);
- DoSplit(this->connectors[i].GetServerName().c_str());
}
this->connectors[i].CloseConnection();
has_been_netsplit = true;
@@ -337,9 +325,6 @@ void serverrec::FlushWriteBuffers()
if (!IsRoutable(this->connectors[i].GetServerName()))
{
WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
- snprintf(buffer,MAXBUF,"& %s",this->connectors[i].GetServerName().c_str());
- NetSendToAllExcept(this->connectors[i].GetServerName().c_str(),buffer);
- DoSplit(this->connectors[i].GetServerName().c_str());
}
this->connectors[i].CloseConnection();
has_been_netsplit = true;
@@ -398,9 +383,6 @@ bool serverrec::SendPacket(char *message, const char* sendhost)
}
char buffer[MAXBUF];
snprintf(buffer,MAXBUF,"& %s",sendhost);
- WriteOpers("*** All connections to %s lost.",sendhost);
- NetSendToAllExcept(sendhost,buffer);
- DoSplit(sendhost);
return false;
}
@@ -482,9 +464,6 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
if (!IsRoutable(sn))
{
WriteOpers("*** Server %s is no longer routable, disconnecting (EOF)",sn.c_str());
- snprintf(buffer,MAXBUF,"& %s",sn.c_str());
- NetSendToAllExcept(sn.c_str(),buffer);
- DoSplit(sn.c_str());
}
this->connectors[i].CloseConnection();
has_been_netsplit = true;
@@ -500,9 +479,6 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
if (!IsRoutable(sn))
{
WriteOpers("*** Server %s is no longer routable, disconnecting.",sn.c_str());
- snprintf(buffer,MAXBUF,"& %s",sn.c_str());
- NetSendToAllExcept(sn.c_str(),buffer);
- DoSplit(sn.c_str());
}
has_been_netsplit = true;
this->connectors[i].CloseConnection();
@@ -519,9 +495,6 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
if (!IsRoutable(sn))
{
WriteOpers("*** Server %s is no longer routable, disconnecting.",sn.c_str());
- snprintf(buffer,MAXBUF,"& %s",sn.c_str());
- NetSendToAllExcept(sn.c_str(),buffer);
- DoSplit(sn.c_str());
}
has_been_netsplit = true;
this->connectors[i].CloseConnection();