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.

85 lines
2.5 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. /*
  2. * shadowsocks.h - Header files of library interfaces
  3. *
  4. * Copyright (C) 2013 - 2015, Max Lv <max.c.lv@gmail.com>
  5. *
  6. * This file is part of the shadowsocks-libev.
  7. * shadowsocks-libev is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * shadowsocks-libev is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with shadowsocks-libev; see the file COPYING. If not, see
  19. * <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef _SHADOWSOCKS_H
  22. #define _SHADOWSOCKS_H
  23. typedef struct {
  24. /* Required */
  25. char *remote_host; // hostname or ip of remote server
  26. char *local_addr; // local ip to bind
  27. char *method; // encryption method
  28. char *password; // password of remote server
  29. int remote_port; // port number of remote server
  30. int local_port; // port number of local server
  31. int timeout; // connection timeout
  32. /* Optional, set NULL if not valid */
  33. char *acl; // file path to acl
  34. char *log; // file path to log
  35. int fast_open; // enable tcp fast open
  36. int mode; // enable udp relay
  37. int verbose; // verbose mode
  38. } profile_t;
  39. /* An example profile
  40. const profile_t EXAMPLE_PROFILE = {
  41. .remote_host = "example.com",
  42. .local_addr = "127.0.0.1",
  43. .method = "bf-cfb",
  44. .password = "barfoo!",
  45. .remote_port = 8338,
  46. .local_port = 1080,
  47. .timeout = 600;
  48. .acl = NULL,
  49. .log = NULL,
  50. .fast_open = 0,
  51. .mode = 0,
  52. .verbose = 0
  53. };
  54. */
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. /*
  59. * Create and start a shadowsocks local server.
  60. *
  61. * Calling this function will block the current thread forever if the server
  62. * starts successfully.
  63. *
  64. * Make sure start the server in a seperate process to avoid any potential
  65. * memory and socket leak.
  66. *
  67. * If failed, -1 is returned. Errors will output to the log file.
  68. */
  69. int start_ss_local_server(profile_t profile);
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. // To stop the service on posix system, just kill the daemon process
  74. // kill(pid, SIGKILL);
  75. #endif // _SHADOWSOCKS_H