summaryrefslogtreecommitdiff
path: root/src/app/config/resolve_addr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/config/resolve_addr.h')
-rw-r--r--src/app/config/resolve_addr.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/app/config/resolve_addr.h b/src/app/config/resolve_addr.h
index 3747546402..919d5d42cc 100644
--- a/src/app/config/resolve_addr.h
+++ b/src/app/config/resolve_addr.h
@@ -9,19 +9,58 @@
#ifndef TOR_CONFIG_RESOLVE_ADDR_H
#define TOR_CONFIG_RESOLVE_ADDR_H
+#include "app/config/config.h"
+#include "core/mainloop/connection.h"
+
#include "app/config/or_options_st.h"
-int resolve_my_address(int warn_severity, const or_options_t *options,
- uint32_t *addr_out,
- const char **method_out, char **hostname_out);
+/** Method used to resolved an address. In other words, how was the address
+ * discovered by tor. */
+typedef enum {
+ /* Default value. Indicate that no method found the address. */
+ RESOLVED_ADDR_NONE = 0,
+ /* Found from the "Address" configuration option. */
+ RESOLVED_ADDR_CONFIGURED = 1,
+ /* Found from the "ORPort" configuration option. */
+ RESOLVED_ADDR_CONFIGURED_ORPORT = 2,
+ /* Found by resolving the local hostname. */
+ RESOLVED_ADDR_GETHOSTNAME = 3,
+ /* Found by querying the local interface(s). */
+ RESOLVED_ADDR_INTERFACE = 4,
+ /* Found by resolving the hostname from the Address configuration option. */
+ RESOLVED_ADDR_RESOLVED = 5,
+} resolved_addr_method_t;
+
+const char *resolved_addr_method_to_str(const resolved_addr_method_t method);
+
+#define get_orport_addr(family) \
+ (portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER, family))
+
+bool find_my_address(const or_options_t *options, int family,
+ int warn_severity, tor_addr_t *addr_out,
+ resolved_addr_method_t *method_out, char **hostname_out);
+
+void resolved_addr_get_last(int family, tor_addr_t *addr_out);
+void resolved_addr_reset_last(int family);
+void resolved_addr_set_last(const tor_addr_t *addr,
+ const resolved_addr_method_t method_used,
+ const char *hostname_used);
-uint32_t get_last_resolved_addr(void);
-void reset_last_resolved_addr(void);
+void resolved_addr_get_suggested(int family, tor_addr_t *addr_out);
+void resolved_addr_set_suggested(const tor_addr_t *addr);
-MOCK_DECL(int, is_local_addr, (const tor_addr_t *addr));
+bool resolved_addr_is_configured(int family);
+
+MOCK_DECL(bool, is_local_to_resolve_addr, (const tor_addr_t *addr));
#ifdef RESOLVE_ADDR_PRIVATE
+#ifdef TOR_UNIT_TESTS
+
+void resolve_addr_reset_suggested(int family);
+
+#endif /* TOR_UNIT_TESTS */
+
#endif /* RESOLVE_ADDR_PRIVATE */
#endif /* TOR_CONFIG_RESOLVE_ADDR_H */