relay.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. uint16_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. uint16_t encryption_counter;
  18. struct client_st *next;
  19. } client;
  20. typedef struct client_table_st {
  21. client *first;
  22. } client_table;
  23. extern client_table *clients;
  24. struct socks_req {
  25. uint8_t version;
  26. uint8_t cmd;
  27. uint8_t rsvd;
  28. uint8_t addr_type;
  29. };
  30. struct __attribute__((__packed__)) sl_up_hdr {
  31. uint16_t stream_id;
  32. uint16_t len;
  33. };
  34. int replace_packet(flow *f, struct packet_info *info);
  35. int process_downstream(flow *f, int32_t offset, struct packet_info *info);
  36. int read_header(flow *f, struct packet_info *info);
  37. uint32_t get_response_length(uint8_t *response);
  38. int fill_with_downstream(flow *f, uint8_t *data, int32_t length);
  39. uint16_t tcp_checksum(struct packet_info *info);
  40. void *proxy_covert_site(void *data);
  41. #define BEGIN_HEADER 0x10
  42. #define PARSE_HEADER 0x20
  43. #define MID_CONTENT 0x30
  44. #define BEGIN_CHUNK 0x40
  45. #define MID_CHUNK 0x50
  46. #define END_CHUNK 0x60
  47. #define END_BODY 0x70
  48. #define FORFEIT_REST 0x80
  49. #define USE_REST 0x90
  50. #endif /* _RELAY_H_ */