Tor 0.4.9.3-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Fields
connection_t Struct Reference

#include <connection_st.h>

Data Fields

uint32_t magic
 
uint8_t state
 
unsigned int type:5
 
unsigned int purpose:5
 
unsigned int read_blocked_on_bw:1
 
unsigned int write_blocked_on_bw:1
 
unsigned int hold_open_until_flushed:1
 
unsigned int inbuf_reached_eof:1
 
unsigned int in_flushed_some:1
 
unsigned int in_connection_handle_write:1
 
unsigned int always_rate_limit_as_remote:1
 
unsigned int linked:1
 
unsigned int reading_from_linked_conn:1
 
unsigned int writing_to_linked_conn:1
 
unsigned int active_on_link:1
 
unsigned int linked_conn_is_closed:1
 
unsigned int from_listener:1
 
unsigned int proxy_state:4
 
tor_socket_t s
 
int conn_array_index
 
struct event * read_event
 
struct event * write_event
 
struct buf_t * inbuf
 
struct buf_t * outbuf
 
time_t timestamp_last_read_allowed
 
time_t timestamp_last_write_allowed
 
time_t timestamp_created
 
int socket_family
 
tor_addr_t addr
 
uint16_t port
 
uint16_t marked_for_close
 
const char * marked_for_close_file
 
char * address
 
struct connection_tlinked_conn
 
uint64_t global_identifier
 
uint32_t n_read_conn_bw
 
uint32_t n_written_conn_bw
 

Detailed Description

Description of a connection to another host or process, and associated data.

A connection is named based on what it's connected to – an "OR connection" has a Tor node on the other end, an "exit connection" has a website or other server on the other end, and an "AP connection" has an application proxy (and thus a user) on the other end.

Every connection has a type and a state. Connections never change their type, but can go through many state changes in their lifetime.

Every connection has two associated input and output buffers. Listeners don't use them. For non-listener connections, incoming data is appended to conn->inbuf, and outgoing data is taken from conn->outbuf. Connections differ primarily in the functions called to fill and drain these buffers.

Definition at line 45 of file connection_st.h.

Field Documentation

◆ active_on_link

unsigned int active_on_link

True iff we're currently able to read on the linked conn, and our read_event should be made active with libevent.

Definition at line 86 of file connection_st.h.

Referenced by connection_handle_read_impl(), connection_start_reading_from_linked_conn(), and connection_stop_reading_from_linked_conn().

◆ addr

tor_addr_t addr

IP address on the internet of this connection's peer, usually.

This address may come from several sources. If this is an outbound connection, it is the address we are trying to connect to–either directly through s, or via a proxy. (If we used a proxy, then getpeername(s) will not give this address.)

For incoming connections, this field is the address we got from getpeername() or accept(), as updated by any proxy that we are using (for example, an ExtORPort proxy).

For listeners, this is the address we are trying to bind to.

If this connection is using a unix socket, then this address is a null address, and the real address is in the address field.

If this connection represents a request made somewhere other than via TCP (for example, a UDP dns request, or a controller resolve request), then this address is the address that originated the request.

TECHNICAL DEBT:

There are a few places in the code that modify this address, or use it in other ways that we don't currently like. Please don't add any more!

The misuses of this field include:

  • Setting it on linked connections, possibly.
  • Updating it based on the Forwarded-For header– Forwarded-For is set by a proxy, but not a local trusted proxy.

Definition at line 149 of file connection_st.h.

