relay.h 1.4 KB

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