You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.0 KiB

10 years ago
12 years ago
10 years ago
11 years ago
10 years ago
10 years ago
11 years ago
12 years ago
10 years ago
12 years ago
10 years ago
11 years ago
12 years ago
  1. /*
  2. * local.h - Define the clinet's buffers and callbacks
  3. *
  4. * Copyright (C) 2013 - 2015, Max Lv <max.c.lv@gmail.com>
  5. *
  6. * This file is part of the shadowsocks-libev.
  7. *
  8. * shadowsocks-libev is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * shadowsocks-libev is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with shadowsocks-libev; see the file COPYING. If not, see
  20. * <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef _LOCAL_H
  23. #define _LOCAL_H
  24. #include <ev.h>
  25. #include <libcork/ds.h>
  26. #include "encrypt.h"
  27. #include "jconf.h"
  28. #include "common.h"
  29. struct listen_ctx {
  30. ev_io io;
  31. char *iface;
  32. int remote_num;
  33. int method;
  34. int timeout;
  35. int fd;
  36. struct sockaddr **remote_addr;
  37. };
  38. struct server_ctx {
  39. ev_io io;
  40. int connected;
  41. struct server *server;
  42. };
  43. struct server {
  44. int fd;
  45. ssize_t buf_len;
  46. ssize_t buf_idx;
  47. char *buf; // server send from, remote recv into
  48. char stage;
  49. struct enc_ctx *e_ctx;
  50. struct enc_ctx *d_ctx;
  51. struct server_ctx *recv_ctx;
  52. struct server_ctx *send_ctx;
  53. struct listen_ctx *listener;
  54. struct remote *remote;
  55. struct cork_dllist_item entries;
  56. };
  57. struct remote_ctx {
  58. ev_io io;
  59. ev_timer watcher;
  60. int connected;
  61. struct remote *remote;
  62. };
  63. struct remote {
  64. int fd;
  65. ssize_t buf_len;
  66. ssize_t buf_idx;
  67. int direct;
  68. char *buf; // remote send from, server recv into
  69. struct remote_ctx *recv_ctx;
  70. struct remote_ctx *send_ctx;
  71. struct server *server;
  72. struct sockaddr_storage addr;
  73. int addr_len;
  74. };
  75. #endif // _LOCAL_H