or_connection_st.h 3.8 KB

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