[srvx-commits] CVS: services/src proto-p10.c,1.56,1.57
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2003-01-07 04:29:51
|
Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv28237/src
Modified Files:
proto-p10.c
Log Message:
fix AddUser() to make the right user a zombie
when calling AddClone() or AddService(), make sure we collide existing users
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** proto-p10.c 6 Jan 2003 01:53:01 -0000 1.56
--- proto-p10.c 7 Jan 2003 04:29:49 -0000 1.57
***************
*** 1473,1476 ****
--- 1473,1477 ----
/* other numeric responses we might get */
dict_insert(irc_func_dict, "401", cmd_dummy); /* target left network */
+ dict_insert(irc_func_dict, "403", cmd_dummy); /* no such channel */
dict_insert(irc_func_dict, "441", cmd_dummy); /* target isn't on that channel */
dict_insert(irc_func_dict, "442", cmd_dummy); /* you aren't on that channel */
***************
*** 1704,1707 ****
--- 1705,1710 ----
char numeric[COMBO_NUMERIC_LEN+1];
int local_num = get_local_numeric();
+ time_t timestamp = now;
+ struct userNode *old_user = GetUserH(nick);
if (local_num == -1) {
***************
*** 1710,1713 ****
--- 1713,1717 ----
}
make_numeric(self, local_num, numeric);
+ if (old_user) timestamp = old_user->timestamp - 1;
return AddUser(self, nick, nick, self->name, "+oik", NULL, numeric, desc, now, "AAAAAA");
}
***************
*** 1718,1721 ****
--- 1722,1727 ----
char numeric[COMBO_NUMERIC_LEN+1];
int local_num = get_local_numeric();
+ time_t timestamp = now;
+ struct userNode *old_user = GetUserH(nick);
if (local_num == -1) {
***************
*** 1724,1728 ****
}
make_numeric(self, local_num, numeric);
! return AddUser(self, nick, ident, hostname, "+i", NULL, numeric, desc, now, "AAAAAA");
}
--- 1730,1735 ----
}
make_numeric(self, local_num, numeric);
! if (old_user) timestamp = old_user->timestamp - 1;
! return AddUser(self, nick, ident, hostname, "+i", NULL, numeric, desc, timestamp, "AAAAAA");
}
***************
*** 1744,1748 ****
struct userNode *oldUser, *uNode;
struct policer_params *pol_params;
! unsigned int n;
if ((strlen(numeric) < 3) || (strlen(numeric) > 5)) {
--- 1751,1755 ----
struct userNode *oldUser, *uNode;
struct policer_params *pol_params;
! unsigned int n, ignore_user;
if ((strlen(numeric) < 3) || (strlen(numeric) > 5)) {
***************
*** 1766,1769 ****
--- 1773,1794 ----
}
+ ignore_user = 0;
+ if ((oldUser = GetUserH(nick))) {
+ if (IsLocal(oldUser) && IsService(oldUser)) {
+ /* The service should collide the new user off. */
+ oldUser->timestamp = timestamp - 1;
+ irc_user(oldUser);
+ }
+ if (oldUser->timestamp > timestamp) {
+ /* "Old" user is really newer; remove them */
+ DelUser(oldUser, 0, 1, "Overruled by older nick");
+ } else {
+ /* User being added is too new; do not add them to
+ * clients, but do add them to the server's list, since it
+ * will send a KILL and QUIT soon. */
+ ignore_user = 1;
+ }
+ }
+
/* create new usernode and set all values */
uNode = calloc(1, sizeof(*uNode));
***************
*** 1774,1778 ****
safestrncpy(uNode->numeric, numeric, sizeof(uNode->numeric));
uNode->ip = base64toint(realip, 6);
! uNode->timestamp=timestamp;
modeList_init(&uNode->channels);
uNode->uplink = uplink;
--- 1799,1803 ----
safestrncpy(uNode->numeric, numeric, sizeof(uNode->numeric));
uNode->ip = base64toint(realip, 6);
! uNode->timestamp = timestamp;
modeList_init(&uNode->channels);
uNode->uplink = uplink;
***************
*** 1785,1808 ****
uNode->uplink->users[uNode->num_local] = uNode;
if (account) call_account_func(uNode, account);
! if ((oldUser = GetUserH(nick))) {
! if (IsLocal(oldUser) && IsService(oldUser)) {
! oldUser->timestamp = uNode->timestamp - 1;
! irc_user(oldUser);
! }
! if (oldUser->timestamp > uNode->timestamp) {
! oldUser = NULL;
! }
! }
!
! if (!oldUser) {
! dict_insert(clients, uNode->nick, uNode);
! if (dict_size(clients) > max_clients) {
! max_clients = dict_size(clients);
! max_clients_time = now;
! }
}
-
- mod_usermode(uNode, modes);
if (IsLocal(uNode)) irc_user(uNode);
for (n=0; n<nuf_used; n++) {
--- 1810,1821 ----
uNode->uplink->users[uNode->num_local] = uNode;
if (account) call_account_func(uNode, account);
+ mod_usermode(uNode, modes);
+ if (ignore_user) return uNode;
! dict_insert(clients, uNode->nick, uNode);
! if (dict_size(clients) > max_clients) {
! max_clients = dict_size(clients);
! max_clients_time = now;
}
if (IsLocal(uNode)) irc_user(uNode);
for (n=0; n<nuf_used; n++) {
|