or_connection_st.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef OR_CONNECTION_ST_H
  7. #define OR_CONNECTION_ST_H
  8. #include "or/connection_st.h"
  9. /** Subtype of connection_t for an "OR connection" -- that is, one that speaks
  10. * cells over TLS. */
  11. struct or_connection_t {
  12. connection_t base_;
  13. /** Hash of the public RSA key for the other side's identity key, or zeroes
  14. * if the other side hasn't shown us a valid identity key. */
  15. char identity_digest[DIGEST_LEN];
  16. /** Extended ORPort connection identifier. */
  17. char *ext_or_conn_id;
  18. /** This is the ClientHash value we expect to receive from the
  19. * client during the Extended ORPort authentication protocol. We
  20. * compute it upon receiving the ClientNoce from the client, and we
  21. * compare it with the acual ClientHash value sent by the
  22. * client. */
  23. char *ext_or_auth_correct_client_hash;
  24. /** String carrying the name of the pluggable transport
  25. * (e.g. "obfs2") that is obfuscating this connection. If no
  26. * pluggable transports are used, it's NULL. */
  27. char *ext_or_transport;
  28. char *nickname; /**< Nickname of OR on other side (if any). */
  29. tor_tls_t *tls; /**< TLS connection state. */
  30. int tls_error; /**< Last tor_tls error code. */
  31. /** When we last used this conn for any client traffic. If not
  32. * recent, we can rate limit it further. */
  33. /* Channel using this connection */
  34. channel_tls_t *chan;
  35. tor_addr_t real_addr; /**< The actual address that this connection came from
  36. * or went to. The <b>addr</b> field is prone to
  37. * getting overridden by the address from the router
  38. * descriptor matching <b>identity_digest</b>. */
  39. /** Should this connection be used for extending circuits to the server
  40. * matching the <b>identity_digest</b> field? Set to true if we're pretty
  41. * sure we aren't getting MITMed, either because we're connected to an
  42. * address listed in a server descriptor, or because an authenticated
  43. * NETINFO cell listed the address we're connected to as recognized. */
  44. unsigned int is_canonical:1;
  45. /** True iff this is an outgoing connection. */
  46. unsigned int is_outgoing:1;
  47. unsigned int proxy_type:2; /**< One of PROXY_NONE...PROXY_SOCKS5 */
  48. unsigned int wide_circ_ids:1;
  49. /** True iff this connection has had its bootstrap failure logged with
  50. * control_event_bootstrap_problem. */
  51. unsigned int have_noted_bootstrap_problem:1;
  52. /** True iff this is a client connection and its address has been put in the
  53. * geoip cache and handled by the DoS mitigation subsystem. We use this to
  54. * insure we have a coherent count of concurrent connection. */
  55. unsigned int tracked_for_dos_mitigation : 1;
  56. uint16_t link_proto; /**< What protocol version are we using? 0 for
  57. * "none negotiated yet." */
  58. uint16_t idle_timeout; /**< How long can this connection sit with no
  59. * circuits on it before we close it? Based on
  60. * IDLE_CIRCUIT_TIMEOUT_{NON,}CANONICAL and
  61. * on is_canonical, randomized. */
  62. or_handshake_state_t *handshake_state; /**< If we are setting this connection
  63. * up, state information to do so. */
  64. time_t timestamp_lastempty; /**< When was the outbuf last completely empty?*/
  65. token_bucket_rw_t bucket; /**< Used for rate limiting when the connection is
  66. * in state CONN_OPEN. */
  67. /*
  68. * Count the number of bytes flushed out on this orconn, and the number of
  69. * bytes TLS actually sent - used for overhead estimation for scheduling.
  70. */
  71. uint64_t bytes_xmitted, bytes_xmitted_by_tls;
  72. };
  73. #endif