dcc.h 9.5 KB

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