relay.h 1.5 KB

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