ClassVector Classes;
struct linger linger = { 0 };
-char bannerBuffer[MAXBUF];
+char MyExecutable[1024];
int boundPortCount = 0;
int portCount = 0, UDPportCount = 0, ports[MAXSOCKS];
int defaultRoute = 0;
{
if (strchr(i->second->modes,'w'))
{
- WriteTo(source,i->second,"WALLOPS %s",textbuffer);
+ WriteTo(source,i->second,"WALLOPS :%s",textbuffer);
}
}
}
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnUserPreJoin(user,NULL,cname));
- if (MOD_RESULT) {
+ if (MOD_RESULT == 1) {
return NULL;
}
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname));
- if (MOD_RESULT) {
+ if (MOD_RESULT == 1) {
return NULL;
}
- if (strcmp(Ptr->key,""))
+ if (MOD_RESULT == 0)
{
- log(DEBUG,"add_channel: %s has key %s",Ptr->name,Ptr->key);
- if (!key)
- {
- log(DEBUG,"add_channel: no key given in JOIN");
- WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name);
- return NULL;
- }
- else
+
+ if (strcmp(Ptr->key,""))
{
- log(DEBUG,"key at %p is %s",key,key);
- if (strcasecmp(key,Ptr->key))
+ log(DEBUG,"add_channel: %s has key %s",Ptr->name,Ptr->key);
+ if (!key)
{
- log(DEBUG,"add_channel: bad key given in JOIN");
- WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name);
+ log(DEBUG,"add_channel: no key given in JOIN");
+ WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name);
return NULL;
}
+ else
+ {
+ log(DEBUG,"key at %p is %s",key,key);
+ if (strcasecmp(key,Ptr->key))
+ {
+ log(DEBUG,"add_channel: bad key given in JOIN");
+ WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name);
+ return NULL;
+ }
+ }
}
- }
- log(DEBUG,"add_channel: no key");
-
- if (Ptr->inviteonly)
- {
- log(DEBUG,"add_channel: channel is +i");
- if (user->IsInvited(Ptr->name))
- {
- /* user was invited to channel */
- /* there may be an optional channel NOTICE here */
- }
- else
+ log(DEBUG,"add_channel: no key");
+
+ if (Ptr->inviteonly)
{
- WriteServ(user->fd,"473 %s %s :Cannot join channel (Invite only)",user->nick, Ptr->name);
- return NULL;
+ log(DEBUG,"add_channel: channel is +i");
+ if (user->IsInvited(Ptr->name))
+ {
+ /* user was invited to channel */
+ /* there may be an optional channel NOTICE here */
+ }
+ else
+ {
+ WriteServ(user->fd,"473 %s %s :Cannot join channel (Invite only)",user->nick, Ptr->name);
+ return NULL;
+ }
}
- }
- log(DEBUG,"add_channel: channel is not +i");
-
- if (Ptr->limit)
- {
- if (usercount(Ptr) == Ptr->limit)
+ log(DEBUG,"add_channel: channel is not +i");
+
+ if (Ptr->limit)
{
- WriteServ(user->fd,"471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
- return NULL;
+ if (usercount(Ptr) == Ptr->limit)
+ {
+ WriteServ(user->fd,"471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
+ return NULL;
+ }
}
- }
-
- log(DEBUG,"add_channel: about to walk banlist");
-
- /* check user against the channel banlist */
- if (Ptr)
- {
- if (Ptr->bans.size())
+
+ log(DEBUG,"add_channel: about to walk banlist");
+
+ /* check user against the channel banlist */
+ if (Ptr)
{
- for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++)
+ if (Ptr->bans.size())
{
- if (match(user->GetFullHost(),i->data))
+ for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++)
{
- WriteServ(user->fd,"474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
- return NULL;
+ if (match(user->GetFullHost(),i->data))
+ {
+ WriteServ(user->fd,"474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
+ return NULL;
+ }
}
}
}
- }
+
+ log(DEBUG,"add_channel: bans checked");
- log(DEBUG,"add_channel: bans checked");
+ }
if ((Ptr) && (user))
}
-int main(int argc, char *argv[])
+int main(int argc, char **argv)
{
Start();
srand(time(NULL));
Exit(ERROR);
}
if (argc > 1) {
- if (!strcmp(argv[1],"-nofork")) {
- nofork = true;
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i],"-nofork")) {
+ nofork = true;
+ }
+ if (!strcmp(argv[i],"-wait")) {
+ sleep(6);
+ }
}
}
+ strcpy(MyExecutable,argv[0]);
+
if (InspIRCd() == ERROR)
{
log(DEBUG,"main: daemon function bailed");
// another phidjit bug...
if (total_params > 126)
{
- kill_link(user,"Protocol violation (1)");
+ //kill_link(user,"Protocol violation (1)");
+ WriteServ(user->fd,"421 %s * :Unknown command",user->nick);
return;
}
if (strlen(command)>MAXCOMMAND)
{
- kill_link(user,"Protocol violation (2)");
+ //kill_link(user,"Protocol violation (2)");
+ WriteServ(user->fd,"421 %s * :Unknown command",user->nick);
return;
}
{
if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-'))
{
- if (!strchr("@!\"$%^&*(){}[]_-=+;:'#~,.<>/?\\|`",command[x]))
+ if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
{
- kill_link(user,"Protocol violation (3)");
+ //kill_link(user,"Protocol violation (3)");
+ WriteServ(user->fd,"421 %s * :Unknown command",user->nick);
return;
}
}
createcommand("GLINE",handle_gline,'o',1);
createcommand("ZLINE",handle_zline,'o',1);
createcommand("QLINE",handle_qline,'o',1);
+ createcommand("SERVER",handle_server,0,0);
}
void process_buffer(const char* cmdbuf,userrec *user)
{
snprintf(data,MAXBUF,"N %d %s %s %s %s +%s %s %s :%s",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",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 (int j = 0; j < l.size(); j++)
+ {
+ strncpy(data,l[j].c_str(),MAXBUF);
+ serv->SendPacket(data,tcp_host);
+ }
+ }
if (strcmp(chlist(u->second),""))
{
snprintf(data,MAXBUF,"J %s %s",u->second->nick,chlist(u->second));
{
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 (int j = 0; j < l.size(); j++)
+ {
+ strncpy(data,l[j].c_str(),MAXBUF);
+ serv->SendPacket(data,tcp_host);
+ }
+ }
if (strcmp(c->second->topic,""))
{
snprintf(data,MAXBUF,"T %d %s %s :%s",c->second->topicset,c->second->setby,c->second->name,c->second->topic);
int InspIRCd(void)
{
- struct sockaddr_in client, server;
+ struct sockaddr_in client,server;
char addrs[MAXBUF][255];
int openSockfd[MAXSOCKS], incomingSockfd, result = TRUE;
socklen_t length;
- int count = 0, scanDetectTrigger = TRUE, showBanner = FALSE;
+ int count = 0;
int selectResult = 0, selectResult2 = 0;
char *temp, configToken[MAXBUF], stuff[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
char resolvedHost[MAXBUF];
log(DEBUG,"InspIRCd: startup: binding '%s:%s' is default server route",Addr,configToken);
}
me[count3] = new serverrec(ServerName,100L,false);
- me[count3]->CreateListener(Addr,atoi(configToken));
- count3++;
+ if (!me[count3]->CreateListener(Addr,atoi(configToken)))
+ {
+ log(DEFAULT,"Error! Failed to bind port %d",atoi(configToken));
+ }
+ else
+ {
+ count3++;
+ }
}
else
{
for (int x = 0; x != UDPportCount; x++)
{
- FD_SET(me[x]->fd, &serverfds);
+ if (me[x])
+ FD_SET(me[x]->fd, &serverfds);
}
tvs.tv_usec = 0;
{
for (int x = 0; x != UDPportCount; x++)
{
- if (FD_ISSET (me[x]->fd, &serverfds))
+ if ((me[x]) && (FD_ISSET (me[x]->fd, &serverfds)))
{
char remotehost[MAXBUF],resolved[MAXBUF];
length = sizeof (client);
{
std::deque<std::string> msgs;
msgs.clear();
- if (me[x]->RecvPacket(msgs, tcp_host))
+ if ((me[x]) && (me[x]->RecvPacket(msgs, tcp_host)))
{
for (int ctr = 0; ctr < msgs.size(); ctr++)
{