eggdrop.h 22 KB

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