dcc.h 9.6 KB

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