or_connection_st.h 3.9 KB

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