relay.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 [name of library's license],
  21. * the licensors of this Program grant you additional permission to convey
  22. * the resulting work. {Corresponding Source for a non-source form of such
  23. * a combination shall include the source code for the parts of the OpenSSL
  24. * library used as well as that of the covered work.}
  25. */
  26. #ifndef _RELAY_H_
  27. #define _RELAY_H_
  28. #include "flow.h"
  29. #include <stdint.h>
  30. struct proxy_thread_data {
  31. uint8_t *initial_data;
  32. uint16_t initial_len;
  33. uint16_t stream_id;
  34. int32_t pipefd;
  35. stream_table *streams;
  36. data_queue *downstream_queue;
  37. client *client;
  38. };
  39. typedef struct client_st {
  40. uint8_t slitheen_id[SLITHEEN_ID_LEN];
  41. stream_table *streams;
  42. data_queue *downstream_queue;
  43. sem_t queue_lock;
  44. uint16_t encryption_counter;
  45. struct client_st *next;
  46. uint8_t *header_key;
  47. uint8_t *body_key;
  48. //uint8_t *mac_key
  49. //EVP_CIPHER_CTX *header_ctx;
  50. //EVP_CIPHER_CTX *body_ctx;
  51. EVP_MD_CTX *mac_ctx;
  52. } client;
  53. typedef struct client_table_st {
  54. client *first;
  55. } client_table;
  56. extern client_table *clients;
  57. struct socks_req {
  58. uint8_t version;
  59. uint8_t cmd;
  60. uint8_t rsvd;
  61. uint8_t addr_type;
  62. };
  63. struct __attribute__((__packed__)) sl_up_hdr {
  64. uint16_t stream_id;
  65. uint16_t len;
  66. };
  67. int replace_packet(flow *f, struct packet_info *info);
  68. int process_downstream(flow *f, int32_t offset, struct packet_info *info);
  69. int read_header(flow *f, struct packet_info *info);
  70. uint32_t get_response_length(uint8_t *response);
  71. int fill_with_downstream(flow *f, uint8_t *data, int32_t length);
  72. uint16_t tcp_checksum(struct packet_info *info);
  73. void *proxy_covert_site(void *data);
  74. #define BEGIN_HEADER 0x10
  75. #define PARSE_HEADER 0x20
  76. #define MID_CONTENT 0x30
  77. #define BEGIN_CHUNK 0x40
  78. #define MID_CHUNK 0x50
  79. #define END_CHUNK 0x60
  80. #define END_BODY 0x70
  81. #define FORFEIT_REST 0x80
  82. #define USE_REST 0x90
  83. #endif /* _RELAY_H_ */