Referenced by clock_skew_warning(), conn_get_proxy_type(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_send_resolve(), connection_ap_handshake_socks_reply(), connection_ap_make_link(), connection_describe_peer_internal(), connection_dir_is_global_write_low(), connection_edge_end(), connection_edge_finished_connecting(), connection_exit_begin_conn(), connection_exit_connect(), connection_exit_connect_dir(), connection_ext_or_handle_cmd_useraddr(), connection_handle_listener_read(), connection_haproxy_proxy_connect(), connection_https_proxy_connect(), connection_is_rate_limited(), connection_listener_new(), connection_or_check_canonicity(), connection_or_client_learned_peer_id(), connection_or_init_conn_from_address(), connection_read_proxy_handshake(), connection_send_socks5_connect(), connection_socks4_proxy_connect(), connection_socks5_proxy_connect(), control_connection_add_local_fd(), directory_initiate_request(), dns_resolve_impl(), dnsserv_launch_request(), get_proxy_addrport(), metrics_connection_process_inbuf(), retry_all_listeners(), retry_listener_ports(), run_connection_housekeeping(), set_exitconn_info_from_resolve(), and write_http_response_header_impl().

◆ address

char* address

◆ always_rate_limit_as_remote

unsigned int always_rate_limit_as_remote

If true, then we treat this connection as remote for the purpose of rate-limiting, no matter what its address is.

Definition at line 74 of file connection_st.h.

Referenced by connection_ext_or_handle_cmd_useraddr(), and connection_is_rate_limited().

◆ conn_array_index

int conn_array_index

◆ from_listener

unsigned int from_listener

True iff this connection was opened from a listener and thus we've received this connection. Else, it means we've initiated an outbound connection.

Definition at line 93 of file connection_st.h.

Referenced by connection_handle_listener_read(), and connection_mark_for_close_internal_().

◆ global_identifier

uint64_t global_identifier

◆ hold_open_until_flushed

unsigned int hold_open_until_flushed

Despite this connection's being marked for close, do we flush it before closing it?

Definition at line 61 of file connection_st.h.

Referenced by assert_connection_ok(), circuit_log_ancient_one_hop_circuits(), conn_close_if_marked(), connection_expire_held_open(), connection_may_write_to_buf(), and connection_or_about_to_close().

◆ in_connection_handle_write

unsigned int in_connection_handle_write

True if connection_handle_write is currently running on this connection.

Definition at line 71 of file connection_st.h.

Referenced by connection_buf_read_from_socket().

◆ in_flushed_some

unsigned int in_flushed_some

Set to 1 when we're inside connection_flushed_some to keep us from calling connection_handle_write() recursively.

Definition at line 68 of file connection_st.h.

Referenced by connection_flushed_some(), and connection_handle_write_impl().

◆ inbuf

struct buf_t* inbuf

◆ inbuf_reached_eof

unsigned int inbuf_reached_eof

Boolean: did read() return 0 on this conn?

Definition at line 64 of file connection_st.h.

Referenced by connection_buf_read_from_socket(), connection_dir_process_inbuf(), and connection_handle_read_impl().

◆ linked

unsigned int linked

◆ linked_conn

struct connection_t* linked_conn

◆ linked_conn_is_closed

unsigned int linked_conn_is_closed

True iff we've called connection_close_immediate() on this linked connection.

Definition at line 89 of file connection_st.h.

Referenced by connection_close_immediate(), and connection_dir_is_anonymous().

◆ magic

uint32_t magic

◆ marked_for_close

uint16_t marked_for_close

Should we close this conn on the next iteration of the main loop? (If true, holds the line number where this connection was marked.)

Definition at line 153 of file connection_st.h.

Referenced by add_connection_to_closeable_list(), ap_stream_wants_exit_attention(), assert_connection_ok(), channel_tls_handle_cell(), circuit_about_to_free(), circuit_log_ancient_one_hop_circuits(), circuit_resume_edge_reading_helper(), circuits_handle_oom(), conn_close_if_marked(), conn_read_callback(), conn_write_callback(), connection_about_to_close_connection(), connection_ap_about_to_close(), connection_ap_attach_pending(), connection_ap_handshake_rewrite_and_attach(), connection_ap_mark_as_pending_circuit_(), connection_buf_read_from_socket(), connection_check_event(), connection_dir_finished_flushing(), connection_dir_is_anonymous(), connection_edge_about_to_close(), connection_edge_destroy(), connection_edge_end(), connection_edge_package_raw_inbuf(), connection_edge_reached_eof(), connection_edge_send_command(), connection_exit_begin_resolve(), connection_expire_held_open(), connection_free_(), connection_handle_listener_read(), connection_handle_read_impl(), connection_handle_write_impl(), connection_is_moribund(), connection_mark_all_noncontrol_connections(), connection_mark_all_noncontrol_listeners(), connection_mark_for_close_internal_(), connection_mark_unattached_ap_(), connection_may_write_to_buf(), connection_or_group_set_badness_(), connection_or_single_set_badness_(), connection_state_is_connecting(), connection_state_is_open(), connection_unlink(), dns_cancel_pending_resolve(), dns_resolve(), get_stream(), handle_relay_msg(), inform_pending_connections(), purge_expired_resolves(), relay_lookup_conn(), retry_all_listeners(), retry_all_socks_conn_waiting_for_desc(), run_connection_housekeeping(), and set_block_state_for_streams().

◆ marked_for_close_file

const char* marked_for_close_file

◆ n_read_conn_bw

uint32_t n_read_conn_bw

Bytes read since last call to control_event_conn_bandwidth_used(). Only used if we're configured to emit CONN_BW events.

Definition at line 179 of file connection_st.h.

Referenced by connection_buf_read_from_socket(), and control_event_conn_bandwidth().

◆ n_written_conn_bw

uint32_t n_written_conn_bw

Bytes written since last call to control_event_conn_bandwidth_used(). Only used if we're configured to emit CONN_BW events.

Definition at line 183 of file connection_st.h.

Referenced by connection_handle_write_impl(), and control_event_conn_bandwidth().

◆ outbuf

struct buf_t* outbuf

◆ port

uint16_t port

◆ proxy_state

unsigned int proxy_state

◆ purpose

unsigned int purpose

◆ read_blocked_on_bw

unsigned int read_blocked_on_bw

Boolean: should we start reading again once the bandwidth throttler allows it?

Definition at line 56 of file connection_st.h.

Referenced by connection_close_immediate(), connection_read_bw_exhausted(), and reenable_blocked_connections_cb().

◆ read_event

struct event* read_event

◆ reading_from_linked_conn

unsigned int reading_from_linked_conn

◆ s

◆ socket_family

int socket_family

◆ state

uint8_t state

Current state of this connection.

Definition at line 49 of file connection_st.h.

Referenced by ap_stream_wants_exit_attention(), assert_connection_ok(), channel_tls_handle_cell(), circuit_get_open_circ_or_launch(), circuit_log_ancient_one_hop_circuits(), conn_close_if_marked(), connection_ap_attach_pending(), connection_ap_handle_onion(), connection_ap_handshake_attach_chosen_circuit(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_process_socks(), connection_ap_handshake_rewrite_and_attach(), connection_ap_handshake_send_begin(), connection_ap_handshake_send_resolve(), connection_ap_make_link(), connection_ap_mark_as_pending_circuit_(), connection_bucket_read_limit(), connection_bucket_refill_single(), connection_bucket_write_limit(), connection_buckets_decrement(), connection_buf_read_from_socket(), connection_check_event(), connection_close_immediate(), connection_consider_empty_read_buckets(), connection_consider_empty_write_buckets(), connection_control_process_inbuf(), connection_describe(), connection_dir_about_to_close(), connection_dir_finished_connecting(), connection_dir_finished_flushing(), connection_dir_process_inbuf(), connection_dir_reached_eof(), connection_dirserv_flushed_some(), connection_dns_remove(), connection_edge_finished_connecting(), connection_edge_finished_flushing(), connection_edge_flushed_some(), connection_edge_package_raw_inbuf(), connection_edge_process_inbuf(), connection_edge_process_ordered_relay_cell(), connection_edge_process_relay_cell_not_open(), connection_edge_process_resolved_cell(), connection_exit_about_to_close(), connection_exit_begin_conn(), connection_exit_begin_resolve(), connection_exit_connect(), connection_exit_connect_dir(), connection_expire_held_open(), connection_ext_or_auth_handle_client_hash(), connection_ext_or_auth_handle_client_nonce(), connection_ext_or_auth_neg_auth_type(), connection_ext_or_auth_process_inbuf(), connection_ext_or_finished_flushing(), connection_ext_or_process_inbuf(), connection_ext_or_start_auth(), connection_flushed_some(), connection_free_minimal(), connection_half_edge_add(), connection_handle_write_impl(), connection_init_accepted_conn(), connection_listener_new(), connection_or_about_to_close(), connection_or_change_state(), connection_or_finished_connecting(), connection_or_finished_flushing(), connection_or_get_state_description(), connection_or_group_set_badness_(), connection_or_process_inbuf(), connection_or_send_auth_challenge_cell(), connection_or_send_certs_cell(), connection_or_write_cell_to_buf(), connection_or_write_var_cell_to_buf(), connection_state_is_connecting(), connection_state_is_open(), connection_tls_continue_handshake(), control_connection_add_local_fd(), control_protocol_is_valid(), directory_handle_command_get(), directory_handle_command_post(), directory_initiate_request(), dns_cancel_pending_resolve(), dns_resolve(), dnsserv_launch_request(), getinfo_helper_events(), handle_control_authenticate(), handle_hs_exit_conn(), inform_pending_connections(), is_valid_initial_command(), mark_conn_as_waiting_for_circuit(), purge_expired_resolves(), and run_connection_housekeeping().

◆ timestamp_created

time_t timestamp_created

◆ timestamp_last_read_allowed

time_t timestamp_last_read_allowed

◆ timestamp_last_write_allowed

time_t timestamp_last_write_allowed

◆ type

unsigned int type

What kind of connection is this?

Definition at line 50 of file connection_st.h.

Referenced by ap_stream_wants_exit_attention(), assert_circuit_ok(), assert_connection_ok(), check_sockaddr_family_match(), circuit_detach_stream(), circuit_get_open_circ_or_launch(), circuit_log_ancient_one_hop_circuits(), circuits_handle_oom(), conn_close_if_marked(), conn_read_callback(), conn_write_callback(), connection_about_to_close_connection(), connection_add_impl(), connection_ap_attach_pending(), connection_ap_get_nonrend_circ_purpose(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_process_socks(), connection_ap_handshake_send_begin(), connection_ap_handshake_send_resolve(), connection_bucket_read_limit(), connection_bucket_write_limit(), connection_buckets_decrement(), connection_buf_read_from_socket(), connection_check_event(), connection_close_immediate(), connection_connect(), connection_counts_as_relayed_traffic(), connection_describe(), connection_describe_peer_internal(), connection_dir_finished_connecting(), connection_dir_finished_flushing(), connection_dir_process_inbuf(), connection_dns_remove(), connection_edge_destroy(), connection_edge_finished_connecting(), connection_edge_package_raw_inbuf(), connection_edge_process_inbuf(), connection_edge_process_ordered_relay_cell(), connection_edge_process_relay_cell_not_open(), connection_edge_reached_eof(), connection_edge_send_command(), connection_exit_connect(), connection_exit_connect_dir(), connection_expire_held_open(), connection_ext_or_transition(), connection_finished_connecting(), connection_finished_flushing(), connection_flushed_some(), connection_free_(), connection_free_minimal(), connection_handle_listener_read(), connection_handle_read_impl(), connection_handle_write_impl(), connection_init(), connection_init_accepted_conn(), connection_is_listener(), connection_mark_all_noncontrol_connections(), connection_mark_all_noncontrol_listeners(), connection_mark_for_close_(), connection_mark_for_close_internal_(), connection_mark_unattached_ap_(), connection_or_get_state_description(), connection_or_nonopen_was_started_here(), connection_process_inbuf(), connection_reached_eof(), connection_remove(), connection_state_is_connecting(), connection_state_is_open(), connection_unlink(), connection_unregister_events(), connection_write_to_buf_failed(), control_event_bootstrap_problem(), control_event_conn_bandwidth(), control_event_stream_status(), directory_handle_command(), directory_send_command(), dnsserv_close_listener(), dnsserv_configure_listener(), evdns_server_callback(), get_stream(), handle_relay_msg(), hibernate_go_dormant(), metrics_connection_process_inbuf(), note_connection(), oos_victim_comparator(), record_num_bytes_transferred_impl(), retry_all_listeners(), retry_listener_ports(), and run_connection_housekeeping().

◆ write_blocked_on_bw

unsigned int write_blocked_on_bw

Boolean: should we start writing again once the bandwidth throttler allows writes?

Definition at line 58 of file connection_st.h.

Referenced by connection_close_immediate(), connection_write_bw_exhausted(), and reenable_blocked_connections_cb().

◆ write_event

struct event* write_event

◆ writing_to_linked_conn

unsigned int writing_to_linked_conn

True iff we're willing to write to the linked conn.

Definition at line 83 of file connection_st.h.

Referenced by connection_is_writing(), connection_should_read_from_linked_conn(), connection_start_writing(), and connection_stop_writing().


The documentation for this struct was generated from the following file: