[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] feature: Move proxy_mode() into new files



commit 7944b55ad1dbadaeb2a4f72b959d23bdc15b8d20
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Fri Oct 18 13:21:36 2019 +1000

    feature: Move proxy_mode() into new files
    
    proxy_mode() was in routermode.[ch], but it's actually a client
    mode. Move it into client/proxymode.[ch].
    
    Part of 32123.
---
 src/core/include.am            |  2 ++
 src/core/mainloop/mainloop.c   |  1 +
 src/core/or/circuituse.c       |  1 +
 src/feature/client/proxymode.c | 27 +++++++++++++++++++++++++++
 src/feature/client/proxymode.h | 17 +++++++++++++++++
 src/feature/relay/routermode.c | 17 -----------------
 src/feature/relay/routermode.h |  1 -
 7 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/src/core/include.am b/src/core/include.am
index a5d11c24f..1c97f65f9 100644
--- a/src/core/include.am
+++ b/src/core/include.am
@@ -71,6 +71,7 @@ LIBTOR_APP_A_SOURCES = 				\
 	src/feature/client/circpathbias.c	\
 	src/feature/client/dnsserv.c		\
 	src/feature/client/entrynodes.c		\
+	src/feature/client/proxymode.c		\
 	src/feature/client/transports.c		\
 	src/feature/control/btrack.c		\
 	src/feature/control/btrack_circuit.c	\
@@ -305,6 +306,7 @@ noinst_HEADERS +=					\
 	src/feature/client/circpathbias.h		\
 	src/feature/client/dnsserv.h			\
 	src/feature/client/entrynodes.h			\
+	src/feature/client/proxymode.h			\
 	src/feature/client/transports.h			\
 	src/feature/control/btrack_circuit.h		\
 	src/feature/control/btrack_orconn.h		\
diff --git a/src/core/mainloop/mainloop.c b/src/core/mainloop/mainloop.c
index 2f8be9961..d58f263bd 100644
--- a/src/core/mainloop/mainloop.c
+++ b/src/core/mainloop/mainloop.c
@@ -71,6 +71,7 @@
 #include "feature/client/bridges.h"
 #include "feature/client/dnsserv.h"
 #include "feature/client/entrynodes.h"
+#include "feature/client/proxymode.h"
 #include "feature/client/transports.h"
 #include "feature/control/control.h"
 #include "feature/control/control_events.h"
diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c
index 606c5e2dd..a74ecbfd5 100644
--- a/src/core/or/circuituse.c
+++ b/src/core/or/circuituse.c
@@ -42,6 +42,7 @@
 #include "feature/client/bridges.h"
 #include "feature/client/circpathbias.h"
 #include "feature/client/entrynodes.h"
+#include "feature/client/proxymode.h"
 #include "feature/control/control_events.h"
 #include "feature/dircommon/directory.h"
 #include "feature/hs/hs_circuit.h"
diff --git a/src/feature/client/proxymode.c b/src/feature/client/proxymode.c
new file mode 100644
index 000000000..3b5fba5cd
--- /dev/null
+++ b/src/feature/client/proxymode.c
@@ -0,0 +1,27 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#include "core/or/or.h"
+
+#include "app/config/config.h"
+#include "core/mainloop/connection.h"
+#include "core/or/port_cfg_st.h"
+#include "feature/client/proxymode.h"
+
+/** Return true iff we are trying to proxy client connections. */
+int
+proxy_mode(const or_options_t *options)
+{
+  (void)options;
+  SMARTLIST_FOREACH_BEGIN(get_configured_ports(), const port_cfg_t *, p) {
+    if (p->type == CONN_TYPE_AP_LISTENER ||
+        p->type == CONN_TYPE_AP_TRANS_LISTENER ||
+        p->type == CONN_TYPE_AP_DNS_LISTENER ||
+        p->type == CONN_TYPE_AP_NATD_LISTENER)
+      return 1;
+  } SMARTLIST_FOREACH_END(p);
+  return 0;
+}
diff --git a/src/feature/client/proxymode.h b/src/feature/client/proxymode.h
new file mode 100644
index 000000000..f8352922c
--- /dev/null
+++ b/src/feature/client/proxymode.h
@@ -0,0 +1,17 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file proxymode.h
+ * \brief Header file for proxymode.c.
+ **/
+
+#ifndef TOR_PROXYMODE_H
+#define TOR_PROXYMODE_H
+
+int proxy_mode(const or_options_t *options);
+
+#endif
diff --git a/src/feature/relay/routermode.c b/src/feature/relay/routermode.c
index 2a9ddeac4..3613841b1 100644
--- a/src/feature/relay/routermode.c
+++ b/src/feature/relay/routermode.c
@@ -7,8 +7,6 @@
 #include "core/or/or.h"
 
 #include "app/config/config.h"
-#include "core/mainloop/connection.h"
-#include "core/or/port_cfg_st.h"
 #include "feature/relay/router.h"
 #include "feature/relay/routermode.h"
 
@@ -25,21 +23,6 @@ dir_server_mode(const or_options_t *options)
     (server_mode(options) && router_has_bandwidth_to_be_dirserver(options));
 }
 
-/** Return true iff we are trying to proxy client connections. */
-int
-proxy_mode(const or_options_t *options)
-{
-  (void)options;
-  SMARTLIST_FOREACH_BEGIN(get_configured_ports(), const port_cfg_t *, p) {
-    if (p->type == CONN_TYPE_AP_LISTENER ||
-        p->type == CONN_TYPE_AP_TRANS_LISTENER ||
-        p->type == CONN_TYPE_AP_DNS_LISTENER ||
-        p->type == CONN_TYPE_AP_NATD_LISTENER)
-      return 1;
-  } SMARTLIST_FOREACH_END(p);
-  return 0;
-}
-
 /** Return true iff we are trying to be a server.
  */
 MOCK_IMPL(int,
diff --git a/src/feature/relay/routermode.h b/src/feature/relay/routermode.h
index be535af47..a391a6485 100644
--- a/src/feature/relay/routermode.h
+++ b/src/feature/relay/routermode.h
@@ -17,7 +17,6 @@ int dir_server_mode(const or_options_t *options);
 MOCK_DECL(int, server_mode, (const or_options_t *options));
 MOCK_DECL(int, public_server_mode, (const or_options_t *options));
 MOCK_DECL(int, advertised_server_mode, (void));
-int proxy_mode(const or_options_t *options);
 
 void set_server_advertised(int s);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits