Minimize the includes in control.c

This commit is contained in:
Nick Mathewson 2019-03-25 14:14:56 -04:00
parent 2917ecaa97
commit 61cebb2035
7 changed files with 20 additions and 94 deletions

View File

@ -109,8 +109,6 @@ problem function-size /src/tools/tor-gencert.c:parse_commandline() 111
problem function-size /src/feature/keymgt/loadkey.c:ed_key_init_from_file() 333
problem function-size /src/feature/dircommon/consdiff.c:gen_ed_diff() 204
problem function-size /src/feature/dircommon/consdiff.c:apply_ed_diff() 159
problem file-size /src/feature/control/control.c 7592
problem include-count /src/feature/control/control.c 90
problem function-size /src/feature/control/control_auth.c:handle_control_authenticate() 188
problem function-size /src/feature/control/control_auth.c:handle_control_authchallenge() 115
problem function-size /src/feature/control/control_getinfo.c:getinfo_helper_misc() 109

View File

@ -33,91 +33,25 @@
**/
#define CONTROL_MODULE_PRIVATE
#define CONTROL_EVENTS_PRIVATE
#define OCIRC_EVENT_PRIVATE
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/confparse.h"
#include "app/main/main.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/or/channel.h"
#include "core/or/channeltls.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuitstats.h"
#include "core/or/circuituse.h"
#include "core/or/command.h"
#include "core/or/connection_edge.h"
#include "core/or/connection_or.h"
#include "core/or/ocirc_event.h"
#include "core/or/policies.h"
#include "core/or/reasons.h"
#include "core/or/versions.h"
#include "core/proto/proto_control0.h"
#include "core/proto/proto_http.h"
#include "feature/client/addressmap.h"
#include "feature/client/bridges.h"
#include "feature/client/dnsserv.h"
#include "feature/client/entrynodes.h"
#include "feature/control/control.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_cmd.h"
#include "feature/control/control_events.h"
#include "feature/control/control_fmt.h"
#include "feature/control/control_getinfo.h"
#include "feature/control/fmt_serverstatus.h"
#include "feature/control/getinfo_geoip.h"
#include "feature/dircache/dirserv.h"
#include "feature/dirclient/dirclient.h"
#include "feature/dirclient/dlstatus.h"
#include "feature/dircommon/directory.h"
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_cache.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_control.h"
#include "feature/hs_common/shared_random_client.h"
#include "feature/nodelist/authcert.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerinfo.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/router.h"
#include "feature/relay/routermode.h"
#include "feature/relay/selftest.h"
#include "feature/rend/rendclient.h"
#include "feature/rend/rendcommon.h"
#include "feature/rend/rendparse.h"
#include "feature/rend/rendservice.h"
#include "feature/stats/geoip_stats.h"
#include "feature/stats/predict_ports.h"
#include "lib/buf/buffers.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/encoding/confline.h"
#include "lib/evloop/compat_libevent.h"
#include "lib/version/torversion.h"
#include "lib/evloop/procmon.h"
#include "feature/dircache/cached_dir_st.h"
#include "feature/control/control_connection_st.h"
#include "core/or/cpath_build_state_st.h"
#include "core/or/entry_connection_st.h"
#include "feature/nodelist/extrainfo_st.h"
#include "feature/nodelist/networkstatus_st.h"
#include "feature/nodelist/node_st.h"
#include "core/or/or_connection_st.h"
#include "core/or/or_circuit_st.h"
#include "core/or/origin_circuit_st.h"
#include "feature/nodelist/microdesc_st.h"
#include "feature/rend/rend_authorized_client_st.h"
#include "feature/rend/rend_encoded_v2_service_descriptor_st.h"
#include "feature/rend/rend_service_descriptor_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/routerlist_st.h"
#include "core/or/socks_request_st.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@ -126,15 +60,6 @@
#include <sys/stat.h>
#endif
#ifndef _WIN32
#include <pwd.h>
#include <sys/resource.h>
#endif
#include "lib/crypt_ops/crypto_s2k.h"
#include "lib/evloop/procmon.h"
#include "lib/evloop/compat_libevent.h"
/** Convert a connection_t* to an control_connection_t*; assert if the cast is
* invalid. */
control_connection_t *
@ -610,21 +535,6 @@ monitor_owning_controller_process(const char *process_spec)
}
}
/** Return a longname the node whose identity is <b>id_digest</b>. If
* node_get_by_id() returns NULL, base 16 encoding of <b>id_digest</b> is
* returned instead.
*
* This function is not thread-safe. Each call to this function invalidates
* previous values returned by this function.
*/
MOCK_IMPL(const char *,
node_describe_longname_by_id,(const char *id_digest))
{
static char longname[MAX_VERBOSE_NICKNAME_LEN+1];
node_get_verbose_nickname_by_id(id_digest, longname);
return longname;
}
/** Free any leftover allocated memory of the control.c subsystem. */
void
control_free_all(void)

View File

@ -48,7 +48,6 @@ void enable_control_logging(void);
void monitor_owning_controller_process(const char *process_spec);
const char *rend_auth_type_to_string(rend_auth_type_t auth_type);
MOCK_DECL(const char *, node_describe_longname_by_id,(const char *id_digest));
void control_free_all(void);
#ifdef CONTROL_MODULE_PRIVATE

View File

@ -392,3 +392,18 @@ decode_escaped_string(const char *start, size_t in_len_max,
return end+1;
}
/** Return a longname the node whose identity is <b>id_digest</b>. If
* node_get_by_id() returns NULL, base 16 encoding of <b>id_digest</b> is
* returned instead.
*
* This function is not thread-safe. Each call to this function invalidates
* previous values returned by this function.
*/
MOCK_IMPL(const char *,
node_describe_longname_by_id,(const char *id_digest))
{
static char longname[MAX_VERBOSE_NICKNAME_LEN+1];
node_get_verbose_nickname_by_id(id_digest, longname);
return longname;
}

View File

@ -31,4 +31,6 @@ const char *decode_escaped_string(const char *start, size_t in_len_max,
char **out, size_t *out_len);
void send_control_done(control_connection_t *conn);
MOCK_DECL(const char *, node_describe_longname_by_id,(const char *id_digest));
#endif /* !defined(TOR_CONTROL_FMT_H) */

View File

@ -16,6 +16,7 @@
#include "test/test.h"
#include "feature/control/control.h"
#include "feature/control/control_events.h"
#include "feature/control/control_fmt.h"
#include "app/config/config.h"
#include "feature/hs/hs_common.h"
#include "feature/rend/rendcommon.h"

View File

@ -12,6 +12,7 @@
#include "test/test.h"
#include "feature/control/control.h"
#include "feature/control/control_events.h"
#include "feature/control/control_fmt.h"
#include "app/config/config.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_control.h"