[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] config: Move any_client_port_set() to config.c
commit 01ffe8e2f4ca24325e81f040e1ac3a5a17afa5d5
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Wed Apr 25 13:41:04 2018 -0400
config: Move any_client_port_set() to config.c
This functions is now used outside of networkstatus.c and makes more sense to
be in config.c.
It is also renamed to options_any_client_port_set() for the config.c
namespace.
No code behavior change.
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/or/config.c | 15 +++++++++++++++
src/or/config.h | 3 +++
src/or/main.c | 2 +-
src/or/networkstatus.c | 20 +-------------------
src/or/networkstatus.h | 2 --
5 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/or/config.c b/src/or/config.c
index 9af613e93..20db37ae3 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -8433,3 +8433,18 @@ init_cookie_authentication(const char *fname, const char *header,
return retval;
}
+/**
+ * Return true if any option is set in <b>options</b> to make us behave
+ * as a client.
+ */
+int
+options_any_client_port_set(const or_options_t *options)
+{
+ return (options->SocksPort_set ||
+ options->TransPort_set ||
+ options->NATDPort_set ||
+ options->ControlPort_set ||
+ options->DNSPort_set ||
+ options->HTTPTunnelPort_set);
+}
+
diff --git a/src/or/config.h b/src/or/config.h
index 1d3c27217..4b4127443 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -214,6 +214,9 @@ smartlist_t *get_options_from_transport_options_line(const char *line,
const char *transport);
smartlist_t *get_options_for_server_transport(const char *transport);
+/* Port helper functions. */
+int options_any_client_port_set(const or_options_t *options);
+
#ifdef CONFIG_PRIVATE
#define CL_PORT_NO_STREAM_OPTIONS (1u<<0)
diff --git a/src/or/main.c b/src/or/main.c
index c3505a2d9..6cda56b3c 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1497,7 +1497,7 @@ get_my_roles(const or_options_t *options)
int roles = 0;
int is_bridge = options->BridgeRelay;
- int is_client = any_client_port_set(options);
+ int is_client = options_any_client_port_set(options);
int is_relay = server_mode(options);
int is_dirauth = authdir_mode_v3(options);
int is_bridgeauth = authdir_mode_bridge(options);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 44c0638c2..b7443b4c7 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1691,24 +1691,6 @@ networkstatus_set_current_consensus_from_ns(networkstatus_t *c,
#endif /* defined(TOR_UNIT_TESTS) */
/**
- * Return true if any option is set in <b>options</b> to make us behave
- * as a client.
- *
- * XXXX If we need this elsewhere at any point, we should make it nonstatic
- * XXXX and move it into another file.
- */
-int
-any_client_port_set(const or_options_t *options)
-{
- return (options->SocksPort_set ||
- options->TransPort_set ||
- options->NATDPort_set ||
- options->ControlPort_set ||
- options->DNSPort_set ||
- options->HTTPTunnelPort_set);
-}
-
-/**
* Helper for handle_missing_protocol_warning: handles either the
* client case (if <b>is_client</b> is set) or the server case otherwise.
*/
@@ -1743,7 +1725,7 @@ handle_missing_protocol_warning(const networkstatus_t *c,
const or_options_t *options)
{
const int is_server = server_mode(options);
- const int is_client = any_client_port_set(options) || !is_server;
+ const int is_client = options_any_client_port_set(options) || !is_server;
if (is_server)
handle_missing_protocol_warning_impl(c, 0);
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index 0c325959d..6a7a42f91 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -147,8 +147,6 @@ void vote_routerstatus_free_(vote_routerstatus_t *rs);
#define vote_routerstatus_free(rs) \
FREE_AND_NULL(vote_routerstatus_t, vote_routerstatus_free_, (rs))
-int any_client_port_set(const or_options_t *options);
-
#ifdef NETWORKSTATUS_PRIVATE
#ifdef TOR_UNIT_TESTS
STATIC int networkstatus_set_current_consensus_from_ns(networkstatus_t *c,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits