relay.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _RELAY_H_
  2. #define _RELAY_H_
  3. #include "flow.h"
  4. #include <stdint.h>
  5. struct proxy_thread_data {
  6. uint8_t *initial_data;
  7. uint16_t initial_len;
  8. uint8_t stream_id;
  9. int32_t pipefd;
  10. stream_table *streams;
  11. data_queue *downstream_queue;
  12. };
  13. typedef struct client_st {
  14. uint8_t slitheen_id[SLITHEEN_ID_LEN];
  15. stream_table *streams;
  16. data_queue *downstream_queue;
  17. struct client_st *next;
  18. } client;
  19. typedef struct client_table_st {
  20. client *first;
  21. } client_table;
  22. extern client_table *clients;
  23. struct socks_req {
  24. uint8_t version;
  25. uint8_t cmd;
  26. uint8_t rsvd;
  27. uint8_t addr_type;
  28. };
  29. struct __attribute__((__packed__)) sl_up_hdr {
  30. uint8_t stream_id;
  31. uint16_t len;
  32. };
  33. int replace_packet(flow *f, struct packet_info *info);
  34. int process_downstream(flow *f, int32_t offset, struct packet_info *info);
  35. int read_header(flow *f, struct packet_info *info);
  36. uint32_t get_response_length(uint8_t *response);
  37. int fill_with_downstream(flow *f, uint8_t *data, int32_t length);
  38. uint16_t tcp_checksum(struct packet_info *info);
  39. void *proxy_covert_site(void *data);
  40. #define BEGIN_HEADER 0x10
  41. #define PARSE_HEADER 0x20
  42. #define MID_CONTENT 0x30
  43. #define BEGIN_CHUNK 0x40
  44. #define MID_CHUNK 0x50
  45. #define END_CHUNK 0x60
  46. #define END_BODY 0x70
  47. #define FORFEIT_REST 0x80
  48. #define USE_REST 0x90
  49. #endif /* _RELAY_H_ */