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.

90 lines
2.0 KiB

10 years ago
10 years ago
10 years ago
12 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
12 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
  1. /*
  2. * server.h - Define shadowsocks server'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 _SERVER_H
  23. #define _SERVER_H
  24. #include <ev.h>
  25. #include <time.h>
  26. #include <libcork/ds.h>
  27. #include "encrypt.h"
  28. #include "jconf.h"
  29. #include "resolv.h"
  30. #include "common.h"
  31. struct listen_ctx {
  32. ev_io io;
  33. int fd;
  34. int timeout;
  35. int method;
  36. char *iface;
  37. struct ev_loop *loop;
  38. };
  39. struct server_ctx {
  40. ev_io io;
  41. ev_timer watcher;
  42. int connected;
  43. struct server *server;
  44. };
  45. struct server {
  46. int fd;
  47. int stage;
  48. ssize_t buf_len;
  49. ssize_t buf_idx;
  50. char *buf; // server send from, remote recv into
  51. int auth;
  52. struct chunk *chunk;
  53. struct enc_ctx *e_ctx;
  54. struct enc_ctx *d_ctx;
  55. struct server_ctx *recv_ctx;
  56. struct server_ctx *send_ctx;
  57. struct listen_ctx *listen_ctx;
  58. struct remote *remote;
  59. struct ResolvQuery *query;
  60. struct cork_dllist_item entries;
  61. };
  62. struct remote_ctx {
  63. ev_io io;
  64. int connected;
  65. struct remote *remote;
  66. };
  67. struct remote {
  68. int fd;
  69. ssize_t buf_len;
  70. ssize_t buf_idx;
  71. char *buf; // remote send from, server recv into
  72. struct remote_ctx *recv_ctx;
  73. struct remote_ctx *send_ctx;
  74. struct server *server;
  75. };
  76. #endif // _SERVER_H