dcc.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #ifndef _DCC_H
  2. #define _DCC_H
  3. #ifdef HAVE_CONFIG_H
  4. # include "config.h"
  5. #endif
  6. #include "types.h"
  7. #include "enclink.h"
  8. #include "crypt.h"
  9. #include "eggdrop.h"
  10. #include "src/mod/server.mod/server.h"
  11. /* Public structure of all the dcc connections */
  12. struct dcc_table {
  13. char *name;
  14. int flags;
  15. void (*eof) (int);
  16. void (*activity) (int, char *, int);
  17. interval_t *timeout_val;
  18. void (*timeout) (int);
  19. void (*display) (int, char *, size_t);
  20. void (*kill) (int, void *);
  21. void (*output) (int, char *, void *);
  22. void (*outdone) (int);
  23. };
  24. struct dcc_t {
  25. struct dcc_table *type;
  26. struct userrec *user;
  27. union {
  28. struct chat_info *chat;
  29. struct dns_info *dns;
  30. struct edit_info *edit;
  31. struct xfer_info *xfer;
  32. struct bot_info *bot;
  33. struct relay_info *relay;
  34. struct dupwait_info *dupwait;
  35. struct enc_link_dcc *enc;
  36. void *other;
  37. } u; /* Special use depending on type */
  38. union {
  39. int ident_sock;
  40. } uint;
  41. in_addr_t addr; /* IP address in host byte order */
  42. time_t simultime; /* the time when the simul dcc is initiated, expires after a number of seconds */
  43. time_t timeval; /* Use for any timing stuff
  44. - this is used for timeout checking */
  45. time_t pingtime;
  46. unsigned long status; /* A LOT of dcc types have status
  47. thingos, this makes it more avaliabe */
  48. int sock;
  49. int encrypt; /* 1 = should encrypt, 2 = encrypted */
  50. int simul; /* this will hold the idx on the remote bot to return result. */
  51. bool irc; /* forward the output back to irc? */
  52. bool hub; // is this bot a hub?
  53. bool wrong_pass; // auth obscure hack
  54. bool bot;
  55. // int auth;
  56. bool whowas;
  57. int dns_id;
  58. port_t port;
  59. char simulbot[HANDLEN + 1]; /* used for hub->leaf cmd simulation, holds bot that results should be sent to */
  60. char hash[MD5_HASH_LENGTH + 1]; /* used for dcc authing */
  61. char shahash[SHA_HASH_LENGTH + 1];
  62. char nick[NICKLEN];
  63. char whois[UHOSTLEN];
  64. char host[UHOSTLEN];
  65. #ifdef USE_IPV6
  66. char host6[121]; /* easier.. ipv6 address in regular notation (3ffe:80c0:225::) */
  67. #endif /* USE_IPV6 */
  68. };
  69. struct dns_info {
  70. char *cbuf; /* free`d when done */
  71. char *cptr;
  72. int ibuf;
  73. int ibuf2;
  74. // struct dcc_table *type; /* type we are doing the lookup for */
  75. };
  76. struct chat_info {
  77. struct msgq *buffer; /* a buffer of outgoing lines
  78. (for .page cmd) */
  79. int max_line; /* maximum lines at once */
  80. int line_count; /* number of lines sent since last page */
  81. int current_lines; /* number of lines total stored */
  82. int msgs_per_sec; /* used to stop flooding */
  83. int con_flags; /* with console: what to show */
  84. int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
  85. int channel; /* 0=party line, -1=off */
  86. int su_channel;
  87. char *away; /* non-NULL if user is away */
  88. char *su_nick;
  89. char con_chan[81]; /* with console: what channel to view */
  90. };
  91. struct xfer_info {
  92. FILE *f; /* pointer to file being sent/received */
  93. unsigned long int length;
  94. unsigned long int acked;
  95. unsigned long int offset; /* offset from beginning of file, during
  96. resend. */
  97. unsigned long block_pending; /* bytes of this DCC block which weren't sent yet. */
  98. unsigned int type; /* xfer connection type, see enum below */
  99. time_t start_time; /* Time when a xfer was started. */
  100. char *filename;
  101. char *origname;
  102. unsigned char sofar; /* how much of the byte count received */
  103. unsigned short ack_type; /* type of ack */
  104. char from[NICKLEN]; /* [GET] user who offered the file */
  105. char buf[4]; /* you only need 5 bytes! */
  106. };
  107. struct bot_info {
  108. int numver;
  109. int uff_flags; /* user file feature flags */
  110. port_t port; /* base port */
  111. char linker[NOTENAMELEN + 1]; /* who requested this link */
  112. char sysname[121];
  113. char version[121]; /* channel/version info */
  114. };
  115. struct relay_info {
  116. struct chat_info *chat;
  117. int sock;
  118. int old_status;
  119. int idx;
  120. #ifdef USE_IPV6
  121. int af;
  122. #endif /* USE_IPV6 */
  123. port_t port;
  124. };
  125. struct dupwait_info {
  126. int atr; /* the bots attributes */
  127. };
  128. /* Flags about dcc types
  129. */
  130. #define DCT_CHAT BIT0 /* this dcc type receives botnet
  131. chatter */
  132. #define DCT_MASTER BIT1 /* received master chatter */
  133. #define DCT_SHOWWHO BIT2 /* show the user in .who */
  134. #define DCT_REMOTEWHO BIT3 /* show in remote who */
  135. #define DCT_VALIDIDX BIT4 /* valid idx for outputting to
  136. in tcl */
  137. #define DCT_SIMUL BIT5 /* can be tcl_simul'd */
  138. #define DCT_CANBOOT BIT6 /* can be booted */
  139. #define DCT_ BIT7 /* unused */
  140. #define DCT_FORKTYPE BIT8 /* a forking type */
  141. #define DCT_BOT BIT9 /* a bot connection of some sort... */
  142. #define DCT_FILETRAN BIT10 /* a file transfer of some sort */
  143. #define DCT_FILESEND BIT11 /* a sending file transfer,
  144. getting = !this */
  145. #define DCT_LISTEN BIT12 /* a listening port of some sort */
  146. /* For dcc chat & files:
  147. */
  148. #define STAT_ECHO BIT0 /* echo commands back? */
  149. #define STAT_DENY BIT1 /* bad username (ignore password & deny
  150. access) */
  151. #define STAT_CHAT BIT2 /* in file-system but may return */
  152. #define STAT_TELNET BIT3 /* connected via telnet */
  153. #define STAT_PARTY BIT4 /* only on party line via 'p' flag */
  154. /* skip 2 */
  155. #define STAT_PAGE BIT7 /* page output to the user */
  156. #define STAT_COLOR BIT8 /* Color enabled for user */
  157. #define STAT_BANNER BIT9 /* show banner on login? */
  158. #define STAT_CHANNELS BIT10 /* show channels on login? */
  159. #define STAT_BOTS BIT11 /* Show bots linked on login? */
  160. #define STAT_WHOM BIT12 /* show .whom on login? */
  161. #define STAT_UNIXDOMAIN BIT13 /* This dcc is over a unix domain */
  162. /* For stripping out mIRC codes
  163. */
  164. #define STRIP_COLOR BIT0 /* remove mIRC color codes */
  165. #define STRIP_BOLD BIT1 /* remove bold codes */
  166. #define STRIP_REV BIT2 /* remove reverse video codes */
  167. #define STRIP_UNDER BIT3 /* remove underline codes */
  168. #define STRIP_ANSI BIT4 /* remove ALL ansi codes */
  169. #define STRIP_BELLS BIT5 /* remote ctrl-g's */
  170. #define STRIP_ALL BIT6 /* remove every damn thing! */
  171. /* for dcc bot links: */
  172. #define STAT_PINGED BIT0 /* waiting for ping to return */
  173. #define STAT_SHARE BIT1 /* sharing user data with the bot */
  174. #define STAT_CALLED BIT2 /* this bot called me */
  175. #define STAT_OFFERED BIT3 /* offered her the user file */
  176. #define STAT_SENDING BIT4 /* in the process of sending a user list */
  177. #define STAT_GETTING BIT5 /* in the process of getting a user list */
  178. #define STAT_WARNED BIT6 /* warned him about unleaflike behavior */
  179. #define STAT_LEAF BIT7 /* this bot is a leaf only */
  180. #define STAT_LINKING BIT8 /* the bot is currently going through
  181. the linking stage */
  182. #define STAT_AGGRESSIVE BIT9 /* aggressively sharing with this bot */
  183. #define STAT_OFFEREDU BIT10
  184. #define STAT_SENDINGU BIT11
  185. #define STAT_GETTINGU BIT12
  186. #define STAT_UPDATED BIT13
  187. /* Flags for listening sockets
  188. */
  189. #define LSTN_PUBLIC BIT0 /* No access restrictions */
  190. /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
  191. * "TELNET Echo Option" (RFC 875) for details.
  192. */
  193. #define TLN_AYT 246 /* Are You There */
  194. #define TLN_WILL 251 /* Will */
  195. #define TLN_WILL_C "\373"
  196. #define TLN_WONT 252 /* Won't */
  197. #define TLN_WONT_C "\374"
  198. #define TLN_DO 253 /* Do */
  199. #define TLN_DO_C "\375"
  200. #define TLN_DONT 254 /* Don't */
  201. #define TLN_DONT_C "\376"
  202. #define TLN_IAC 255 /* Interpret As Command */
  203. #define TLN_IAC_C "\377"
  204. #define TLN_ECHO 1 /* Echo */
  205. #define TLN_ECHO_C "\001"
  206. extern struct dcc_t *dcc;
  207. extern int dcc_total, dccn, uplink_idx;
  208. extern time_t timesync;
  209. extern char network[];
  210. extern bool protect_telnet;
  211. extern struct cmd_pass *cmdpass;
  212. extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_BOT_NEW,
  213. DCC_RELAY, DCC_RELAYING, DCC_FORK_RELAY, DCC_PRE_RELAY, DCC_CHAT_PASS,
  214. DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
  215. DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_IDENTD, DCC_IDENTD_CONNECT, DCC_DNSWAIT;
  216. void send_timesync(int);
  217. void failed_link(int);
  218. void dupwait_notify(const char *);
  219. void send_sysinfo();
  220. int ansi_len(char *);
  221. #endif /* !_DCC_H */