transports.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2012, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file transports.h
  7. * \brief Headers for transports.c
  8. **/
  9. #ifndef TOR_TRANSPORTS_H
  10. #define TOR_TRANSPORTS_H
  11. /** Represents a pluggable transport used by a bridge. */
  12. typedef struct {
  13. /** SOCKS version: One of PROXY_SOCKS4, PROXY_SOCKS5. */
  14. int socks_version;
  15. /** Name of pluggable transport protocol */
  16. char *name;
  17. /** Address of proxy */
  18. tor_addr_t addr;
  19. /** Port of proxy */
  20. uint16_t port;
  21. /** Boolean: We are re-parsing our transport list, and we are going to remove
  22. * this one if we don't find it in the list of configured transports. */
  23. unsigned marked_for_removal : 1;
  24. } transport_t;
  25. void mark_transport_list(void);
  26. void sweep_transport_list(void);
  27. void clear_transport_list(void);
  28. int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
  29. const char *name, int socks_ver);
  30. int transport_add(transport_t *t);
  31. void transport_free(transport_t *transport);
  32. transport_t *transport_new(const tor_addr_t *addr, uint16_t port,
  33. const char *name, int socks_ver);
  34. transport_t *transport_get_by_name(const char *name);
  35. void pt_kickstart_proxy(const smartlist_t *transport_list, char **proxy_argv,
  36. int is_server);
  37. #define pt_kickstart_client_proxy(tl, pa) \
  38. pt_kickstart_proxy(tl, pa, 0)
  39. #define pt_kickstart_server_proxy(tl, pa) \
  40. pt_kickstart_proxy(tl, pa, 1)
  41. void pt_configure_remaining_proxies(void);
  42. int pt_proxies_configuration_pending(void);
  43. void pt_free_all(void);
  44. void pt_prepare_proxy_list_for_config_read(void);
  45. void sweep_proxy_list(void);
  46. #ifdef PT_PRIVATE
  47. /** State of the managed proxy configuration protocol. */
  48. enum pt_proto_state {
  49. PT_PROTO_INFANT, /* was just born */
  50. PT_PROTO_LAUNCHED, /* was just launched */
  51. PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
  52. PT_PROTO_CONFIGURED, /* configured successfully */
  53. PT_PROTO_COMPLETED, /* configure and registered its transports */
  54. PT_PROTO_BROKEN, /* broke during the protocol */
  55. PT_PROTO_FAILED_LAUNCH /* failed while launching */
  56. };
  57. /** Structure containing information of a managed proxy. */
  58. typedef struct {
  59. enum pt_proto_state conf_state; /* the current configuration state */
  60. char **argv; /* the cli arguments of this proxy */
  61. int conf_protocol; /* the configuration protocol version used */
  62. int is_server; /* is it a server proxy? */
  63. /* A pointer to the process handle of this managed proxy. */
  64. process_handle_t *process_handle;
  65. int pid; /* The Process ID this managed proxy is using. */
  66. /** Boolean: We are re-parsing our config, and we are going to
  67. * remove this managed proxy if we don't find it any transport
  68. * plugins that use it. */
  69. unsigned int marked_for_removal : 1;
  70. /** Boolean: We got a SIGHUP while this proxy was running. We use
  71. * this flag to signify that this proxy might need to be restarted
  72. * so that it can listen for other transports according to the new
  73. * torrc. */
  74. unsigned int got_hup : 1;
  75. /* transports to-be-launched by this proxy */
  76. smartlist_t *transports_to_launch;
  77. /* The 'transports' list contains all the transports this proxy has
  78. launched. */
  79. smartlist_t *transports;
  80. } managed_proxy_t;
  81. int parse_cmethod_line(const char *line, managed_proxy_t *mp);
  82. int parse_smethod_line(const char *line, managed_proxy_t *mp);
  83. int parse_version(const char *line, managed_proxy_t *mp);
  84. void parse_env_error(const char *line);
  85. void handle_proxy_line(const char *line, managed_proxy_t *mp);
  86. #endif
  87. #endif