users.cc 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. /*
  2. * Copyright (C) 1997 Robey Pointer
  3. * Copyright (C) 1999 - 2002 Eggheads Development Team
  4. * Copyright (C) 2002 - 2014 Bryan Drewery
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. /*
  21. * users.c -- handles:
  22. * testing and enforcing ignores
  23. * adding and removing ignores
  24. * listing ignores
  25. * auto-linking bots
  26. * sending and receiving a userfile from a bot
  27. * listing users ('.whois' and '.match')
  28. * reading the user file
  29. *
  30. * dprintf'ized, 9nov1995
  31. *
  32. */
  33. #include "common.h"
  34. #include "users.h"
  35. #include "rfc1459.h"
  36. #include "src/mod/share.mod/share.h"
  37. #include "dcc.h"
  38. #include "settings.h"
  39. #include "userrec.h"
  40. #include "misc.h"
  41. #include "set.h"
  42. #include "match.h"
  43. #include "main.h"
  44. #include "chanprog.h"
  45. #include "dccutil.h"
  46. #include "crypt.h"
  47. #include "botnet.h"
  48. #include "chan.h"
  49. #include "tandem.h"
  50. #include "src/mod/channels.mod/channels.h"
  51. #include <netinet/in.h>
  52. #include <arpa/inet.h>
  53. #include "misc_file.h"
  54. #include "EncryptedStream.h"
  55. char userfile[121] = ""; /* where the user records are stored */
  56. char autolink_failed[HANDLEN + 1] = "";
  57. interval_t ignore_time = 10; /* how many minutes will ignores last? */
  58. bool dont_restructure = 0; /* set when we botlink() to a hub with +U, only stops bot from restructuring */
  59. /* is this nick!user@host being ignored? */
  60. bool match_ignore(char *uhost)
  61. {
  62. for (struct igrec *ir = global_ign; ir; ir = ir->next)
  63. if (wild_match(ir->igmask, uhost))
  64. return 1;
  65. return 0;
  66. }
  67. int equals_ignore(char *uhost)
  68. {
  69. struct igrec *u = global_ign;
  70. for (; u; u = u->next)
  71. if (!rfc_casecmp(u->igmask, uhost)) {
  72. if (u->flags & IGREC_PERM)
  73. return 2;
  74. else
  75. return 1;
  76. }
  77. return 0;
  78. }
  79. char *delignore(char *ign)
  80. {
  81. int i = 0, j;
  82. struct igrec **u = NULL, *t = NULL;
  83. static char temp[256] = "";
  84. if (!strchr(ign, '!') && (j = atoi(ign))) {
  85. for (u = &global_ign, j--; *u && j; u = &((*u)->next), j--)
  86. ;
  87. if (*u) {
  88. strlcpy(temp, (*u)->igmask, sizeof temp);
  89. i = 1;
  90. }
  91. } else {
  92. /* find the matching host, if there is one */
  93. for (u = &global_ign; *u && !i; u = &((*u)->next))
  94. if (!rfc_casecmp(ign, (*u)->igmask)) {
  95. strlcpy(temp, ign, sizeof temp);
  96. i = 1;
  97. break;
  98. }
  99. }
  100. if (i) {
  101. if (!noshare) {
  102. char *mask = str_escape(temp, ':', '\\');
  103. if (mask) {
  104. shareout("-i %s\n", mask);
  105. free(mask);
  106. }
  107. }
  108. free((*u)->igmask);
  109. free((*u)->msg);
  110. free((*u)->user);
  111. t = *u;
  112. *u = (*u)->next;
  113. free(t);
  114. } else
  115. temp[0] = 0;
  116. return temp;
  117. }
  118. void addignore(char *ign, char *from, const char *mnote, time_t expire_time)
  119. {
  120. struct igrec *p = NULL, *l = NULL;
  121. for (l = global_ign; l; l = l->next)
  122. if (!rfc_casecmp(l->igmask, ign)) {
  123. p = l;
  124. break;
  125. }
  126. if (p == NULL) {
  127. p = (struct igrec *) calloc(1, sizeof(struct igrec));
  128. p->next = global_ign;
  129. global_ign = p;
  130. } else {
  131. free(p->igmask);
  132. free(p->user);
  133. free(p->msg);
  134. }
  135. p->expire = expire_time;
  136. p->added = now;
  137. p->flags = expire_time ? 0 : IGREC_PERM;
  138. p->igmask = strdup(ign);
  139. p->user = strdup(from);
  140. p->msg = strdup(mnote);
  141. if (!noshare) {
  142. char *mask = str_escape(ign, ':', '\\');
  143. if (mask) {
  144. shareout("+i %s %d %c %s %s\n", mask, (int) (expire_time - now), (p->flags & IGREC_PERM) ? 'p' : '-', from, mnote);
  145. free(mask);
  146. }
  147. }
  148. }
  149. /* take host entry from ignore list and display it ignore-style */
  150. void display_ignore(int idx, int number, struct igrec *ignore)
  151. {
  152. char dates[81] = "", s[41] = "";
  153. if (ignore->added) {
  154. daysago(now, ignore->added, s, sizeof(s));
  155. simple_snprintf(dates, sizeof(dates), "Started %s", s);
  156. }
  157. if (ignore->flags & IGREC_PERM)
  158. strlcpy(s, "(perm)", sizeof(s));
  159. else {
  160. char s1[41] = "";
  161. days(ignore->expire, now, s1, sizeof(s1));
  162. simple_snprintf(s, sizeof(s), "(expires %s)", s1);
  163. }
  164. if (number >= 0)
  165. dprintf(idx, " [%3d] %s %s\n", number, ignore->igmask, s);
  166. else
  167. dprintf(idx, "IGNORE: %s %s\n", ignore->igmask, s);
  168. if (ignore->msg && ignore->msg[0])
  169. dprintf(idx, " %s: %s\n", ignore->user, ignore->msg);
  170. else
  171. dprintf(idx, " placed by %s\n", ignore->user);
  172. if (dates[0])
  173. dprintf(idx, " %s\n", dates);
  174. }
  175. /* list the ignores and how long they've been active */
  176. void tell_ignores(int idx, char *match)
  177. {
  178. struct igrec *u = global_ign;
  179. if (u == NULL) {
  180. dprintf(idx, "No ignores.\n");
  181. return;
  182. }
  183. dprintf(idx, "%s:\n", "Currently ignoring");
  184. int k = 1;
  185. for (; u; u = u->next) {
  186. if (match[0]) {
  187. if (wild_match(match, u->igmask) ||
  188. wild_match(match, u->msg) ||
  189. wild_match(match, u->user))
  190. display_ignore(idx, k, u);
  191. k++;
  192. } else
  193. display_ignore(idx, k++, u);
  194. }
  195. }
  196. /* check for expired timed-ignores */
  197. void check_expired_ignores()
  198. {
  199. struct igrec **u = &global_ign;
  200. if (!*u)
  201. return;
  202. while (*u) {
  203. if (!((*u)->flags & IGREC_PERM) && (now >= (*u)->expire)) {
  204. putlog(LOG_MISC, "*", "%s %s (expired)", "No longer ignoring", (*u)->igmask);
  205. delignore((*u)->igmask);
  206. } else {
  207. u = &((*u)->next);
  208. }
  209. }
  210. }
  211. /* Channel mask loaded from user file. This function is
  212. * add(ban|invite|exempt)_fully merged into one. <cybah>
  213. */
  214. static void addmask_fully(struct chanset_t *chan, maskrec **m, maskrec **global,
  215. char *mask, char *from,
  216. char *note, time_t expire_time, int flags,
  217. time_t added, time_t last)
  218. {
  219. maskrec *p = (maskrec *) calloc(1, sizeof(maskrec));
  220. maskrec **u = (chan) ? m : global;
  221. p->next = *u;
  222. *u = p;
  223. p->expire = expire_time;
  224. p->added = added;
  225. p->lastactive = last;
  226. p->flags = flags;
  227. p->mask = strdup(mask);
  228. p->user = strdup(from);
  229. p->desc = strdup(note);
  230. }
  231. static void restore_chanmask(const char type, struct chanset_t *chan, char *host)
  232. {
  233. char *expi = NULL, *add = NULL, *last = NULL, *user = NULL, *desc = NULL;
  234. int flags = 0;
  235. maskrec **chan_masks = NULL, **global_masks = NULL;
  236. const char *str_type = (type == 'b' ? "ban" : type == 'e' ? "exempt" : "invite");
  237. if (type == 'b') {
  238. if (chan) chan_masks = &chan->bans;
  239. global_masks = &global_bans;
  240. } else if (type == 'e') {
  241. if (chan) chan_masks = &chan->exempts;
  242. global_masks = &global_exempts;
  243. } else if (type == 'I') {
  244. if (chan) chan_masks = &chan->invites;
  245. global_masks = &global_invites;
  246. }
  247. expi = strchr_unescape(host, ':', '\\');
  248. if (expi) {
  249. if (*expi == '+') {
  250. flags |= MASKREC_PERM;
  251. expi++;
  252. }
  253. add = strchr(expi, ':');
  254. if (add) {
  255. if (add[-1] == '*') {
  256. flags |= MASKREC_STICKY;
  257. add[-1] = 0;
  258. } else
  259. *add = 0;
  260. add++;
  261. if (*add == '+') {
  262. last = strchr(add, ':');
  263. if (last) {
  264. *last = 0;
  265. last++;
  266. user = strchr(last, ':');
  267. if (user) {
  268. *user = 0;
  269. user++;
  270. desc = strchr(user, ':');
  271. if (desc) {
  272. *desc = 0;
  273. desc++;
  274. addmask_fully(chan, chan_masks, global_masks, host, user,
  275. desc, atoi(expi), flags, atoi(add), atoi(last));
  276. return;
  277. }
  278. }
  279. }
  280. } else {
  281. desc = strchr(add, ':');
  282. if (desc) {
  283. *desc = 0;
  284. desc++;
  285. addmask_fully(chan, chan_masks, global_masks, host, add, desc,
  286. atoi(expi), flags, now, 0);
  287. return;
  288. }
  289. }
  290. }
  291. }
  292. putlog(LOG_MISC, "*", "*** Malformed %sline for %s%s%s.", str_type, chan ? chan->dname : "global_", chan ? "" : str_type, chan ? "" : "s");
  293. }
  294. static void restore_ignore(char *host)
  295. {
  296. char *expi = NULL, *user = NULL, *added = NULL, *desc = NULL;
  297. int flags = 0;
  298. struct igrec *p = NULL;
  299. expi = strchr_unescape(host, ':', '\\');
  300. if (expi) {
  301. if (*expi == '+') {
  302. flags |= IGREC_PERM;
  303. expi++;
  304. }
  305. user = strchr(expi, ':');
  306. if (user) {
  307. *user = 0;
  308. user++;
  309. added = strchr(user, ':');
  310. if (added) {
  311. *added = 0;
  312. added++;
  313. desc = strchr(added, ':');
  314. if (desc) {
  315. *desc = 0;
  316. desc++;
  317. } else
  318. desc = NULL;
  319. } else {
  320. added = "0";
  321. desc = NULL;
  322. }
  323. p = (struct igrec *) calloc(1, sizeof(struct igrec));
  324. p->next = global_ign;
  325. global_ign = p;
  326. p->expire = atoi(expi);
  327. p->added = atoi(added);
  328. p->flags = flags;
  329. p->igmask = strdup(host);
  330. p->user = strdup(user);
  331. if (desc) {
  332. p->msg = strdup(desc);
  333. } else
  334. p->msg = NULL;
  335. return;
  336. }
  337. }
  338. putlog(LOG_MISC, "*", "*** Malformed ignore line.");
  339. }
  340. static void
  341. tell_user(int idx, struct userrec *u)
  342. {
  343. char s[81] = "", s1[81] = "", format[81] = "";
  344. time_t now2;
  345. struct chanuserrec *ch = NULL;
  346. struct chanset_t *chan = NULL;
  347. struct user_entry *ue = NULL;
  348. struct laston_info *li = (struct laston_info *) get_user(&USERENTRY_LASTON, u);
  349. struct flag_record fr = {FR_GLOBAL, u->flags, 0, 0 };
  350. build_flags(s, &fr, NULL);
  351. if (!li || !li->laston)
  352. strlcpy(s1, "never", sizeof(s1));
  353. else {
  354. now2 = now - li->laston;
  355. if (now2 > 86400)
  356. strftime(s1, 7, "%d %b", gmtime(&li->laston));
  357. else
  358. strftime(s1, 6, "%H:%M", gmtime(&li->laston));
  359. }
  360. if (!u->bot) {
  361. simple_snprintf(format, sizeof format, "%%-%us %%-4s %%-15s %%s (%%-10.10s)\n", HANDLEN);
  362. dprintf(idx, format, u->handle, get_user(&USERENTRY_PASS, u) ? "yes" : "no", s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
  363. } else { /* BOT */
  364. simple_snprintf(format, sizeof format, "%%-%us %%-8s %%s (%%-10.10s)\n", HANDLEN);
  365. dprintf(idx, format, u->handle, s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
  366. }
  367. /* channel flags? */
  368. for (ch = u->chanrec; ch; ch = ch->next) {
  369. fr.match = FR_CHAN | FR_GLOBAL;
  370. chan = findchan_by_dname(ch->channel);
  371. get_user_flagrec(dcc[idx].user, &fr, ch->channel);
  372. if (!channel_privchan(chan) || (channel_privchan(chan) && (chan_op(fr) || glob_owner(fr)))) {
  373. if (glob_op(fr) || chan_op(fr)) {
  374. if (ch->laston == 0L)
  375. strlcpy(s1, "never", sizeof(s1));
  376. else {
  377. now2 = now - (ch->laston);
  378. if (now2 > 86400)
  379. strftime(s1, 7, "%d %b", gmtime(&ch->laston));
  380. else
  381. strftime(s1, 6, "%H:%M", gmtime(&ch->laston));
  382. }
  383. fr.match = FR_CHAN;
  384. fr.chan = ch->flags;
  385. build_flags(s, &fr, NULL);
  386. simple_snprintf(format, sizeof format, "%%%us %%-18s %%-15s %%s\n", HANDLEN-9);
  387. dprintf(idx, format, " ", ch->channel, s, s1);
  388. if (ch->info != NULL)
  389. dprintf(idx, " INFO: %s\n", ch->info);
  390. }
  391. }
  392. }
  393. /* user-defined extra fields */
  394. for (ue = u->entries; ue; ue = ue->next)
  395. if (!ue->name && ue->type->display)
  396. ue->type->display(idx, ue, u);
  397. }
  398. /* show user by ident */
  399. void tell_user_ident(int idx, char *id)
  400. {
  401. struct userrec *u = get_user_by_handle(userlist, id);
  402. struct flag_record user = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
  403. get_user_flagrec(dcc[idx].user, &user, NULL);
  404. if (u == NULL)
  405. u = get_user_by_host(id);
  406. if (u == NULL || (u && !whois_access(dcc[idx].user, u))) {
  407. dprintf(idx, "Can't find anyone matching that, or you have no access to view them.\n");
  408. return;
  409. }
  410. char format[81] = "";
  411. if (u->bot) {
  412. simple_snprintf(format, sizeof format, "%%-%us FLAGS LAST\n", HANDLEN);
  413. dprintf(idx, format, "BOTNICK");
  414. } else {
  415. simple_snprintf(format, sizeof format, "%%-%us PASS FLAGS LAST\n", HANDLEN);
  416. dprintf(idx, format, "HANDLE");
  417. }
  418. tell_user(idx, u);
  419. }
  420. /* match string:
  421. * wildcard to match nickname or hostmasks
  422. * +attr to find all with attr */
  423. void tell_users_match(int idx, char *mtch, int start, int limit, char *chname, int isbot)
  424. {
  425. char format[81] = "";
  426. struct userrec *u = NULL;
  427. int fnd = 0, cnt = 0, nomns = 0, flags = 0;
  428. struct list_type *q = NULL;
  429. struct flag_record user, pls, mns;
  430. dprintf(idx, "*** Matching '%s':\n", mtch);
  431. if (isbot) {
  432. simple_snprintf(format, sizeof format, "%%-%us FLAGS LAST\n", HANDLEN);
  433. dprintf(idx, format, "BOTNICK");
  434. } else {
  435. simple_snprintf(format, sizeof format, "%%-%us PASS FLAGS LAST\n", HANDLEN);
  436. dprintf(idx, format, "HANDLE");
  437. }
  438. if (start > 1)
  439. dprintf(idx, "(skipping first %d)\n", start - 1);
  440. if (strchr("+-&|", *mtch)) {
  441. user.match = pls.match = FR_GLOBAL | FR_CHAN;
  442. if (isbot) {
  443. user.match |= FR_BOT;
  444. pls.match |= FR_BOT;
  445. }
  446. break_down_flags(mtch, &pls, &mns);
  447. mns.match = pls.match ^ (FR_AND | FR_OR);
  448. if (!mns.global && !mns.chan) {
  449. nomns = 1;
  450. if (!pls.global && !pls.chan) {
  451. /* happy now BB you weenie :P */
  452. dprintf(idx, "Unknown flag specified for matching!!\n");
  453. return;
  454. }
  455. }
  456. if (!chname || !chname[0])
  457. chname = dcc[idx].u.chat->con_chan;
  458. flags = 1;
  459. }
  460. for (u = userlist; u; u = u->next) {
  461. if (!whois_access(dcc[idx].user, u) || (isbot && !u->bot) || (!isbot && u->bot)) {
  462. continue;
  463. } else if (flags) {
  464. get_user_flagrec(u, &user, chname);
  465. if (flagrec_eq(&pls, &user)) {
  466. if (nomns || !flagrec_eq(&mns, &user)) {
  467. cnt++;
  468. if ((cnt <= limit) && (cnt >= start))
  469. tell_user(idx, u);
  470. if (cnt == limit + 1)
  471. dprintf(idx, "(more than %d matches; list truncated)\n", limit);
  472. }
  473. }
  474. } else if (wild_match(mtch, u->handle)) {
  475. cnt++;
  476. if ((cnt <= limit) && (cnt >= start))
  477. tell_user(idx, u);
  478. if (cnt == limit + 1)
  479. dprintf(idx, "(more than %d matches; list truncated)\n", limit);
  480. } else {
  481. fnd = 0;
  482. for (q = (struct list_type *) get_user(&USERENTRY_HOSTS, u); q; q = q->next) {
  483. if ((wild_match(mtch, q->extra)) && (!fnd)) {
  484. cnt++;
  485. fnd = 1;
  486. if ((cnt <= limit) && (cnt >= start)) {
  487. tell_user(idx, u);
  488. }
  489. if (cnt == limit + 1)
  490. dprintf(idx, "(more than %d matches; list truncated)\n", limit);
  491. }
  492. }
  493. }
  494. }
  495. dprintf(idx, "--- Found %d match%s.\n", cnt, cnt == 1 ? "" : "es");
  496. }
  497. void backup_userfile()
  498. {
  499. char s[DIRMAX] = "", s2[DIRMAX] = "";
  500. putlog(LOG_MISC, "*", "Backing up user file...");
  501. simple_snprintf(s, sizeof s, "%s/.u.0", conf.datadir);
  502. simple_snprintf(s2, sizeof s2, "%s/.u.1", conf.datadir);
  503. movefile(s, s2);
  504. copyfile(userfile, s);
  505. }
  506. /*
  507. * tagged lines in the user file:
  508. * * OLD:
  509. * # (comment)
  510. * ; (comment)
  511. * - hostmask(s)
  512. * + email
  513. * * dcc directory
  514. * = comment
  515. * : info line
  516. * . xtra (Tcl)
  517. * ! channel-specific
  518. * !! global laston
  519. * :: channel-specific bans
  520. * NEW:
  521. * *ban global bans
  522. * *ignore global ignores
  523. * ::#chan channel bans
  524. * - entries in each
  525. * + denotes tcl command
  526. * <handle> begin user entry
  527. * --KEY INFO - info on each
  528. * NEWER:
  529. * % exemptmask(s)
  530. * @ Invitemask(s)
  531. * *exempt global exempts
  532. * *Invite global Invites
  533. * && channel-specific exempts
  534. * &&#chan channel exempts
  535. * $$ channel-specific Invites
  536. * $$#chan channel Invites
  537. */
  538. int readuserfile(const char *file, struct userrec **ret)
  539. {
  540. const char salt1[] = SALT1;
  541. EncryptedStream stream(salt1);
  542. if (stream.loadFile(file))
  543. return 1;
  544. return stream_readuserfile(stream, ret);
  545. }
  546. int stream_readuserfile(bd::Stream& stream, struct userrec **ret)
  547. {
  548. char *p = NULL, buf[1024] = "", lasthand[512] = "", *attr = NULL, *pass = NULL;
  549. char *code = NULL, s1[1024] = "", *s = buf, ignored[512] = "";
  550. struct userrec *bu = NULL, *u = NULL;
  551. struct chanset_t *cst = NULL;
  552. struct flag_record fr;
  553. struct chanuserrec *cr = NULL;
  554. int i, line = 0;
  555. bu = (*ret);
  556. if (bu == userlist) {
  557. clear_chanlist();
  558. lastuser = NULL;
  559. global_bans = NULL;
  560. global_ign = NULL;
  561. global_exempts = NULL;
  562. global_invites = NULL;
  563. }
  564. noshare = 1;
  565. /* read opening comment */
  566. bd::String str(stream.getline(180));
  567. if (unlikely(str[1] < '4')) {
  568. putlog(LOG_MISC, "*", "!*! Empty or malformed userfile.");
  569. return 0;
  570. }
  571. if (unlikely(str[1] > '4')) {
  572. putlog(LOG_MISC, "*", "Invalid userfile format.");
  573. return 0;
  574. }
  575. while (stream.tell() < stream.length()) {
  576. s = buf;
  577. str = stream.getline(sizeof(buf)).chomp();
  578. strlcpy(s, str.c_str(), std::min(str.length() + 1, sizeof(buf)));
  579. if (1) {
  580. line++;
  581. if (s[0] != '#' && s[0] != ';' && s[0]) {
  582. code = newsplit(&s);
  583. rmspace(s);
  584. if (!strcmp(code, "-")) { /* ignores/bans */
  585. if (!lasthand[0])
  586. continue; /* Skip this entry. */
  587. if (u) { /* only break it down if there a real users */
  588. p = strchr(s, ',');
  589. while (p != NULL) {
  590. splitc(s1, s, ',');
  591. rmspace(s1);
  592. if (s1[0])
  593. set_user(&USERENTRY_HOSTS, u, s1);
  594. p = strchr(s, ',');
  595. }
  596. }
  597. /* channel bans are never stacked with , */
  598. if (s[0]) {
  599. if (lasthand[0] && strchr(CHANMETA, lasthand[0]) != NULL)
  600. restore_chanmask('b', cst, s);
  601. else if (lasthand[0] == '*') {
  602. if (lasthand[1] == IGNORE_NAME[1])
  603. restore_ignore(s);
  604. else if (lasthand[1] == SET_NAME[1]) {
  605. set_cmd_pass(s, 0); /* no need to share here, if we have a new userfile
  606. * then leaf bots under us also get the new userfile */
  607. }
  608. else
  609. restore_chanmask('b', NULL, s);
  610. } else if (lasthand[0])
  611. set_user(&USERENTRY_HOSTS, u, s);
  612. }
  613. } else if (!strcmp(code, "%")) { /* exemptmasks */
  614. if (!lasthand[0])
  615. continue; /* Skip this entry. */
  616. if (s[0]) {
  617. if (lasthand[0] == '#' || lasthand[0] == '+')
  618. restore_chanmask('e', cst, s);
  619. else if (lasthand[0] == '*')
  620. if (lasthand[1] == EXEMPT_NAME[1])
  621. restore_chanmask('e', NULL, s);
  622. }
  623. } else if (!strcmp(code, "@")) { /* Invitemasks */
  624. if (!lasthand[0])
  625. continue; /* Skip this entry. */
  626. if (s[0]) {
  627. if (lasthand[0] == '#' || lasthand[0] == '+') {
  628. restore_chanmask('I', cst, s);
  629. } else if (lasthand[0] == '*') {
  630. if (lasthand[1] == INVITE_NAME[1]) {
  631. restore_chanmask('I', NULL, s);
  632. } else if (lasthand[1] == SET_NAME[1]) {
  633. var_userfile_share_line(s, -1, 0);
  634. }
  635. }
  636. }
  637. } else if (!strcmp(code, "!")) { /* user channel record */
  638. /* ! #chan laston flags [info] */
  639. char *chname = NULL, *st = NULL, *fl = NULL;
  640. if (u) {
  641. chname = newsplit(&s);
  642. st = newsplit(&s);
  643. fl = newsplit(&s);
  644. rmspace(s);
  645. fr.match = FR_CHAN;
  646. if (u->bot)
  647. fr.match |= FR_BOT;
  648. break_down_flags(fl, &fr, 0);
  649. if (findchan_by_dname(chname)) {
  650. for (cr = u->chanrec; cr; cr = cr->next)
  651. if (!rfc_casecmp(cr->channel, chname))
  652. break;
  653. if (!cr) {
  654. cr = (struct chanuserrec *) calloc(1, sizeof(struct chanuserrec));
  655. cr->next = u->chanrec;
  656. u->chanrec = cr;
  657. strlcpy(cr->channel, chname, 80);
  658. cr->laston = atoi(st);
  659. cr->flags = fr.chan;
  660. if (s[0]) {
  661. cr->info = strdup(s);
  662. } else
  663. cr->info = NULL;
  664. }
  665. }
  666. }
  667. } else if (!strcmp(code, "+")) { /* add channel record */
  668. if (s[0] && lasthand[0] == '*' && lasthand[1] == CHANS_NAME[1]) {
  669. char *options = NULL, *chan = NULL, *my_ptr = NULL;
  670. char resultbuf[RESULT_LEN] = "";
  671. options = my_ptr = strdup(s);
  672. newsplit(&options);
  673. newsplit(&options);
  674. chan = newsplit(&options);
  675. /* hack to remove { } */
  676. newsplit(&options);
  677. options[strlen(options) - 1] = 0;
  678. if (channel_add(resultbuf, chan, options) != OK) {
  679. putlog(LOG_MISC, "*", "Channel parsing error in userfile on line %d", line);
  680. free(my_ptr);
  681. noshare = 0;
  682. return 0;
  683. }
  684. free(my_ptr);
  685. }
  686. } else if (!strncmp(code, "::", 2)) { /* channel-specific bans */
  687. strlcpy(lasthand, &code[2], sizeof(lasthand));
  688. u = NULL;
  689. if (!findchan_by_dname(lasthand)) {
  690. strlcpy(s1, lasthand, sizeof(s1));
  691. strlcat(s1, " ", sizeof(s1));
  692. if (strstr(ignored, s1) == NULL) {
  693. strlcat(ignored, lasthand, sizeof(ignored));
  694. strlcat(ignored, " ", sizeof(ignored));
  695. }
  696. lasthand[0] = 0;
  697. } else {
  698. /* Remove all bans for this channel to avoid dupes */
  699. /* NOTE only remove bans for when getting a userfile
  700. * from another bot & that channel is shared */
  701. cst = findchan_by_dname(lasthand);
  702. clear_masks(cst->bans);
  703. cst->bans = NULL;
  704. }
  705. } else if (!strncmp(code, "&&", 2)) { /* channel-specific exempts */
  706. strlcpy(lasthand, &code[2], sizeof(lasthand));
  707. u = NULL;
  708. if (!findchan_by_dname(lasthand)) {
  709. strlcpy(s1, lasthand, sizeof(s1));
  710. strlcat(s1, " ", sizeof(s1));
  711. if (strstr(ignored, s1) == NULL) {
  712. strlcat(ignored, lasthand, sizeof(ignored));
  713. strlcat(ignored, " ", sizeof(ignored));
  714. }
  715. lasthand[0] = 0;
  716. } else {
  717. /* Remove all exempts for this channel to avoid dupes */
  718. /* NOTE only remove exempts for when getting a userfile
  719. * from another bot & that channel is shared */
  720. cst = findchan_by_dname(lasthand);
  721. clear_masks(cst->exempts);
  722. cst->exempts = NULL;
  723. }
  724. } else if (!strncmp(code, "$$", 2)) { /* channel-specific invites */
  725. strlcpy(lasthand, &code[2], sizeof(lasthand));
  726. u = NULL;
  727. if (!findchan_by_dname(lasthand)) {
  728. strlcpy(s1, lasthand, sizeof(s1));
  729. strlcat(s1, " ", sizeof(s1));
  730. if (strstr(ignored, s1) == NULL) {
  731. strlcat(ignored, lasthand, sizeof(ignored));
  732. strlcat(ignored, " ", sizeof(ignored));
  733. }
  734. lasthand[0] = 0;
  735. } else {
  736. /* Remove all invites for this channel to avoid dupes */
  737. /* NOTE only remove invites for when getting a userfile
  738. * from another bot & that channel is shared */
  739. cst = findchan_by_dname(lasthand);
  740. clear_masks(cst->invites);
  741. cst->invites = NULL;
  742. }
  743. } else if (!strncmp(code, "--", 2)) { /* user USERENTRY */
  744. if (u) {
  745. /* new format storage */
  746. struct user_entry *ue = NULL;
  747. int ok = 0;
  748. for (ue = u->entries; ue && !ok; ue = ue->next)
  749. if (ue->name && !strcasecmp(code + 2, ue->name)) {
  750. struct list_type *list = NULL;
  751. list = (struct list_type *) calloc(1, sizeof(struct list_type));
  752. list->next = NULL;
  753. list->extra = strdup(s);
  754. list_append((&ue->u.list), list);
  755. ok = 1;
  756. }
  757. /* if we don't have the entry, make it */
  758. if (!ok) {
  759. ue = (struct user_entry *) calloc(1, sizeof(struct user_entry));
  760. // ue->name = (char *) calloc(1, strlen(code + 1));
  761. ue->name = strdup(code + 2);
  762. ue->type = NULL;
  763. // strcpy(ue->name, code + 2);
  764. ue->u.list = (struct list_type *) calloc(1, sizeof(struct list_type));
  765. ue->u.list->next = NULL;
  766. ue->u.list->extra = strdup(s);
  767. list_insert((&u->entries), ue);
  768. }
  769. }
  770. } else if (!rfc_casecmp(code, BAN_NAME)) {
  771. strlcpy(lasthand, code, sizeof(lasthand));
  772. u = NULL;
  773. } else if (!rfc_casecmp(code, IGNORE_NAME)) {
  774. strlcpy(lasthand, code, sizeof(lasthand));
  775. u = NULL;
  776. } else if (!rfc_casecmp(code, EXEMPT_NAME)) {
  777. strlcpy(lasthand, code, sizeof(lasthand));
  778. u = NULL;
  779. } else if (!rfc_casecmp(code, INVITE_NAME)) {
  780. strlcpy(lasthand, code, sizeof(lasthand));
  781. u = NULL;
  782. } else if (!rfc_casecmp(code, CHANS_NAME)) {
  783. strlcpy(lasthand, code, sizeof(lasthand));
  784. u = NULL;
  785. } else if (!rfc_casecmp(code, SET_NAME)) {
  786. strlcpy(lasthand, code, sizeof(lasthand));
  787. u = NULL;
  788. } else if (code[0] == '*') {
  789. lasthand[0] = 0;
  790. u = NULL;
  791. } else { /* its a user ! */
  792. pass = newsplit(&s); /* old style passwords */
  793. attr = newsplit(&s);
  794. rmspace(s);
  795. if (unlikely(!attr[0] || !pass[0])) {
  796. putlog(LOG_MISC, "*", "* Corrupt user record line: %d!", line);
  797. lasthand[0] = 0;
  798. noshare = 0;
  799. return 0;
  800. } else {
  801. int isbot = 0;
  802. if (code[0] == '-') {
  803. code++;
  804. isbot++;
  805. }
  806. u = get_user_by_handle(bu, code);
  807. if (unlikely(u)) {
  808. putlog(LOG_ERROR, "@", "* Duplicate user record '%s'!", code);
  809. lasthand[0] = 0;
  810. u = NULL;
  811. } else {
  812. fr.match = FR_GLOBAL;
  813. if (isbot)
  814. fr.match |= FR_BOT;
  815. break_down_flags(attr, &fr, 0);
  816. strlcpy(lasthand, code, sizeof(lasthand));
  817. cst = NULL;
  818. if (strlen(code) > HANDLEN)
  819. code[HANDLEN] = 0;
  820. if (unlikely(strlen(pass) > 20)) { /* old style passwords */
  821. putlog(LOG_MISC, "*", "* Corrupted password reset for '%s'", code);
  822. pass[0] = '-';
  823. pass[1] = 0;
  824. }
  825. bu = adduser(bu, code, 0, pass, sanity_check(fr.global, isbot), isbot);
  826. u = get_user_by_handle(bu, code);
  827. for (i = 0; i < dcc_total; i++)
  828. if (dcc[i].type && !strcasecmp(code, dcc[i].nick))
  829. dcc[i].user = u;
  830. if (!strcasecmp(code, conf.bot->nick))
  831. conf.bot->u = u;
  832. /* if s starts with '/' it's got file info */
  833. }
  834. }
  835. }
  836. }
  837. }
  838. }
  839. (*ret) = bu;
  840. if (ignored[0]) {
  841. putlog(LOG_MISC, "*", "Ignored masks for channel(s): %s", ignored);
  842. }
  843. putlog(LOG_MISC, "*", "Userfile loaded, unpacking...");
  844. for (u = bu; u; u = u->next) {
  845. struct user_entry *e = NULL;
  846. if (unlikely(!u->bot && !strcasecmp (u->handle, conf.bot->nick))) {
  847. putlog(LOG_MISC, "*", "(!) I have a user record, but am not classified as a BOT!");
  848. u->bot = 1;
  849. }
  850. for (e = u->entries; e; e = e->next)
  851. if (likely(e->name)) {
  852. struct user_entry_type *uet = find_entry_type(e->name);
  853. if (uet) {
  854. e->type = uet;
  855. uet->unpack(u, e);
  856. free(e->name);
  857. e->name = NULL;
  858. } else
  859. sdprintf("FAILED TO UNPACK '%s'", e->name);
  860. }
  861. }
  862. /* process the user data *now* */
  863. if (!conf.bot->hub)
  864. unlink(userfile);
  865. noshare = 0;
  866. return 1;
  867. }
  868. void link_pref_val(struct userrec *u, char *val)
  869. {
  870. /* val must be HANDLEN + 4 chars minimum */
  871. val[0] = 'Z';
  872. val[1] = 0;
  873. if (!u)
  874. return;
  875. if (!u->bot)
  876. return;
  877. struct bot_addr *ba = NULL;
  878. if (!(ba = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, u))) {
  879. return;
  880. }
  881. if (!ba->hublevel || ba->hublevel == 999) {
  882. return;
  883. }
  884. simple_snprintf(val, HANDLEN + 4, "%02d%s", ba->hublevel, u->handle);
  885. }
  886. /*
  887. starting at "current" or "userlist" if NULL, find next bot with a
  888. link_pref_val higher than "lowval" and lower than "highval"
  889. If none found return bot with best overall link_pref_val
  890. If still not found return NULL
  891. */
  892. struct userrec *next_hub(struct userrec *current, char *lowval, char *highval)
  893. {
  894. char thisval[HANDLEN + 4] = "", bestmatchval[HANDLEN + 4] = "z", bestallval[HANDLEN + 4] = "z";
  895. struct userrec *cur = NULL, *bestmatch = NULL, *bestall = NULL;
  896. if (current)
  897. cur = current->next;
  898. else
  899. cur = userlist;
  900. while (cur != current) {
  901. if (!cur)
  902. cur = userlist;
  903. if (cur == current)
  904. break;
  905. if (cur->bot && (strcasecmp(cur->handle, conf.bot->nick))) {
  906. link_pref_val(cur, thisval);
  907. if ((strcmp(thisval, lowval) < 0) && (strcmp(thisval, highval) > 0) &&(strcmp(thisval, bestmatchval) < 0)) {
  908. strlcpy(bestmatchval, thisval, sizeof(bestmatchval));
  909. bestmatch = cur;
  910. }
  911. if ((strcmp(thisval, lowval) < 0) && (strcmp(thisval, bestallval) < 0)) {
  912. strlcpy(bestallval, thisval, sizeof(bestallval));
  913. bestall = cur;
  914. }
  915. }
  916. cur = cur->next;
  917. }
  918. if (bestmatch)
  919. return bestmatch;
  920. if (bestall)
  921. return bestall;
  922. return NULL;
  923. }
  924. static void autolink_cycle_hub(char *start)
  925. {
  926. char bestval[HANDLEN + 4] = "", curval[HANDLEN + 4] = "", myval[HANDLEN + 4] = "";
  927. tand_t *bot = NULL;
  928. link_pref_val(conf.bot->u, myval);
  929. strlcpy(bestval, myval, sizeof(bestval));
  930. for (int i = 0; i < dcc_total; i++) {
  931. if (dcc[i].type) {
  932. if (dcc[i].type == &DCC_BOT_NEW)
  933. return;
  934. if (dcc[i].type == &DCC_FORK_BOT)
  935. return;
  936. if (dcc[i].type == &DCC_BOT) {
  937. if (dcc[i].status & (STAT_OFFEREDU | STAT_GETTINGU | STAT_SENDINGU))
  938. continue; /* lets let the binary update have its peace. */
  939. if ((bot = findbot(dcc[i].nick)) && bot->buildts != buildts)
  940. continue; /* same thing. */
  941. if (dcc[i].status & (STAT_SHARE | STAT_OFFERED | STAT_SENDING | STAT_GETTING)) {
  942. link_pref_val(dcc[i].user, curval);
  943. if (strcmp(myval, curval) < 0) {
  944. /* I should be aggressive to this one */
  945. if (dcc[i].status & STAT_AGGRESSIVE) {
  946. putlog(LOG_MISC, "*", "Passively sharing with %s but should be aggressive", dcc[i].user->handle);
  947. putlog(LOG_DEBUG, "*", "My linkval: %s - %s linkval: %s", myval, dcc[i].nick, curval);
  948. botunlink(-2, dcc[i].nick, "Marked passive, should be aggressive");
  949. return;
  950. }
  951. } else {
  952. /* I should be passive to this one */
  953. if (!(dcc[i].status & STAT_AGGRESSIVE)) {
  954. putlog(LOG_MISC, "*", "Aggressively sharing with %s but should be passive", dcc[i].user->handle);
  955. putlog(LOG_DEBUG, "*", "My linkval: %s - %s linkval: %s", myval, dcc[i].nick, curval);
  956. botunlink(-2, dcc[i].nick, "Marked aggressive, should be passive");
  957. return;
  958. }
  959. if (strcmp(curval, bestval) < 0)
  960. strlcpy(bestval, curval, sizeof(bestval));
  961. }
  962. }
  963. }
  964. }
  965. }
  966. struct userrec *u = NULL;
  967. if (start)
  968. u = get_user_by_handle(userlist, start);
  969. if (u) {
  970. link_pref_val(u, curval);
  971. if (strcmp(bestval, curval) < 0) {
  972. /* This happens if we're already connected to a good hub but we failed to link to another hub as well
  973. can happen if you .link.... but it's nothing FATAL :) */
  974. /* This shouldn't happen. Getting a failed link attempt (start!=NULL)
  975. while a dcc scan indicates we *are* connected to a better bot than
  976. the one we failed a link to.
  977. */
  978. // putlog(LOG_BOTS, "*", "Failed link attempt to %s but connected to %s already???", u->handle, (char *) &bestval[2]);
  979. return;
  980. }
  981. } else
  982. strlcpy(curval, "0", sizeof(curval));
  983. /* link to the (highlest level)/best hub */
  984. u = next_hub(u, bestval, curval);
  985. if (u && !in_chain(u->handle))
  986. botlink("", -3, u->handle);
  987. }
  988. typedef struct hublist_entry {
  989. struct hublist_entry *next;
  990. struct userrec *u;
  991. } tag_hublist_entry;
  992. int botlinkcount = 0;
  993. static void autolink_random_hub(char *avoidbot) {
  994. /* Pick a random hub, but avoid 'avoidbot' */
  995. int hlc = 0;
  996. struct hublist_entry *hl = NULL, *hl2 = NULL;
  997. struct userrec *tmpu = NULL;
  998. struct flag_record fr = { FR_GLOBAL|FR_BOT, 0, 0, 0 };
  999. for (struct userrec *u = userlist; u; u = u->next) {
  1000. get_user_flagrec(u, &fr, NULL);
  1001. if (glob_bot(fr) && strcasecmp(u->handle, conf.bot->nick) && (bot_hublevel(u) < 999)) {
  1002. if (strcmp(u->handle, avoidbot)) {
  1003. hl2 = hl;
  1004. hl = (struct hublist_entry *) calloc(1, sizeof(struct hublist_entry));
  1005. hl->next = hl2;
  1006. hlc++;
  1007. hl->u = u;
  1008. } else
  1009. tmpu = u;
  1010. }
  1011. }
  1012. /* We probably have 1 hub and avoided it :/ */
  1013. if (!hlc && tmpu) {
  1014. hl2 = hl;
  1015. hl = (struct hublist_entry *) calloc(1, sizeof(struct hublist_entry));
  1016. hl->next = hl2;
  1017. hlc++;
  1018. hl->u = tmpu;
  1019. }
  1020. hlc = randint(hlc);
  1021. while (hl) {
  1022. if (!hlc) {
  1023. botlink("", -3, hl->u->handle);
  1024. }
  1025. hlc--;
  1026. hl2 = hl->next;
  1027. free(hl);
  1028. hl = hl2;
  1029. }
  1030. }
  1031. static void autolink_cycle_leaf(char *start)
  1032. {
  1033. struct bot_addr *my_ba = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
  1034. char uplink[HANDLEN + 1] = "", avoidbot[HANDLEN + 1] = "", curhub[HANDLEN + 1] = "";
  1035. /* Reset connection attempts if we ain't called due to a failed link */
  1036. if (!start)
  1037. botlinkcount = 0;
  1038. if (my_ba && (my_ba->uplink[0])) {
  1039. strlcpy(uplink, my_ba->uplink, sizeof(uplink));
  1040. }
  1041. for (int i = 0; i < dcc_total; i++) {
  1042. if (dcc[i].type) {
  1043. if ((dcc[i].type == &DCC_BOT_NEW) || (dcc[i].type == &DCC_FORK_BOT))
  1044. return;
  1045. if (dcc[i].hub && dcc[i].type == &DCC_BOT) {
  1046. strlcpy(curhub, dcc[i].nick, sizeof(curhub));
  1047. break;
  1048. }
  1049. }
  1050. }
  1051. if (curhub[0]) {
  1052. /* we are linked to a bot (hub) */
  1053. if (uplink[0] && !strcmp(curhub, uplink))
  1054. /* Connected to uplink, nothing more to do */
  1055. return;
  1056. if (start)
  1057. /* Failed a link... let's just wait for next regular call */
  1058. return;
  1059. if (dont_restructure)
  1060. return;
  1061. if (uplink[0]) {
  1062. /* Trying the uplink */
  1063. botlink("", -3, uplink);
  1064. return;
  1065. }
  1066. /* we got a hub currently, and no set uplink. Stay here */
  1067. return;
  1068. } else {
  1069. /* no hubs connected... pick one */
  1070. if (!start) {
  1071. /* Regular interval call, no previous failed link */
  1072. if (uplink[0]) {
  1073. /* We have a set uplink, try it */
  1074. botlink("", -3, uplink);
  1075. return;
  1076. }
  1077. /* No preferred uplink, we need a random bot */
  1078. avoidbot[0] = 0;
  1079. } else {
  1080. /* We got a failed link... */
  1081. botlinkcount++;
  1082. if (botlinkcount >= 3)
  1083. /* tried 3+ random hubs without success, wait for next regular interval call */
  1084. return;
  1085. /* We need a random bot but *not* the last we tried */
  1086. strlcpy(avoidbot, start, sizeof(avoidbot));
  1087. }
  1088. }
  1089. autolink_random_hub(avoidbot);
  1090. }
  1091. void autolink_cycle()
  1092. {
  1093. char start[HANDLEN + 1] = "";
  1094. if (autolink_failed[0]) {
  1095. strlcpy(start, autolink_failed, HANDLEN + 1);
  1096. autolink_failed[0] = 0;
  1097. }
  1098. if (conf.bot->hub)
  1099. autolink_cycle_hub(start[0] ? start : NULL);
  1100. else if (conf.bot->localhub)
  1101. autolink_cycle_leaf(start[0] ? start : NULL);
  1102. else { //Connect to the localhub
  1103. if (tands == 0) {
  1104. // Make sure not already trying for the localhub
  1105. for (int i = 0; i < dcc_total; i++) {
  1106. if (dcc[i].type) {
  1107. if ((dcc[i].type == &DCC_BOT_NEW) || (dcc[i].type == &DCC_FORK_BOT))
  1108. return;
  1109. }
  1110. }
  1111. sdprintf("need to link to my localhub: %s\n", conf.localhub);
  1112. botlink("", -3, conf.localhub);
  1113. }
  1114. }
  1115. }
  1116. void check_stale_dcc_users()
  1117. {
  1118. for (int i = 0; i < dcc_total; ++i) {
  1119. if (!dcc[i].type || !dcc[i].nick[0]) continue;
  1120. if (dcc[i].user == NULL && !(dcc[i].user = get_user_by_handle(userlist, dcc[i].nick))) { /* Removed user */
  1121. if (dcc[i].type == &DCC_BOT || dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_NEW)
  1122. botunlink(i, dcc[i].nick, "No longer a valid bot.");
  1123. else if (dcc[i].type == &DCC_CHAT) {
  1124. if (!backgrd && term_z && !strcmp(dcc[i].nick, "HQ"))
  1125. setup_HQ(i);
  1126. else
  1127. do_boot(i, "internal", "No longer a valid user.");
  1128. }
  1129. }
  1130. }
  1131. }
  1132. /* vim: set sts=2 sw=2 ts=8 et: */