aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-26 11:27:33 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-26 11:27:33 -0400
commit92d8284a9792267514cbe21f3ce1564f6ad0e10b (patch)
treef4a82d867c9fb863f7a3f56a2baffb509a2af5c5 /src/or
parentb4e23dba930cbb8168151e1fe9dcf280615d6f3b (diff)
parent1b93b065fc3eb52fe5674d6df05c71c505ed1ef3 (diff)
downloadtor-92d8284a9792267514cbe21f3ce1564f6ad0e10b.tar.gz
tor-92d8284a9792267514cbe21f3ce1564f6ad0e10b.zip
Merge branch 'log_dependencies'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c20
-rw-r--r--src/or/config.h4
-rw-r--r--src/or/confparse.c4
-rw-r--r--src/or/consdiff.c1
-rw-r--r--src/or/consdiff.h3
-rw-r--r--src/or/dirauth/dirvote.c2
-rw-r--r--src/or/dirserv.c3
-rw-r--r--src/or/entrynodes.c3
-rw-r--r--src/or/geoip.c3
-rw-r--r--src/or/hs_client.c1
-rw-r--r--src/or/hs_descriptor.h1
-rw-r--r--src/or/include.am4
-rw-r--r--src/or/keypin.c4
-rw-r--r--src/or/microdesc.c4
-rw-r--r--src/or/onion_ntor.c2
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/parsecommon.c4
-rw-r--r--src/or/parsecommon.h13
-rw-r--r--src/or/protover.h11
-rw-r--r--src/or/rephist.c4
-rw-r--r--src/or/routerlist.c3
-rw-r--r--src/or/routerparse.c3
-rw-r--r--src/or/routerset.c3
-rw-r--r--src/or/routerset.h3
-rw-r--r--src/or/torcert.c2
25 files changed, 69 insertions, 41 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 6bdb4ab7dc..cc3cc3ec55 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5638,6 +5638,23 @@ addressmap_register_auto(const char *from, const char *to,
}
/**
+ * As add_file_log, but open the file as appropriate.
+ */
+STATIC int
+open_and_add_file_log(const log_severity_list_t *severity,
+ const char *filename, int truncate_log)
+{
+ int open_flags = O_WRONLY|O_CREAT;
+ open_flags |= truncate_log ? O_TRUNC : O_APPEND;
+
+ int fd = tor_open_cloexec(filename, open_flags, 0640);
+ if (fd < 0)
+ return -1;
+
+ return add_file_log(severity, filename, fd);
+}
+
+/**
* Initialize the logs based on the configuration file.
*/
static int
@@ -5762,7 +5779,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
}
}
}
- if (add_file_log(severity, fname, truncate_log) < 0) {
+ if (open_and_add_file_log(severity, fname, truncate_log) < 0) {
log_warn(LD_CONFIG, "Couldn't open file for 'Log %s': %s",
opt->value, strerror(errno));
ok = 0;
@@ -8452,4 +8469,3 @@ options_any_client_port_set(const or_options_t *options)
options->DNSPort_set ||
options->HTTPTunnelPort_set);
}
-
diff --git a/src/or/config.h b/src/or/config.h
index dc3322e6b4..d2faf6c512 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -271,8 +271,10 @@ STATIC int check_bridge_distribution_setting(const char *bd);
STATIC uint64_t compute_real_max_mem_in_queues(const uint64_t val,
int log_guess);
+STATIC int open_and_add_file_log(const log_severity_list_t *severity,
+ const char *fname,
+ int truncate_log);
#endif /* defined(CONFIG_PRIVATE) */
#endif /* !defined(TOR_CONFIG_H) */
-
diff --git a/src/or/confparse.c b/src/or/confparse.c
index e88c4f72d8..b38e06c6a2 100644
--- a/src/or/confparse.c
+++ b/src/or/confparse.c
@@ -1,4 +1,3 @@
-
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
@@ -26,6 +25,8 @@
#include "or/confparse.h"
#include "or/routerset.h"
+#include "lib/container/bitarray.h"
+
static uint64_t config_parse_memunit(const char *s, int *ok);
static int config_parse_msec_interval(const char *s, int *ok);
static int config_parse_interval(const char *s, int *ok);
@@ -1186,4 +1187,3 @@ config_parse_interval(const char *s, int *ok)
}
return (int)r;
}
-
diff --git a/src/or/consdiff.c b/src/or/consdiff.c
index 59e27c0aeb..6d000997f9 100644
--- a/src/or/consdiff.c
+++ b/src/or/consdiff.c
@@ -1412,4 +1412,3 @@ looks_like_a_consensus_diff(const char *document, size_t len)
return (len >= strlen(ns_diff_version) &&
fast_memeq(document, ns_diff_version, strlen(ns_diff_version)));
}
-
diff --git a/src/or/consdiff.h b/src/or/consdiff.h
index 3f73b8536c..1cae59a1a5 100644
--- a/src/or/consdiff.h
+++ b/src/or/consdiff.h
@@ -15,6 +15,8 @@ char *consensus_diff_apply(const char *consensus,
int looks_like_a_consensus_diff(const char *document, size_t len);
#ifdef CONSDIFF_PRIVATE
+#include "lib/container/bitarray.h"
+
struct memarea_t;
/** Line type used for constructing consensus diffs. Each of these lines
@@ -95,4 +97,3 @@ MOCK_DECL(STATIC int,
#endif /* defined(CONSDIFF_PRIVATE) */
#endif /* !defined(TOR_CONSDIFF_H) */
-
diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index 16439905a2..85a0d3e707 100644
--- a/src/or/dirauth/dirvote.c
+++ b/src/or/dirauth/dirvote.c
@@ -43,6 +43,8 @@
#include "or/vote_routerstatus_st.h"
#include "or/vote_timing_st.h"
+#include "lib/container/order.h"
+
/**
* \file dirvote.c
* \brief Functions to compute directory consensus, and schedule voting.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 8c26311710..693160e80c 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -46,6 +46,8 @@
#include "or/tor_version_st.h"
#include "or/vote_routerstatus_st.h"
+#include "lib/container/order.h"
+
/**
* \file dirserv.c
* \brief Directory server core implementation. Manages directory
@@ -3591,4 +3593,3 @@ dirserv_free_all(void)
dirserv_clear_measured_bw_cache();
}
-
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 1fb6215906..3c63d3c1c2 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -142,6 +142,8 @@
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "lib/container/bloomfilt.h"
+
/** A list of existing guard selection contexts. */
static smartlist_t *guard_contexts = NULL;
/** The currently enabled guard selection context. */
@@ -3687,4 +3689,3 @@ entry_guards_free_all(void)
}
circuit_build_times_free_timeouts(get_circuit_build_times_mutable());
}
-
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 634ee707b4..330477e4ce 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -38,6 +38,8 @@
#include "or/geoip.h"
#include "or/routerlist.h"
+#include "lib/container/order.h"
+
static void init_geoip_countries(void);
/** An entry from the GeoIP IPv4 file: maps an IPv4 range to a country. */
@@ -1884,4 +1886,3 @@ geoip_free_all(void)
memset(geoip_digest, 0, sizeof(geoip_digest));
memset(geoip6_digest, 0, sizeof(geoip6_digest));
}
-
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 90a3fb3dcb..faccfae50b 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -16,7 +16,6 @@
#include "or/config.h"
#include "or/connection.h"
#include "or/connection_edge.h"
-#include "common/container.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "or/directory.h"
diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h
index 5478edc89b..219b93444e 100644
--- a/src/or/hs_descriptor.h
+++ b/src/or/hs_descriptor.h
@@ -13,7 +13,6 @@
#include "or/or.h"
#include "common/address.h"
-#include "common/container.h"
#include "lib/crypt_ops/crypto.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "trunnel/ed25519_cert.h" /* needed for trunnel */
diff --git a/src/or/include.am b/src/or/include.am
index a2532cd4d1..9e80de1f5b 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -143,8 +143,8 @@ endif
src_or_tor_SOURCES = src/or/tor_main.c
-src/or/tor_main.$(OBJEXT) \
- src/or/src_or_tor_cov-tor_main.$(OBJEXT): micro-revision.i
+src/or/git_revision.$(OBJEXT) \
+ src/or/src_or_libtor_app_testing_a-git_revision.$(OBJEXT): micro-revision.i
AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \
-DLOCALSTATEDIR="\"$(localstatedir)\"" \
diff --git a/src/or/keypin.c b/src/or/keypin.c
index 1bdb471b33..db267673f8 100644
--- a/src/or/keypin.c
+++ b/src/or/keypin.c
@@ -19,7 +19,8 @@
#include "or/keypin.h"
#include "siphash.h"
#include "lib/cc/torint.h"
-#include "common/torlog.h"
+#include "lib/log/torlog.h"
+#include "lib/fdio/fdio.h"
#include "common/util.h"
#include "common/util_format.h"
@@ -498,4 +499,3 @@ keypin_clear(void)
bad_entries);
}
}
-
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index d29d2c300e..bbe5ead6b4 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -9,6 +9,9 @@
*/
#include "or/or.h"
+
+#include "lib/fdio/fdio.h"
+
#include "or/circuitbuild.h"
#include "or/config.h"
#include "or/directory.h"
@@ -1047,4 +1050,3 @@ usable_consensus_flavor,(void))
return FLAV_NS;
}
}
-
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index a6685eb999..3a60d1b7ec 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -26,7 +26,7 @@
#include "lib/crypt_ops/crypto_digest.h"
#include "lib/crypt_ops/crypto_util.h"
#include "or/onion_ntor.h"
-#include "common/torlog.h"
+#include "lib/log/torlog.h"
#include "common/util.h"
/** Free storage held in an ntor handshake state. */
diff --git a/src/or/or.h b/src/or/or.h
index cb7e84e68b..528159b4c6 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -68,8 +68,9 @@
#include "lib/crypt_ops/crypto_dh.h"
#include "lib/crypt_ops/crypto_hkdf.h"
#include "lib/tls/tortls.h"
-#include "common/torlog.h"
-#include "common/container.h"
+#include "lib/log/torlog.h"
+#include "lib/container/smartlist.h"
+#include "lib/container/map.h"
#include "lib/compress/compress.h"
#include "common/address.h"
#include "common/compat_libevent.h"
diff --git a/src/or/parsecommon.c b/src/or/parsecommon.c
index 09c7d665fe..17a7c6a891 100644
--- a/src/or/parsecommon.c
+++ b/src/or/parsecommon.c
@@ -7,8 +7,9 @@
**/
#include "or/parsecommon.h"
-#include "common/torlog.h"
+#include "lib/log/torlog.h"
#include "common/util_format.h"
+#include "lib/container/smartlist.h"
#define MIN_ANNOTATION A_PURPOSE
#define MAX_ANNOTATION A_UNKNOWN_
@@ -448,4 +449,3 @@ find_all_by_keyword(const smartlist_t *s, directory_keyword k)
});
return out;
}
-
diff --git a/src/or/parsecommon.h b/src/or/parsecommon.h
index 93e62a559d..fc61c514a1 100644
--- a/src/or/parsecommon.h
+++ b/src/or/parsecommon.h
@@ -9,10 +9,11 @@
#ifndef TOR_PARSECOMMON_H
#define TOR_PARSECOMMON_H
-#include "common/container.h"
#include "lib/crypt_ops/crypto.h"
#include "common/memarea.h"
+struct smartlist_t;
+
/** Enumeration of possible token types. The ones starting with K_ correspond
* to directory 'keywords'. A_ is for an annotation, R or C is related to
* hidden services, ERR_ is an error in the tokenizing process, EOF_ is an
@@ -299,7 +300,7 @@ void token_clear(directory_token_t *tok);
int tokenize_string(memarea_t *area,
const char *start, const char *end,
- smartlist_t *out,
+ struct smartlist_t *out,
token_rule_t *table,
int flags);
directory_token_t *get_next_token(memarea_t *area,
@@ -307,16 +308,16 @@ directory_token_t *get_next_token(memarea_t *area,
const char *eos,
token_rule_t *table);
-directory_token_t *find_by_keyword_(smartlist_t *s,
+directory_token_t *find_by_keyword_(struct smartlist_t *s,
directory_keyword keyword,
const char *keyword_str);
#define find_by_keyword(s, keyword) \
find_by_keyword_((s), (keyword), #keyword)
-directory_token_t *find_opt_by_keyword(const smartlist_t *s,
+directory_token_t *find_opt_by_keyword(const struct smartlist_t *s,
directory_keyword keyword);
-smartlist_t * find_all_by_keyword(const smartlist_t *s, directory_keyword k);
+struct smartlist_t * find_all_by_keyword(const struct smartlist_t *s,
+ directory_keyword k);
#endif /* !defined(TOR_PARSECOMMON_H) */
-
diff --git a/src/or/protover.h b/src/or/protover.h
index 6236ed133c..aab311e96f 100644
--- a/src/or/protover.h
+++ b/src/or/protover.h
@@ -9,7 +9,7 @@
#ifndef TOR_PROTOVER_H
#define TOR_PROTOVER_H
-#include "common/container.h"
+struct smartlist_t;
/** The first version of Tor that included "proto" entries in its
* descriptors. Authorities should use this to decide whether to
@@ -47,7 +47,7 @@ int protover_all_supported(const char *s, char **missing);
int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
const char *protover_get_supported_protocols(void);
-char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
+char *protover_compute_vote(const struct smartlist_t *list_of_proto_strings,
int threshold);
const char *protover_compute_for_old_tor(const char *version);
int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
@@ -75,12 +75,12 @@ typedef struct proto_entry_t {
*/
char *name;
/** Smartlist of proto_range_t */
- smartlist_t *ranges;
+ struct smartlist_t *ranges;
} proto_entry_t;
#if !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS)
-STATIC smartlist_t *parse_protocol_list(const char *s);
-STATIC char *encode_protocol_list(const smartlist_t *sl);
+STATIC struct smartlist_t *parse_protocol_list(const char *s);
+STATIC char *encode_protocol_list(const struct smartlist_t *sl);
STATIC const char *protocol_type_to_str(protocol_type_t pr);
STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
STATIC void proto_entry_free_(proto_entry_t *entry);
@@ -92,4 +92,3 @@ STATIC void proto_entry_free_(proto_entry_t *entry);
#endif /* defined(PROTOVER_PRIVATE) */
#endif /* !defined(TOR_PROTOVER_H) */
-
diff --git a/src/or/rephist.c b/src/or/rephist.c
index a1cfc49327..2103eecdfb 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -92,6 +92,9 @@
#include "or/networkstatus_st.h"
#include "or/or_circuit_st.h"
+#include "lib/container/bloomfilt.h"
+#include "lib/container/order.h"
+
static void bw_arrays_init(void);
static void predicted_ports_alloc(void);
@@ -3208,4 +3211,3 @@ rep_hist_free_all(void)
tor_assert_nonfatal(rephist_total_alloc == 0);
tor_assert_nonfatal_once(rephist_total_num == 0);
}
-
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 97b3270f5b..5af09fad2b 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -137,6 +137,8 @@
#include "or/routerlist_st.h"
#include "or/vote_routerstatus_st.h"
+#include "lib/container/bloomfilt.h"
+
// #define DEBUG_ROUTERLIST
/****************************************************************************/
@@ -5836,4 +5838,3 @@ refresh_all_country_info(void)
nodelist_refresh_countries();
}
-
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index a0426b96c6..91475cd511 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -98,6 +98,8 @@
#include "or/vote_microdesc_hash_st.h"
#include "or/vote_routerstatus_st.h"
+#include "lib/container/bloomfilt.h"
+
#undef log
#include <math.h>
@@ -5684,4 +5686,3 @@ routerparse_free_all(void)
{
dump_desc_fifo_cleanup();
}
-
diff --git a/src/or/routerset.c b/src/or/routerset.c
index 231ae152a5..61b7dc121e 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2001 Matej Pfajfar.
- * Copyright (c) 2001-2004, Roger Dingledine.
+n * Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
@@ -460,4 +460,3 @@ routerset_free_(routerset_t *routerset)
bitarray_free(routerset->countries);
tor_free(routerset);
}
-
diff --git a/src/or/routerset.h b/src/or/routerset.h
index 5293c0ebf8..8a13ca042a 100644
--- a/src/or/routerset.h
+++ b/src/or/routerset.h
@@ -45,6 +45,8 @@ void routerset_free_(routerset_t *routerset);
int routerset_len(const routerset_t *set);
#ifdef ROUTERSET_PRIVATE
+#include "lib/container/bitarray.h"
+
STATIC char * routerset_get_countryname(const char *c);
STATIC int routerset_contains(const routerset_t *set, const tor_addr_t *addr,
uint16_t orport,
@@ -85,4 +87,3 @@ struct routerset_t {
};
#endif /* defined(ROUTERSET_PRIVATE) */
#endif /* !defined(TOR_ROUTERSET_H) */
-
diff --git a/src/or/torcert.c b/src/or/torcert.c
index 23dfd3d437..e307dd1b54 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -30,7 +30,7 @@
#include "lib/crypt_ops/crypto_util.h"
#include "or/torcert.h"
#include "trunnel/ed25519_cert.h"
-#include "common/torlog.h"
+#include "lib/log/torlog.h"
#include "common/util.h"
#include "common/compat.h"
#include "trunnel/link_handshake.h"