relay.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Slitheen - a decoy routing system for censorship resistance
  2. * Copyright (C) 2017 Cecylia Bocovich (cbocovic@uwaterloo.ca)
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 3.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. * Additional permission under GNU GPL version 3 section 7
  17. *
  18. * If you modify this Program, or any covered work, by linking or combining
  19. * it with the OpenSSL library (or a modified version of that library),
  20. * containing parts covered by the terms of the OpenSSL Licence and the
  21. * SSLeay license, the licensors of this Program grant you additional
  22. * permission to convey the resulting work. Corresponding Source for a
  23. * non-source form of such a combination shall include the source code
  24. * for the parts of the OpenSSL library used as well as that of the covered
  25. * work.
  26. */
  27. #ifndef RELAY_H
  28. #define RELAY_H
  29. #include "flow.h"
  30. #include <stdint.h>
  31. struct proxy_thread_data {
  32. uint8_t *initial_data;
  33. uint16_t initial_len;
  34. uint16_t stream_id;
  35. int32_t pipefd;
  36. stream_table *streams;
  37. data_queue *downstream_queue;
  38. client *client;
  39. };
  40. typedef struct client_st {
  41. uint8_t slitheen_id[SLITHEEN_ID_LEN];
  42. stream_table *streams;
  43. data_queue *downstream_queue;
  44. sem_t queue_lock;
  45. uint16_t encryption_counter;
  46. struct client_st *next;
  47. uint8_t *header_key;
  48. uint8_t *body_key;
  49. //uint8_t *mac_key
  50. //EVP_CIPHER_CTX *header_ctx;
  51. //EVP_CIPHER_CTX *body_ctx;
  52. EVP_MD_CTX *mac_ctx;
  53. } client;
  54. typedef struct client_table_st {
  55. client *first;
  56. } client_table;
  57. extern client_table *clients;
  58. struct socks_req {
  59. uint8_t version;
  60. uint8_t cmd;
  61. uint8_t rsvd;
  62. uint8_t addr_type;
  63. };
  64. struct __attribute__((__packed__)) sl_up_hdr {
  65. uint16_t stream_id;
  66. uint16_t len;
  67. };
  68. int replace_packet(flow *f, struct packet_info *info);
  69. int process_downstream(flow *f, int32_t offset, struct packet_info *info);
  70. int read_header(flow *f, struct packet_info *info);
  71. uint32_t get_response_length(uint8_t *response);
  72. int fill_with_downstream(flow *f, uint8_t *data, int32_t length);
  73. uint16_t tcp_checksum(struct packet_info *info);
  74. void *proxy_covert_site(void *data);
  75. #define BEGIN_HEADER 0x10
  76. #define PARSE_HEADER 0x20
  77. #define MID_CONTENT 0x30
  78. #define BEGIN_CHUNK 0x40
  79. #define MID_CHUNK 0x50
  80. #define END_CHUNK 0x60
  81. #define END_BODY 0x70
  82. #define FORFEIT_REST 0x80
  83. #define USE_REST 0x90
  84. #endif /* RELAY_H */