1
0

eggdrop.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. /*
  2. * eggdrop.h
  3. * Eggdrop compile-time settings
  4. *
  5. * IF YOU ALTER THIS FILE, YOU NEED TO RECOMPILE THE BOT.
  6. *
  7. */
  8. #ifndef _EGG_EGGDROP_H
  9. #define _EGG_EGGDROP_H
  10. #ifdef HAVE_OPENSSL_SSL_H
  11. # ifndef SSL_INC
  12. # include <openssl/ssl.h>
  13. # include <openssl/rand.h>
  14. # include <openssl/err.h>
  15. # include <openssl/md5.h>
  16. # define SSL_INC
  17. # endif /* ! SSL_INC */
  18. # undef HAVE_SSL
  19. /* #define HAVE_SSL 1 */
  20. #endif /* HAVE_OPENSSL_SSL_H */
  21. /*
  22. * Undefine this to completely disable context debugging.
  23. * WARNING: DO NOT send in bug reports if you undefine this!
  24. */
  25. #define DEBUG_CONTEXT
  26. /*
  27. * Set the following to the timestamp for the logfile entries.
  28. * Popular times might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec)
  29. * Read `man strftime' for more formatting options. Keep it below 32 chars.
  30. */
  31. #define LOG_TS "[%H:%M]"
  32. /*
  33. * HANDLEN note:
  34. * HANDLEN defines the maximum length a handle on the bot can be.
  35. * Standard (and minimum) is 9 characters long.
  36. *
  37. * Beware that using lengths over 9 chars is 'non-standard' and if
  38. * you wish to link to other bots, they _must_ both have the same
  39. * maximum handle length.
  40. *
  41. * NICKMAX note:
  42. * You should leave this at 32 characters and modify nick-len in the
  43. * configuration file instead.
  44. */
  45. #define HANDLEN 9 /* valid values 9->NICKMAX */
  46. #define NICKMAX 32 /* valid values HANDLEN->32 */
  47. /* Handy string lengths */
  48. #define UHOSTMAX 291 + NICKMAX /* 32 (ident) + 3 (\0, !, @) + NICKMAX */
  49. #define DIRMAX 512 /* paranoia */
  50. #define LOGLINEMAX 867 /* for misc.c/putlog() <cybah> */
  51. #define BADHANDCHARS "-,+*=:!.@#;$%&"
  52. #define MAX_BOTS 500
  53. #define SERVLEN 60
  54. #define SGRAB 2011 /* How much data to allow through sockets. */
  55. #define PRIV_OP 1
  56. #define PRIV_VOICE 2
  57. #define PRIO_DEOP 1
  58. #define PRIO_KICK 2
  59. #define KICK_BANNED 1
  60. #define KICK_KUSER 2
  61. #define KICK_KICKBAN 3
  62. #define KICK_MASSDEOP 4
  63. #define KICK_BADOP 5
  64. #define KICK_BADOPPED 6
  65. #define KICK_MANUALOP 7
  66. #define KICK_MANUALOPPED 8
  67. #define KICK_CLOSED 9
  68. #define KICK_FLOOD 10
  69. #define KICK_NICKFLOOD 11
  70. #define KICK_KICKFLOOD 12
  71. #define KICK_BOGUSUSERNAME 13
  72. #define KICK_MEAN 14
  73. #define KICK_BOGUSKEY 15
  74. #define ERR_BINSTAT 1
  75. #define ERR_BINMOD 2
  76. #define ERR_PASSWD 3
  77. #define ERR_WRONGBINDIR 4
  78. #define ERR_CONFSTAT 5
  79. #define ERR_TMPSTAT 6
  80. #define ERR_CONFDIRMOD 7
  81. #define ERR_CONFMOD 8
  82. #define ERR_TMPMOD 9
  83. #define ERR_NOCONF 10
  84. #define ERR_CONFBADENC 11
  85. #define ERR_WRONGUID 12
  86. #define ERR_WRONGUNAME 13
  87. #define ERR_BADCONF 14
  88. #define ERR_MAX 15
  89. #define C_BLACK 1
  90. #define C_BLUE 2
  91. #define C_GREEN 3
  92. #define C_CYAN 4
  93. #define C_RED 5
  94. #define C_PURPLE 6
  95. #define C_BROWN 7
  96. #define C_LIGHTGREY 8
  97. #define C_DARKGREY 9
  98. #define C_LIGHTBLUE 10
  99. #define C_LIGHTGREEN 11
  100. #define C_LIGHTCYAN 12
  101. #define C_LIGHTRED 13
  102. #define C_LIGHTPURPLE 14
  103. #define C_YELLOW 15
  104. #define C_WHITE 16
  105. #define BOLD_OPEN 1
  106. #define BOLD_CLOSE 2
  107. #define UNDERLINE_OPEN 3
  108. #define UNDERLINE_CLOSE 4
  109. #define COLOR_OPEN 5
  110. #define COLOR_CLOSE 6
  111. #define FLASH_OPEN 7
  112. #define FLASH_CLOSE 8
  113. #define EMAIL_OWNERS 0x1
  114. #define EMAIL_TEAM 0x2
  115. /*
  116. * The 'configure' script should make this next part automatic,
  117. * so you shouldn't need to adjust anything below.
  118. */
  119. #define NICKLEN NICKMAX + 1
  120. #define UHOSTLEN UHOSTMAX + 1
  121. #define DIRLEN DIRMAX + 1
  122. #define LOGLINELEN LOGLINEMAX + 1
  123. #define NOTENAMELEN ((HANDLEN * 2) + 1)
  124. #define BADNICKCHARS "-,+*=:!.@#;$%&"
  125. /* Have to use a weird way to make the compiler error out cos not all
  126. * compilers support #error or error
  127. */
  128. #if !HAVE_VSPRINTF
  129. # include "error_you_need_vsprintf_to_compile_eggdrop"
  130. #endif
  131. /*
  132. * Enable IPv6 debugging?
  133. */
  134. #define DEBUG_IPV6 1
  135. #define HAVE_IPV6 1
  136. /* IPv6 sanity checks. */
  137. #ifdef USE_IPV6
  138. # ifndef HAVE_IPV6
  139. # undef USE_IPV6
  140. # endif
  141. # ifndef HAVE_GETHOSTBYNAME2
  142. # ifndef HAVE_GETIPNODEBYNAME
  143. # undef USE_IPV6
  144. # endif
  145. # endif
  146. #endif
  147. #if HAVE_UNISTD_H
  148. # include <unistd.h>
  149. #endif
  150. #if !defined(STDC_HEADERS)
  151. # include "you_need_to_upgrade_your_compiler_to_a_standard_c_one_mate!"
  152. #endif
  153. #if (NICKMAX < 9) || (NICKMAX > 32)
  154. # include "invalid NICKMAX value"
  155. #endif
  156. #if (HANDLEN < 9) || (HANDLEN > 32)
  157. # include "invalid HANDLEN value"
  158. #endif
  159. #if HANDLEN > NICKMAX
  160. # include "HANDLEN MUST BE <= NICKMAX"
  161. #endif
  162. /* NAME_MAX is what POSIX defines, but BSD calls it MAXNAMLEN.
  163. * Use 255 if we can't find anything else.
  164. */
  165. #ifndef NAME_MAX
  166. # ifdef MAXNAMLEN
  167. # define NAME_MAX MAXNAMLEN
  168. # else
  169. # define NAME_MAX 255
  170. # endif
  171. #endif
  172. /* Almost every module needs some sort of time thingy, so... */
  173. #if TIME_WITH_SYS_TIME
  174. # include <sys/time.h>
  175. # include <time.h>
  176. #else
  177. # if HAVE_SYS_TIME_H
  178. # include <sys/time.h>
  179. # else
  180. # include <time.h>
  181. # endif
  182. #endif
  183. #if !HAVE_SRANDOM
  184. # define srandom(x) srand(x)
  185. #endif
  186. #if !HAVE_RANDOM
  187. # define random() (rand()/16)
  188. #endif
  189. #if !HAVE_SIGACTION /* old "weird signals" */
  190. # define sigaction sigvec
  191. # ifndef sa_handler
  192. # define sa_handler sv_handler
  193. # define sa_mask sv_mask
  194. # define sa_flags sv_flags
  195. # endif
  196. #endif
  197. #if !HAVE_SIGEMPTYSET
  198. /* and they probably won't have sigemptyset, dammit */
  199. # define sigemptyset(x) ((*(int *)(x))=0)
  200. #endif
  201. #if !HAVE_SOCKLEN_T
  202. typedef int socklen_t;
  203. #endif
  204. /*
  205. * Handy aliases for memory tracking and core dumps
  206. */
  207. #define my_bzero(a, b) { char *x = (char *) a; int y = (int) b; while (y--) *x++ = 0; }
  208. #define nmalloc(x) n_malloc((x),__FILE__,__LINE__)
  209. #define nrealloc(x,y) n_realloc((x),(y),__FILE__,__LINE__)
  210. #define nfree(x) n_free((x),__FILE__,__LINE__)
  211. #define killsock(x) real_killsock((x),__FILE__,__LINE__)
  212. #ifdef DEBUG_CONTEXT
  213. # define Context eggContext(__FILE__, __LINE__, NULL)
  214. # define ContextNote(note) eggContextNote(__FILE__, __LINE__, NULL, note)
  215. #else
  216. # define Context {}
  217. # define ContextNote(note) {}
  218. #endif
  219. #ifdef DEBUG_ASSERT
  220. # define Assert(expr) do { \
  221. if (!(expr)) \
  222. eggAssert(__FILE__, __LINE__, NULL); \
  223. } while (0)
  224. #else
  225. # define Assert(expr) do { } while (0)
  226. #endif
  227. #ifndef COMPILING_MEM
  228. # undef malloc
  229. # define malloc(x) dont_use_old_malloc(x)
  230. # undef free
  231. # define free(x) dont_use_old_free(x)
  232. # undef realloc
  233. # define realloc(x) dont_use_old_realloc(x)
  234. #endif /* !COMPILING_MEM */
  235. /* 32 bit type */
  236. #if (SIZEOF_INT == 4)
  237. typedef unsigned int u_32bit_t;
  238. #else
  239. # if (SIZEOF_LONG == 4)
  240. typedef unsigned long u_32bit_t;
  241. # else
  242. # include "cant/find/32bit/type"
  243. # endif
  244. #endif
  245. typedef unsigned short int u_16bit_t;
  246. typedef unsigned char u_8bit_t;
  247. /* IP type */
  248. typedef u_32bit_t IP;
  249. typedef u_32bit_t dword;
  250. #define debug0(x) putlog(LOG_DEBUG,"*",x)
  251. #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
  252. #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
  253. #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
  254. #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
  255. /* These apparently are unsafe without recasting. */
  256. #define egg_isdigit(x) isdigit((int) (unsigned char) (x))
  257. #define egg_isxdigit(x) isxdigit((int) (unsigned char) (x))
  258. #define egg_isascii(x) isascii((int) (unsigned char) (x))
  259. #define egg_isspace(x) isspace((int) (unsigned char) (x))
  260. #define egg_islower(x) islower((int) (unsigned char) (x))
  261. #define egg_isupper(x) isupper((int) (unsigned char) (x))
  262. /***********************************************************************/
  263. /* It's used in so many places, let's put it here */
  264. typedef int (*Function) ();
  265. /* Public structure for the listening port map */
  266. struct portmap {
  267. int realport;
  268. int mappedto;
  269. struct portmap *next;
  270. };
  271. /* Public structure of all the dcc connections */
  272. struct dcc_table {
  273. char *name;
  274. int flags;
  275. void (*eof) (int);
  276. void (*activity) (int, char *, int);
  277. int *timeout_val;
  278. void (*timeout) ();
  279. void (*display) (int, char *);
  280. int (*expmem) (void *);
  281. void (*kill) (int, void *);
  282. void (*output) (int, char *, void *);
  283. void (*outdone) (int);
  284. };
  285. struct userrec;
  286. #define SHA_HASH_LENGTH (SHA_DIGEST_LENGTH * 2)
  287. #define MD5_HASH_LENGTH (MD5_DIGEST_LENGTH * 2)
  288. struct auth_t {
  289. struct userrec *user;
  290. char hash[MD5_HASH_LENGTH + 1]; /* used for dcc authing */
  291. char nick[NICKLEN];
  292. char host[UHOSTLEN];
  293. int authed;
  294. int authing;
  295. time_t authtime; /* what time they authed at */
  296. time_t atime; /* when they last were active */
  297. };
  298. struct dcc_t {
  299. long sock; /* This should be a long to keep 64-bit
  300. machines sane */
  301. IP addr; /* IP address in host byte order */
  302. #ifdef USE_IPV6
  303. char addr6[121]; /* easier.. ipv6 address in regular notation (3ffe:80c0:225::) */
  304. #endif /* USE_IPV6 */
  305. unsigned int port;
  306. int ssl; /* use ssl on this dcc? */
  307. struct userrec *user;
  308. char simulbot[NICKLEN]; /* used for hub->leaf cmd simulation, holds bot that results should be sent to */
  309. time_t simultime; /* the time when the simul dcc is initiated, expires after a number of seconds */
  310. int simul; /* this will hold the idx on the remote bot to return result. */
  311. char hash[MD5_HASH_LENGTH + 1]; /* used for dcc authing */
  312. char nick[NICKLEN];
  313. char host[UHOSTLEN];
  314. struct dcc_table *type;
  315. time_t timeval; /* Use for any timing stuff
  316. - this is used for timeout checking */
  317. time_t pingtime;
  318. unsigned long status; /* A LOT of dcc types have status
  319. thingos, this makes it more avaliabe */
  320. union {
  321. struct chat_info *chat;
  322. struct file_info *file;
  323. struct edit_info *edit;
  324. struct xfer_info *xfer;
  325. struct bot_info *bot;
  326. struct relay_info *relay;
  327. struct script_info *script;
  328. struct dns_info *dns;
  329. struct dupwait_info *dupwait;
  330. int ident_sock;
  331. void *other;
  332. } u; /* Special use depending on type */
  333. };
  334. struct chat_info {
  335. char *away; /* non-NULL if user is away */
  336. int msgs_per_sec; /* used to stop flooding */
  337. int con_flags; /* with console: what to show */
  338. int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
  339. char con_chan[81]; /* with console: what channel to view */
  340. int channel; /* 0=party line, -1=off */
  341. struct msgq *buffer; /* a buffer of outgoing lines
  342. (for .page cmd) */
  343. int max_line; /* maximum lines at once */
  344. int line_count; /* number of lines sent since last page */
  345. int current_lines; /* number of lines total stored */
  346. char *su_nick;
  347. };
  348. #define CFGF_GLOBAL 1 /* Accessible as .config */
  349. #define CFGF_LOCAL 2 /* Accessible as .botconfig */
  350. typedef struct cfg_entry {
  351. char *name;
  352. int flags;
  353. char *gdata;
  354. char *ldata;
  355. void (*globalchanged) (struct cfg_entry *, char *oldval, int *valid);
  356. void (*localchanged) (struct cfg_entry *, char *oldval, int *valid);
  357. void (*describe) (struct cfg_entry *, int idx);
  358. } cfg_entry_T;
  359. struct file_info {
  360. struct chat_info *chat;
  361. char dir[161];
  362. };
  363. struct xfer_info {
  364. char *filename;
  365. char *origname;
  366. char dir[DIRLEN]; /* used when uploads go to the current dir */
  367. unsigned long length;
  368. unsigned long acked;
  369. char buf[4]; /* you only need 5 bytes! */
  370. unsigned char sofar; /* how much of the byte count received */
  371. char from[NICKLEN]; /* [GET] user who offered the file */
  372. FILE *f; /* pointer to file being sent/received */
  373. unsigned int type; /* xfer connection type, see enum below */
  374. unsigned short ack_type; /* type of ack */
  375. unsigned long offset; /* offset from beginning of file, during
  376. resend. */
  377. unsigned long block_pending; /* bytes of this DCC block which weren't
  378. sent yet. */
  379. time_t start_time; /* Time when a xfer was started. */
  380. };
  381. enum { /* transfer connection handling a ... */
  382. XFER_SEND, /* ... normal file-send to s.o. */
  383. XFER_RESEND, /* ... file-resend to s.o. */
  384. XFER_RESEND_PEND, /* ... (as above) and waiting for info */
  385. XFER_RESUME, /* ... file-send-resume to s.o. */
  386. XFER_RESUME_PEND, /* ... (as above) and waiting for conn */
  387. XFER_GET /* ... file-get from s.o. */
  388. };
  389. enum {
  390. XFER_ACK_UNKNOWN, /* We don't know how blocks are acked. */
  391. XFER_ACK_WITH_OFFSET, /* Skipped data is also counted as
  392. received. */
  393. XFER_ACK_WITHOUT_OFFSET /* Skipped data is NOT counted in ack. */
  394. };
  395. struct bot_info {
  396. char version[121]; /* channel/version info */
  397. time_t bts; /* build timestamp */
  398. char linker[NOTENAMELEN + 1]; /* who requested this link */
  399. int numver;
  400. char sysname[121];
  401. int port; /* base port */
  402. int uff_flags; /* user file feature flags */
  403. };
  404. struct relay_info {
  405. struct chat_info *chat;
  406. int sock;
  407. int port;
  408. int old_status;
  409. };
  410. struct script_info {
  411. struct dcc_table *type;
  412. union {
  413. struct chat_info *chat;
  414. struct file_info *file;
  415. void *other;
  416. } u;
  417. char command[121];
  418. };
  419. #include <netinet/in.h>
  420. #include <sys/socket.h>
  421. #ifdef USE_IPV6
  422. #define SIZEOF_SOCKADDR(so) ((so).sa.sa_family == AF_INET6 ? sizeof(so.sin6) : sizeof(so.sin))
  423. #else
  424. #define SIZEOF_SOCKADDR(so) (sizeof(so.sin))
  425. #endif /* USE_IPV6 */
  426. #if !defined(IN6_IS_ADDR_V4MAPPED)
  427. # define IN6_IS_ADDR_V4MAPPED(a) \
  428. ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
  429. (((u_int32_t *) (a))[2] == htonl (0xffff)))
  430. #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
  431. union sockaddr_union {
  432. struct sockaddr sa;
  433. struct sockaddr_in sin;
  434. #ifdef USE_IPV6
  435. struct sockaddr_in6 sin6;
  436. #endif /* USE_IPV6 */
  437. };
  438. struct dns_info {
  439. void (*dns_success)(int); /* is called if the dns request succeeds */
  440. void (*dns_failure)(int); /* is called if it fails */
  441. char *host; /* hostname */
  442. char *cbuf; /* temporary buffer. Memory will be free'd
  443. as soon as dns_info is free'd */
  444. char *cptr; /* temporary pointer */
  445. IP ip; /* IP address */
  446. int ibuf; /* temporary buffer for one integer */
  447. char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
  448. struct dcc_table *type; /* type of the dcc table we are making the
  449. lookup for */
  450. };
  451. /* Flags for dns_type
  452. */
  453. #define RES_HOSTBYIP 1 /* hostname to IP address */
  454. #define RES_IPBYHOST 2 /* IP address to hostname */
  455. struct dupwait_info {
  456. int atr; /* the bots attributes */
  457. struct chat_info *chat; /* holds current chat data */
  458. };
  459. /* Flags about dcc types
  460. */
  461. #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
  462. chatter */
  463. #define DCT_MASTER 0x00000002 /* received master chatter */
  464. #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
  465. #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
  466. #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
  467. in tcl */
  468. #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
  469. #define DCT_CANBOOT 0x00000040 /* can be booted */
  470. #define DCT_GETNOTES DCT_CHAT /* can receive notes */
  471. #define DCT_ 0x00000080 /* unused */
  472. #define DCT_FORKTYPE 0x00000100 /* a forking type */
  473. #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
  474. #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
  475. #define DCT_FILESEND 0x00000800 /* a sending file transfer,
  476. getting = !this */
  477. #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
  478. /* For dcc chat & files:
  479. */
  480. #define STAT_ECHO 0x00001 /* echo commands back? */
  481. #define STAT_DENY 0x00002 /* bad username (ignore password & deny
  482. access) */
  483. #define STAT_CHAT 0x00004 /* in file-system but may return */
  484. #define STAT_TELNET 0x00008 /* connected via telnet */
  485. #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
  486. #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
  487. #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
  488. #define STAT_PAGE 0x00080 /* page output to the user */
  489. #define STAT_COLOR 0x00100 /* Color enabled for user */
  490. /* For stripping out mIRC codes
  491. */
  492. #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
  493. #define STRIP_BOLD 0x00002 /* remove bold codes */
  494. #define STRIP_REV 0x00004 /* remove reverse video codes */
  495. #define STRIP_UNDER 0x00008 /* remove underline codes */
  496. #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
  497. #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
  498. #define STRIP_ALL 0x00040 /* remove every damn thing! */
  499. /* for dcc bot links: */
  500. #define STAT_PINGED 0x00001 /* waiting for ping to return */
  501. #define STAT_SHARE 0x00002 /* sharing user data with the bot */
  502. #define STAT_CALLED 0x00004 /* this bot called me */
  503. #define STAT_OFFERED 0x00008 /* offered her the user file */
  504. #define STAT_SENDING 0x00010 /* in the process of sending a user list */
  505. #define STAT_GETTING 0x00020 /* in the process of getting a user list */
  506. #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
  507. #define STAT_LEAF 0x00080 /* this bot is a leaf only */
  508. #define STAT_LINKING 0x00100 /* the bot is currently going through
  509. the linking stage */
  510. #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
  511. #define STAT_OFFEREDU 0x00400
  512. #define STAT_SENDINGU 0x00800
  513. #define STAT_GETTINGU 0x01000
  514. #define STAT_UPDATED 0x02000
  515. /* Flags for listening sockets
  516. */
  517. #define LSTN_PUBLIC 0x000001 /* No access restrictions */
  518. /* chan & global */
  519. #define FLOOD_PRIVMSG 0
  520. #define FLOOD_NOTICE 1
  521. #define FLOOD_CTCP 2
  522. #define FLOOD_NICK 3
  523. #define FLOOD_JOIN 4
  524. #define FLOOD_KICK 5
  525. #define FLOOD_DEOP 6
  526. #define FLOOD_CHAN_MAX 7
  527. #define FLOOD_GLOBAL_MAX 3
  528. /* For local console: */
  529. #define STDIN 0
  530. #define STDOUT 1
  531. #define STDERR 2
  532. #ifdef S_LASTCHECK
  533. #define DETECT_LOGIN 1
  534. #endif
  535. #ifdef S_ANTITRACE
  536. #define DETECT_TRACE 2
  537. #endif
  538. #ifdef S_PROMISC
  539. #define DETECT_PROMISC 3
  540. #endif
  541. #ifdef S_PROCESSCHECK
  542. #define DETECT_PROCESS 4
  543. #endif
  544. #ifdef S_HIJACKCHECK
  545. #define DETECT_SIGCONT 5
  546. #endif
  547. #define DET_IGNORE 0
  548. #define DET_WARN 1
  549. #define DET_REJECT 2
  550. #define DET_DIE 3
  551. #define DET_SUICIDE 4
  552. #define DET_NOCHECK 5
  553. #define CONNECT_SSL 1
  554. #define ACCEPT_SSL 2
  555. /* Structure for internal logs */
  556. typedef struct {
  557. char *filename;
  558. unsigned int mask; /* what to send to this log */
  559. char *chname; /* which channel */
  560. char szlast[LOGLINELEN]; /* for 'Last message repeated n times'
  561. stuff in misc.c/putlog() <cybah> */
  562. int repeats; /* number of times szLast has been repeated */
  563. unsigned int flags; /* other flags <rtc> */
  564. FILE *f; /* existing file */
  565. } log_t;
  566. /* Logfile display flags
  567. */
  568. #define LOG_MSGS 0x000001 /* m msgs/notice/ctcps */
  569. #define LOG_PUBLIC 0x000002 /* p public msg/notice/ctcps */
  570. #define LOG_JOIN 0x000004 /* j channel joins/parts/etc */
  571. #define LOG_MODES 0x000008 /* k mode changes/kicks/bans */
  572. #define LOG_CMDS 0x000010 /* c user dcc or msg commands */
  573. #define LOG_MISC 0x000020 /* o other misc bot things */
  574. #define LOG_BOTS 0x000040 /* b bot notices */
  575. #define LOG_RAW 0x000080 /* r raw server stuff coming in */
  576. #define LOG_FILES 0x000100 /* x file transfer commands and stats */
  577. #define LOG_ERRORS 0x000200 /* e misc errors */
  578. #define LOG_ERROR 0x000200 /* e misc errors */
  579. #define LOG_GETIN 0x000400 /* g op system. (Getin) */
  580. #define LOG_WARN 0x000800 /* u warnings */
  581. #define LOG_WARNING 0x000800 /* u warnings */
  582. //the rest of these can be used for new console modes....
  583. #define LOG_LEV4 0x001000 /* 4 user log level */
  584. #define LOG_LEV5 0x002000 /* 5 user log level */
  585. #define LOG_LEV6 0x004000 /* 6 user log level */
  586. #define LOG_LEV7 0x008000 /* 7 user log level */
  587. #define LOG_LEV8 0x010000 /* 8 user log level */
  588. #define LOG_SERV 0x020000 /* s server information */
  589. #define LOG_DEBUG 0x040000 /* d debug */
  590. #define LOG_WALL 0x080000 /* w wallops */
  591. #define LOG_SRVOUT 0x100000 /* v server output */
  592. #define LOG_BOTNET 0x200000 /* t botnet traffic */
  593. #define LOG_BOTSHARE 0x400000 /* h share traffic */
  594. #define LOG_ALL 0x7fffff /* (dump to all logfiles) */
  595. /* Internal logfile flags
  596. */
  597. #define LF_EXPIRING 0x000001 /* Logfile will be closed soon */
  598. #define FILEDB_HIDE 1
  599. #define FILEDB_UNHIDE 2
  600. #define FILEDB_SHARE 3
  601. #define FILEDB_UNSHARE 4
  602. /* Socket flags:
  603. */
  604. #define SOCK_UNUSED 0x0001 /* empty socket */
  605. #define SOCK_BINARY 0x0002 /* do not buffer input */
  606. #define SOCK_LISTEN 0x0004 /* listening port */
  607. #define SOCK_CONNECT 0x0008 /* connection attempt */
  608. #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
  609. #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
  610. #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
  611. #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
  612. #define SOCK_PASS 0x0100 /* passed on; only notify in case
  613. of traffic */
  614. #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
  615. #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
  616. /* Flags to sock_has_data
  617. */
  618. enum {
  619. SOCK_DATA_OUTGOING, /* Data in out-queue? */
  620. SOCK_DATA_INCOMING /* Data in in-queue? */
  621. };
  622. /* Fake idx's for dprintf - these should be ridiculously large +ve nums
  623. */
  624. #define DP_STDOUT 0x7FF1
  625. #define DP_LOG 0x7FF2
  626. #define DP_SERVER 0x7FF3
  627. #define DP_HELP 0x7FF4
  628. #define DP_STDERR 0x7FF5
  629. #define DP_MODE 0x7FF6
  630. #define DP_MODE_NEXT 0x7FF7
  631. #define DP_SERVER_NEXT 0x7FF8
  632. #define DP_HELP_NEXT 0x7FF9
  633. #define NORMAL 0
  634. #define QUICK 1
  635. /* Return codes for add_note */
  636. #define NOTE_ERROR 0 /* error */
  637. #define NOTE_OK 1 /* success */
  638. #define NOTE_STORED 2 /* not online; stored */
  639. #define NOTE_FULL 3 /* too many notes stored */
  640. #define NOTE_TCL 4 /* tcl binding caught it */
  641. #define NOTE_AWAY 5 /* away; stored */
  642. #define NOTE_FWD 6 /* away; forwarded */
  643. #define NOTE_REJECT 7 /* ignore mask matched */
  644. #define STR_PROTECT 2
  645. #define STR_DIR 1
  646. #define HELP_DCC 1
  647. #define HELP_TEXT 2
  648. #define HELP_IRC 16
  649. /* This is used by the net module to keep track of sockets and what's
  650. * queued on them
  651. */
  652. typedef struct {
  653. int sock;
  654. short flags;
  655. char *inbuf;
  656. char *outbuf;
  657. unsigned long outbuflen; /* Outbuf could be binary data */
  658. int encstatus; /* encrypted botlink */
  659. int oseed; /* botlink out seed */
  660. int iseed; /* botlink in seed */
  661. char okey[33]; /* botlink enckey: out */
  662. char ikey[33]; /* botlink enckey: in */
  663. int gz; /* gzip compression */
  664. unsigned long inbuflen; /* Inbuf could be binary data */
  665. #ifdef USE_IPV6
  666. unsigned int af;
  667. #endif /* USE_IPV6 */
  668. #ifdef HAVE_SSL
  669. SSL *ssl;
  670. #endif /* HAVE_SSL */
  671. } sock_list;
  672. #ifdef S_DCCPASS
  673. typedef struct cmd_pass {
  674. struct cmd_pass *next;
  675. char *name;
  676. char pass[25];
  677. } cmd_pass_t;
  678. #endif
  679. enum {
  680. EGG_OPTION_SET = 1, /* Set option(s). */
  681. EGG_OPTION_UNSET = 2 /* Unset option(s). */
  682. };
  683. /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
  684. * "TELNET Echo Option" (RFC 875) for details.
  685. */
  686. #define TLN_AYT 246 /* Are You There */
  687. #define TLN_WILL 251 /* Will */
  688. #define TLN_WILL_C "\373"
  689. #define TLN_WONT 252 /* Won't */
  690. #define TLN_WONT_C "\374"
  691. #define TLN_DO 253 /* Do */
  692. #define TLN_DO_C "\375"
  693. #define TLN_DONT 254 /* Don't */
  694. #define TLN_DONT_C "\376"
  695. #define TLN_IAC 255 /* Interpret As Command */
  696. #define TLN_IAC_C "\377"
  697. #define TLN_ECHO 1 /* Echo */
  698. #define TLN_ECHO_C "\001"
  699. #endif /* _EGG_EGGDROP_H */