tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

circuituse.h (4634B)


      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-2021, The Tor Project, Inc. */
      5 /* See LICENSE for licensing information */
      6 
      7 /**
      8 * \file circuituse.h
      9 * \brief Header file for circuituse.c.
     10 **/
     11 
     12 #ifndef TOR_CIRCUITUSE_H
     13 #define TOR_CIRCUITUSE_H
     14 
     15 void circuit_expire_building(void);
     16 void circuit_expire_waiting_for_better_guard(void);
     17 void circuit_remove_handled_ports(smartlist_t *needed_ports);
     18 int circuit_stream_is_being_handled(entry_connection_t *conn, uint16_t port,
     19                                    int min);
     20 void circuit_log_ancient_one_hop_circuits(int age);
     21 #if 0
     22 int circuit_conforms_to_options(const origin_circuit_t *circ,
     23                                const or_options_t *options);
     24 #endif
     25 void circuit_build_needed_circs(time_t now);
     26 void circuit_expire_old_circs_as_needed(time_t now);
     27 void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
     28 
     29 void circuit_expire_old_circuits_serverside(time_t now);
     30 
     31 void reset_bandwidth_test(void);
     32 int circuit_enough_testing_circs(void);
     33 
     34 void circuit_has_opened(origin_circuit_t *circ);
     35 void circuit_try_attaching_streams(origin_circuit_t *circ);
     36 void circuit_build_failed(origin_circuit_t *circ);
     37 
     38 /** Flag to set when a circuit should have only a single hop. */
     39 #define CIRCLAUNCH_ONEHOP_TUNNEL    (1<<0)
     40 /** Flag to set when a circuit needs to be built of high-uptime nodes */
     41 #define CIRCLAUNCH_NEED_UPTIME      (1<<1)
     42 /** Flag to set when a circuit needs to be built of high-capacity nodes */
     43 #define CIRCLAUNCH_NEED_CAPACITY    (1<<2)
     44 /** Flag to set when the last hop of a circuit doesn't need to be an
     45 * exit node. */
     46 #define CIRCLAUNCH_IS_INTERNAL      (1<<3)
     47 /** Flag to set when we are trying to launch a self-testing circuit to our
     48 *  IPv6 ORPort. We need to apply some additional filters on the second-last
     49 *  node in the circuit. (We are both the client and the last node in the
     50 *  circuit.) */
     51 #define CIRCLAUNCH_IS_IPV6_SELFTEST (1<<5)
     52 /** Flag to set when a circuit needs the exit to support conflux. */
     53 #define CIRCLAUNCH_NEED_CONFLUX     (1<<6)
     54 
     55 origin_circuit_t *circuit_launch_by_extend_info(uint8_t purpose,
     56                                                extend_info_t *info,
     57                                                int flags);
     58 origin_circuit_t *circuit_launch(uint8_t purpose, int flags);
     59 void circuit_reset_failure_count(int timeout);
     60 int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn,
     61                                                  origin_circuit_t *circ,
     62                                                  crypt_path_t *cpath);
     63 int connection_ap_handshake_attach_circuit(entry_connection_t *conn);
     64 
     65 void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose);
     66 
     67 int hostname_in_track_host_exits(const or_options_t *options,
     68                                 const char *address);
     69 void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ);
     70 
     71 int circuit_purpose_is_hidden_service(uint8_t);
     72 
     73 /* Series of helper functions for hidden services. */
     74 bool circuit_purpose_is_hs_client(const uint8_t purpose);
     75 bool circuit_purpose_is_hs_service(const uint8_t purpose);
     76 bool circuit_purpose_is_hs_vanguards(const uint8_t purpose);
     77 
     78 bool circuit_is_hs_v3(const circuit_t *circ);
     79 int circuit_is_acceptable(const origin_circuit_t *origin_circ,
     80                          const entry_connection_t *conn,
     81                          int must_be_open, uint8_t purpose,
     82                          int need_uptime, int need_internal,
     83                          time_t now);
     84 
     85 int circuit_should_use_vanguards(uint8_t);
     86 void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
     87 void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
     88 
     89 #ifdef TOR_UNIT_TESTS
     90 /* Used only by circuituse.c and test_circuituse.c */
     91 
     92 STATIC int circuit_is_available_for_use(const circuit_t *circ);
     93 
     94 STATIC int needs_exit_circuits(time_t now,
     95                               int *port_needs_uptime,
     96                               int *port_needs_capacity);
     97 STATIC int needs_hs_server_circuits(time_t now,
     98                                    int num_uptime_internal);
     99 
    100 STATIC int needs_hs_client_circuits(time_t now,
    101                                    int *needs_uptime,
    102                                    int *needs_capacity,
    103                                    int num_internal,
    104                                    int num_uptime_internal);
    105 
    106 STATIC int needs_circuits_for_build(int num);
    107 
    108 #endif /* defined(TOR_UNIT_TESTS) */
    109 
    110 #endif /* !defined(TOR_CIRCUITUSE_H) */