resolve_addr.h (2220B)
1 /* Copyright (c) 2020-2021, The Tor Project, Inc. */ 2 /* See LICENSE for licensing information */ 3 4 /** 5 * \file resolve_addr.h 6 * \brief Header file for resolve_addr.c. 7 **/ 8 9 #ifndef TOR_CONFIG_RESOLVE_ADDR_H 10 #define TOR_CONFIG_RESOLVE_ADDR_H 11 12 #include "app/config/config.h" 13 #include "core/mainloop/connection.h" 14 15 #include "app/config/or_options_st.h" 16 17 /** Method used to resolved an address. In other words, how was the address 18 * discovered by tor. */ 19 typedef enum { 20 /* Default value. Indicate that no method found the address. */ 21 RESOLVED_ADDR_NONE = 0, 22 /* Found from the "Address" configuration option. */ 23 RESOLVED_ADDR_CONFIGURED = 1, 24 /* Found from the "ORPort" configuration option. */ 25 RESOLVED_ADDR_CONFIGURED_ORPORT = 2, 26 /* Found by resolving the local hostname. */ 27 RESOLVED_ADDR_GETHOSTNAME = 3, 28 /* Found by querying the local interface(s). */ 29 RESOLVED_ADDR_INTERFACE = 4, 30 /* Found by resolving the hostname from the Address configuration option. */ 31 RESOLVED_ADDR_RESOLVED = 5, 32 } resolved_addr_method_t; 33 34 const char *resolved_addr_method_to_str(const resolved_addr_method_t method); 35 36 #define get_orport_addr(family) \ 37 (portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER, family)) 38 39 bool find_my_address(const or_options_t *options, int family, 40 int warn_severity, tor_addr_t *addr_out, 41 resolved_addr_method_t *method_out, char **hostname_out); 42 43 void resolved_addr_get_last(int family, tor_addr_t *addr_out); 44 void resolved_addr_reset_last(int family); 45 void resolved_addr_set_last(const tor_addr_t *addr, 46 const resolved_addr_method_t method_used, 47 const char *hostname_used); 48 49 void resolved_addr_get_suggested(int family, tor_addr_t *addr_out); 50 void resolved_addr_set_suggested(const tor_addr_t *addr); 51 52 bool resolved_addr_is_configured(int family); 53 54 MOCK_DECL(bool, is_local_to_resolve_addr, (const tor_addr_t *addr)); 55 56 #ifdef RESOLVE_ADDR_PRIVATE 57 58 #ifdef TOR_UNIT_TESTS 59 60 void resolve_addr_reset_suggested(int family); 61 62 #endif /* TOR_UNIT_TESTS */ 63 64 #endif /* defined(RESOLVE_ADDR_PRIVATE) */ 65 66 #endif /* !defined(TOR_CONFIG_RESOLVE_ADDR_H) */