| 
					
				 | 
			
			
				@@ -1550,88 +1550,12 @@ typedef struct or_handshake_state_t { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * drops below this size. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define OR_CONN_LOWWATER (16*1024) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** Subtype of connection_t for an "OR connection" -- that is, one that speaks 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * cells over TLS. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-typedef struct or_connection_t { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  connection_t base_; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** Hash of the public RSA key for the other side's identity key, or zeroes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * if the other side hasn't shown us a valid identity key. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char identity_digest[DIGEST_LEN]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** Extended ORPort connection identifier. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char *ext_or_conn_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** This is the ClientHash value we expect to receive from the 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  client during the Extended ORPort authentication protocol. We 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  compute it upon receiving the ClientNoce from the client, and we 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  compare it with the acual ClientHash value sent by the 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  client. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char *ext_or_auth_correct_client_hash; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** String carrying the name of the pluggable transport 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  (e.g. "obfs2") that is obfuscating this connection. If no 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   *  pluggable transports are used, it's NULL. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char *ext_or_transport; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char *nickname; /**< Nickname of OR on other side (if any). */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  tor_tls_t *tls; /**< TLS connection state. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  int tls_error; /**< Last tor_tls error code. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** When we last used this conn for any client traffic. If not 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * recent, we can rate limit it further. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* Channel using this connection */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  channel_tls_t *chan; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  tor_addr_t real_addr; /**< The actual address that this connection came from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       * or went to.  The <b>addr</b> field is prone to 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       * getting overridden by the address from the router 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       * descriptor matching <b>identity_digest</b>. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** Should this connection be used for extending circuits to the server 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * matching the <b>identity_digest</b> field?  Set to true if we're pretty 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * sure we aren't getting MITMed, either because we're connected to an 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * address listed in a server descriptor, or because an authenticated 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * NETINFO cell listed the address we're connected to as recognized. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int is_canonical:1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** True iff this is an outgoing connection. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int is_outgoing:1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int proxy_type:2; /**< One of PROXY_NONE...PROXY_SOCKS5 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int wide_circ_ids:1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** True iff this connection has had its bootstrap failure logged with 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * control_event_bootstrap_problem. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int have_noted_bootstrap_problem:1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** True iff this is a client connection and its address has been put in the 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * geoip cache and handled by the DoS mitigation subsystem. We use this to 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * insure we have a coherent count of concurrent connection. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  unsigned int tracked_for_dos_mitigation : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  uint16_t link_proto; /**< What protocol version are we using? 0 for 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        * "none negotiated yet." */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  uint16_t idle_timeout; /**< How long can this connection sit with no 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                          * circuits on it before we close it? Based on 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                          * IDLE_CIRCUIT_TIMEOUT_{NON,}CANONICAL and 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                          * on is_canonical, randomized. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  or_handshake_state_t *handshake_state; /**< If we are setting this connection 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                          * up, state information to do so. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  time_t timestamp_lastempty; /**< When was the outbuf last completely empty?*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  token_bucket_rw_t bucket; /**< Used for rate limiting when the connection is 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                          * in state CONN_OPEN. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * Count the number of bytes flushed out on this orconn, and the number of 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * bytes TLS actually sent - used for overhead estimation for scheduling. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  uint64_t bytes_xmitted, bytes_xmitted_by_tls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} or_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef struct control_connection_t control_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef struct dir_connection_t dir_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef struct edge_connection_t edge_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef struct entry_connection_t entry_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef struct listener_connection_t listener_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+typedef struct or_connection_t or_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** Cast a connection_t subtype pointer to a connection_t **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define TO_CONN(c) (&(((c)->base_))) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1639,16 +1563,6 @@ typedef struct listener_connection_t listener_connection_t; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** Cast a entry_connection_t subtype pointer to a connection_t **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** Convert a connection_t* to an or_connection_t*; assert if the cast is 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * invalid. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-static or_connection_t *TO_OR_CONN(connection_t *); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-static inline or_connection_t *TO_OR_CONN(connection_t *c) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  tor_assert(c->magic == OR_CONNECTION_MAGIC); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  return DOWNCAST(or_connection_t, c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** What action type does an address policy indicate: accept or reject? */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 typedef enum { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ADDR_POLICY_ACCEPT=1, 
			 |