Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
- fixes for fake server handling (jupe), wildcard handling (don't use
Browse files Browse the repository at this point in the history
  irc.* in jupe names, etc.) [Kamen Sabeff]
  • Loading branch information
dkorunic committed Apr 30, 2013
1 parent 2326749 commit d231cd2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 28 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -36,6 +36,8 @@ Hybserv-1.9.5-dev
- fixing missing help files
+ DELME command for users to delete themselves from channel lists [Kamen
Sabeff]
- fixes for fake server handling (jupe), wildcard handling (don't use
irc.* in jupe names, etc.) [Kamen Sabeff]

Hybserv-1.9.4

Expand Down
1 change: 1 addition & 0 deletions include/jupe.h
Expand Up @@ -36,6 +36,7 @@ void AddJupe(char *, char *, char *);
void DeleteJupe(struct Jupe *);
void CheckJupes(void);
void DoJupeSquit(char *, char *, char *);
void FakeServer(char *, char *);
int CheckJuped(char *);
struct Jupe *IsJupe(char *);
void InitJupes(void);
Expand Down
63 changes: 50 additions & 13 deletions src/jupe.c
Expand Up @@ -159,8 +159,14 @@ DoJupeSquit(char *serv, char *reason, char *who)

{
struct Server *tempserv, *prev;
char sendstr[MAXLINE + 1], **arv;
int acnt;
char *servptr;
int nowild;

/* check for wildcards */
for (servptr = serv; *servptr != '\0' && !IsMWildChar(*servptr); servptr++)
;

nowild = (*servptr == '\0');

for (tempserv = ServerList; tempserv; )
{
Expand All @@ -173,22 +179,46 @@ DoJupeSquit(char *serv, char *reason, char *who)
prev = tempserv->next;
DeleteServer(tempserv); /* remove server from list */
tempserv = prev;

/* If the fake server is introduced before the remote server has quited,
* we get "server already exists" and services get SQUIT'ed,
* so we'll introduce it in s_squit()
*/
if (nowild)
return;
}
else
tempserv = tempserv->next;
}

/* add a fake server to replace it */
/* we don't want to introduce servers such as "irc.*"
*/
if (nowild)
FakeServer(serv, reason);
} /* DoJupeSquit() */

/*
FakeServer()
args: char *serv, char *reason
purpose: introduce a fake server to the network
*/

void
FakeServer(char *serv, char *reason)
{
char **arv, sendstr[MAXLINE + 1];
int arc;

ircsprintf(sendstr, ":%s SERVER %s 2 :Juped: %s\r\n", Me.name, serv,
reason);

toserv("%s", sendstr);

acnt = SplitBuf(sendstr, &arv);
AddServer(acnt, arv);
arc = SplitBuf(sendstr, &arv);
AddServer(arc, arv);

MyFree(arv);
} /* DoJupeSquit() */
}

/*
CheckJuped()
Expand Down Expand Up @@ -271,14 +301,12 @@ CheckJuped(char *name)
tempserv = FindServer(name);
DeleteServer(tempserv);

/* replace it with fake server */
ircsprintf(sendstr, ":%s SERVER %s 2 :Juped: %s\r\n",
Me.name, name, tempjupe->reason);
toserv("%s", sendstr);
SplitBuf(sendstr, &arv);
/* If the fake server is introduced before the remote server has quited,
* we get "server already exists" and services get SQUIT'ed,
* so we'll introduce it in s_squit()
*/


AddServer(5, arv);
MyFree(arv);
}
return 1;
}
Expand Down Expand Up @@ -345,6 +373,14 @@ InitJupes()
}
else
{
char *tptr;

/* check for wildcards */
for (tptr = tmpjupe->name; *tptr != '\0' && !IsMWildChar(*tptr); tptr++)
;

if (*tptr == '\0')
{
ircsprintf(sendstr, ":%s SERVER %s 2 :Juped: %s", Me.name,
tmpjupe->name, tmpjupe->reason);

Expand All @@ -360,6 +396,7 @@ InitJupes()
MyFree(av);
}
}
}
} /* InitJupes() */

#ifdef JUPEVOTES
Expand Down
32 changes: 18 additions & 14 deletions src/server.c
Expand Up @@ -1537,33 +1537,37 @@ s_squit(int ac, char **av)
struct Server *tmpserv;
#endif

#ifdef ALLOW_JUPES
struct Jupe *tmpjupe;
#endif

if (ac == 3)
sptr = FindServer(av[1]);
else if (ac == 4)
sptr = FindServer(av[2]);
else
sptr = NULL;

#ifdef ALLOW_JUPES
/* if manual squitting a juped server, get it back in! */
/* XXX: refactor this back into jupe.c function -kre */
if ((sptr != NULL) && IsJupe(sptr->name))
if ((tmpjupe = IsJupe(av[ac-2])))
{
char sendstr[MAXLINE + 1], **arv;
int acnt;

/* add a fake server to replace it */
ircsprintf(sendstr, ":%s SERVER %s 2 :Juped: %s\r\n", Me.name,
sptr->name, "Auto-rejupe after manual squit");
/* it's our fake server, just get it back in (already hash-added)
*/
if (sptr)
toserv(":%s SERVER %s 2 :Juped: %s\r\n", Me.name,
sptr->name, tmpjupe->reason);

/* it's a remote server quiting (most probably after SQUIT in jupe.c),
* which is to be juped
*/
else
FakeServer(av[ac-2], tmpjupe->reason);

toserv("%s", sendstr);

acnt = SplitBuf(sendstr, &arv);
AddServer(acnt, arv);

MyFree(arv);
return;
}

#endif
/* If we defined more info on split, we will not delete
* non-intentionally splitted servers from hash -kre */

Expand Down
2 changes: 1 addition & 1 deletion src/sock.c
Expand Up @@ -603,7 +603,7 @@ ReadSocketInfo(void)
FD_ZERO(&writefds);

TimeOut.tv_sec = 0L;
TimeOut.tv_usec = 200L;
TimeOut.tv_usec = 20000L;

if (currenthub && (HubSock != NOSOCKET))
{
Expand Down

0 comments on commit d231cd2

Please sign in to comment.