mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Merge remote-tracking branch 'public/unused_stuff' into maint-0.2.4
This commit is contained in:
commit
0cf327dc78
@ -1565,32 +1565,6 @@ addr_mask_get_bits(uint32_t mask)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Compare two addresses <b>a1</b> and <b>a2</b> for equality under a
|
||||
* netmask of <b>mbits</b> bits. Return -1, 0, or 1.
|
||||
*
|
||||
* XXXX_IP6 Temporary function to allow masks as bitcounts everywhere. This
|
||||
* will be replaced with an IPv6-aware version as soon as 32-bit addresses are
|
||||
* no longer passed around.
|
||||
*/
|
||||
int
|
||||
addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits)
|
||||
{
|
||||
if (bits > 32)
|
||||
bits = 32;
|
||||
else if (bits == 0)
|
||||
return 0;
|
||||
|
||||
a1 >>= (32-bits);
|
||||
a2 >>= (32-bits);
|
||||
|
||||
if (a1 < a2)
|
||||
return -1;
|
||||
else if (a1 > a2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Parse a string <b>s</b> in the format of (*|port(-maxport)?)?, setting the
|
||||
* various *out pointers as appropriate. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
@ -1643,93 +1617,6 @@ parse_port_range(const char *port, uint16_t *port_min_out,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Parse a string <b>s</b> in the format of
|
||||
* (IP(/mask|/mask-bits)?|*)(:(*|port(-maxport))?)?, setting the various
|
||||
* *out pointers as appropriate. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
parse_addr_and_port_range(const char *s, uint32_t *addr_out,
|
||||
maskbits_t *maskbits_out, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out)
|
||||
{
|
||||
char *address;
|
||||
char *mask, *port, *endptr;
|
||||
struct in_addr in;
|
||||
int bits;
|
||||
|
||||
tor_assert(s);
|
||||
tor_assert(addr_out);
|
||||
tor_assert(maskbits_out);
|
||||
tor_assert(port_min_out);
|
||||
tor_assert(port_max_out);
|
||||
|
||||
address = tor_strdup(s);
|
||||
/* Break 'address' into separate strings.
|
||||
*/
|
||||
mask = strchr(address,'/');
|
||||
port = strchr(mask?mask:address,':');
|
||||
if (mask)
|
||||
*mask++ = '\0';
|
||||
if (port)
|
||||
*port++ = '\0';
|
||||
/* Now "address" is the IP|'*' part...
|
||||
* "mask" is the Mask|Maskbits part...
|
||||
* and "port" is the *|port|min-max part.
|
||||
*/
|
||||
|
||||
if (strcmp(address,"*")==0) {
|
||||
*addr_out = 0;
|
||||
} else if (tor_inet_aton(address, &in) != 0) {
|
||||
*addr_out = ntohl(in.s_addr);
|
||||
} else {
|
||||
log_warn(LD_GENERAL, "Malformed IP %s in address pattern; rejecting.",
|
||||
escaped(address));
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!mask) {
|
||||
if (strcmp(address,"*")==0)
|
||||
*maskbits_out = 0;
|
||||
else
|
||||
*maskbits_out = 32;
|
||||
} else {
|
||||
endptr = NULL;
|
||||
bits = (int) strtol(mask, &endptr, 10);
|
||||
if (!*endptr) {
|
||||
/* strtol handled the whole mask. */
|
||||
if (bits < 0 || bits > 32) {
|
||||
log_warn(LD_GENERAL,
|
||||
"Bad number of mask bits on address range; rejecting.");
|
||||
goto err;
|
||||
}
|
||||
*maskbits_out = bits;
|
||||
} else if (tor_inet_aton(mask, &in) != 0) {
|
||||
bits = addr_mask_get_bits(ntohl(in.s_addr));
|
||||
if (bits < 0) {
|
||||
log_warn(LD_GENERAL,
|
||||
"Mask %s on address range isn't a prefix; dropping",
|
||||
escaped(mask));
|
||||
goto err;
|
||||
}
|
||||
*maskbits_out = bits;
|
||||
} else {
|
||||
log_warn(LD_GENERAL,
|
||||
"Malformed mask %s on address range; rejecting.",
|
||||
escaped(mask));
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_port_range(port, port_min_out, port_max_out)<0)
|
||||
goto err;
|
||||
|
||||
tor_free(address);
|
||||
return 0;
|
||||
err:
|
||||
tor_free(address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Given an IPv4 in_addr struct *<b>in</b> (in network order, as usual),
|
||||
* write it as a string into the <b>buf_len</b>-byte buffer in
|
||||
* <b>buf</b>.
|
||||
|
@ -219,11 +219,7 @@ int addr_port_lookup(int severity, const char *addrport, char **address,
|
||||
uint32_t *addr, uint16_t *port_out);
|
||||
int parse_port_range(const char *port, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out);
|
||||
int parse_addr_and_port_range(const char *s, uint32_t *addr_out,
|
||||
maskbits_t *maskbits_out, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out);
|
||||
int addr_mask_get_bits(uint32_t mask);
|
||||
int addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits);
|
||||
/** Length of a buffer to allocate to hold the results of tor_inet_ntoa.*/
|
||||
#define INET_NTOA_BUF_LEN 16
|
||||
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len);
|
||||
|
@ -675,11 +675,6 @@ median_int32(int32_t *array, int n_elements)
|
||||
{
|
||||
return find_nth_int32(array, n_elements, (n_elements-1)/2);
|
||||
}
|
||||
static INLINE long
|
||||
median_long(long *array, int n_elements)
|
||||
{
|
||||
return find_nth_long(array, n_elements, (n_elements-1)/2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -113,8 +113,8 @@ crypto_get_rsa_padding_overhead(int padding)
|
||||
{
|
||||
switch (padding)
|
||||
{
|
||||
case RSA_PKCS1_OAEP_PADDING: return 42;
|
||||
case RSA_PKCS1_PADDING: return 11;
|
||||
case RSA_PKCS1_OAEP_PADDING: return PKCS1_OAEP_PADDING_OVERHEAD;
|
||||
case RSA_PKCS1_PADDING: return PKCS1_PADDING_OVERHEAD;
|
||||
default: tor_assert(0); return -1;
|
||||
}
|
||||
}
|
||||
@ -1294,23 +1294,6 @@ crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Return true iff <b>s</b> is in the correct format for a fingerprint.
|
||||
*/
|
||||
int
|
||||
crypto_pk_check_fingerprint_syntax(const char *s)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < FINGERPRINT_LEN; ++i) {
|
||||
if ((i%5) == 4) {
|
||||
if (!TOR_ISSPACE(s[i])) return 0;
|
||||
} else {
|
||||
if (!TOR_ISXDIGIT(s[i])) return 0;
|
||||
}
|
||||
}
|
||||
if (s[FINGERPRINT_LEN]) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* symmetric crypto */
|
||||
|
||||
/** Return a pointer to the key set for the cipher in <b>env</b>.
|
||||
|
@ -183,7 +183,6 @@ crypto_pk_t *crypto_pk_asn1_decode(const char *str, size_t len);
|
||||
int crypto_pk_get_digest(crypto_pk_t *pk, char *digest_out);
|
||||
int crypto_pk_get_all_digests(crypto_pk_t *pk, digests_t *digests_out);
|
||||
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out,int add_space);
|
||||
int crypto_pk_check_fingerprint_syntax(const char *s);
|
||||
|
||||
/* symmetric crypto */
|
||||
const char *crypto_cipher_get_key(crypto_cipher_t *env);
|
||||
|
@ -1176,119 +1176,10 @@ escaped(const char *s)
|
||||
return escaped_val_;
|
||||
}
|
||||
|
||||
/** Rudimentary string wrapping code: given a un-wrapped <b>string</b> (no
|
||||
* newlines!), break the string into newline-terminated lines of no more than
|
||||
* <b>width</b> characters long (not counting newline) and insert them into
|
||||
* <b>out</b> in order. Precede the first line with prefix0, and subsequent
|
||||
* lines with prefixRest.
|
||||
*/
|
||||
/* This uses a stupid greedy wrapping algorithm right now:
|
||||
* - For each line:
|
||||
* - Try to fit as much stuff as possible, but break on a space.
|
||||
* - If the first "word" of the line will extend beyond the allowable
|
||||
* width, break the word at the end of the width.
|
||||
*/
|
||||
void
|
||||
wrap_string(smartlist_t *out, const char *string, size_t width,
|
||||
const char *prefix0, const char *prefixRest)
|
||||
{
|
||||
size_t p0Len, pRestLen, pCurLen;
|
||||
const char *eos, *prefixCur;
|
||||
tor_assert(out);
|
||||
tor_assert(string);
|
||||
tor_assert(width);
|
||||
if (!prefix0)
|
||||
prefix0 = "";
|
||||
if (!prefixRest)
|
||||
prefixRest = "";
|
||||
|
||||
p0Len = strlen(prefix0);
|
||||
pRestLen = strlen(prefixRest);
|
||||
tor_assert(width > p0Len && width > pRestLen);
|
||||
eos = strchr(string, '\0');
|
||||
tor_assert(eos);
|
||||
pCurLen = p0Len;
|
||||
prefixCur = prefix0;
|
||||
|
||||
while ((eos-string)+pCurLen > width) {
|
||||
const char *eol = string + width - pCurLen;
|
||||
while (eol > string && *eol != ' ')
|
||||
--eol;
|
||||
/* eol is now the last space that can fit, or the start of the string. */
|
||||
if (eol > string) {
|
||||
size_t line_len = (eol-string) + pCurLen + 2;
|
||||
char *line = tor_malloc(line_len);
|
||||
memcpy(line, prefixCur, pCurLen);
|
||||
memcpy(line+pCurLen, string, eol-string);
|
||||
line[line_len-2] = '\n';
|
||||
line[line_len-1] = '\0';
|
||||
smartlist_add(out, line);
|
||||
string = eol + 1;
|
||||
} else {
|
||||
size_t line_len = width + 2;
|
||||
char *line = tor_malloc(line_len);
|
||||
memcpy(line, prefixCur, pCurLen);
|
||||
memcpy(line+pCurLen, string, width - pCurLen);
|
||||
line[line_len-2] = '\n';
|
||||
line[line_len-1] = '\0';
|
||||
smartlist_add(out, line);
|
||||
string += width-pCurLen;
|
||||
}
|
||||
prefixCur = prefixRest;
|
||||
pCurLen = pRestLen;
|
||||
}
|
||||
|
||||
if (string < eos) {
|
||||
size_t line_len = (eos-string) + pCurLen + 2;
|
||||
char *line = tor_malloc(line_len);
|
||||
memcpy(line, prefixCur, pCurLen);
|
||||
memcpy(line+pCurLen, string, eos-string);
|
||||
line[line_len-2] = '\n';
|
||||
line[line_len-1] = '\0';
|
||||
smartlist_add(out, line);
|
||||
}
|
||||
}
|
||||
|
||||
/* =====
|
||||
* Time
|
||||
* ===== */
|
||||
|
||||
/**
|
||||
* Converts struct timeval to a double value.
|
||||
* Preserves microsecond precision, but just barely.
|
||||
* Error is approx +/- 0.1 usec when dealing with epoch values.
|
||||
*/
|
||||
double
|
||||
tv_to_double(const struct timeval *tv)
|
||||
{
|
||||
double conv = tv->tv_sec;
|
||||
conv += tv->tv_usec/1000000.0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts timeval to milliseconds.
|
||||
*/
|
||||
int64_t
|
||||
tv_to_msec(const struct timeval *tv)
|
||||
{
|
||||
int64_t conv = ((int64_t)tv->tv_sec)*1000L;
|
||||
/* Round ghetto-style */
|
||||
conv += ((int64_t)tv->tv_usec+500)/1000L;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts timeval to microseconds.
|
||||
*/
|
||||
int64_t
|
||||
tv_to_usec(const struct timeval *tv)
|
||||
{
|
||||
int64_t conv = ((int64_t)tv->tv_sec)*1000000L;
|
||||
conv += tv->tv_usec;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/** Return the number of microseconds elapsed between *start and *end.
|
||||
*/
|
||||
long
|
||||
|
@ -112,7 +112,6 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
|
||||
#define tor_malloc(size) tor_malloc_(size DMALLOC_ARGS)
|
||||
#define tor_malloc_zero(size) tor_malloc_zero_(size DMALLOC_ARGS)
|
||||
#define tor_calloc(nmemb,size) tor_calloc_(nmemb, size DMALLOC_ARGS)
|
||||
#define tor_malloc_roundup(szp) _tor_malloc_roundup(szp DMALLOC_ARGS)
|
||||
#define tor_realloc(ptr, size) tor_realloc_(ptr, size DMALLOC_ARGS)
|
||||
#define tor_strdup(s) tor_strdup_(s DMALLOC_ARGS)
|
||||
#define tor_strndup(s, n) tor_strndup_(s, n DMALLOC_ARGS)
|
||||
@ -216,8 +215,6 @@ int tor_digest256_is_zero(const char *digest);
|
||||
char *esc_for_log(const char *string) ATTR_MALLOC;
|
||||
const char *escaped(const char *string);
|
||||
struct smartlist_t;
|
||||
void wrap_string(struct smartlist_t *out, const char *string, size_t width,
|
||||
const char *prefix0, const char *prefixRest);
|
||||
int tor_vsscanf(const char *buf, const char *pattern, va_list ap)
|
||||
#ifdef __GNUC__
|
||||
__attribute__((format(scanf, 2, 0)))
|
||||
@ -240,9 +237,6 @@ void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||
|
||||
/* Time helpers */
|
||||
double tv_to_double(const struct timeval *tv);
|
||||
int64_t tv_to_msec(const struct timeval *tv);
|
||||
int64_t tv_to_usec(const struct timeval *tv);
|
||||
long tv_udiff(const struct timeval *start, const struct timeval *end);
|
||||
long tv_mdiff(const struct timeval *start, const struct timeval *end);
|
||||
int tor_timegm(const struct tm *tm, time_t *time_out);
|
||||
|
@ -76,7 +76,6 @@ int directory_fetches_from_authorities(const or_options_t *options);
|
||||
int directory_fetches_dir_info_early(const or_options_t *options);
|
||||
int directory_fetches_dir_info_later(const or_options_t *options);
|
||||
int directory_caches_v2_dir_info(const or_options_t *options);
|
||||
#define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o)
|
||||
int directory_caches_unknown_auth_certs(const or_options_t *options);
|
||||
int directory_caches_dir_info(const or_options_t *options);
|
||||
int directory_permits_begindir_requests(const or_options_t *options);
|
||||
|
@ -506,10 +506,6 @@ accounting_run_housekeeping(time_t now)
|
||||
}
|
||||
}
|
||||
|
||||
/** When we have no idea how fast we are, how long do we assume it will take
|
||||
* us to exhaust our bandwidth? */
|
||||
#define GUESS_TIME_TO_USE_BANDWIDTH (24*60*60)
|
||||
|
||||
/** Based on our interval and our estimated bandwidth, choose a
|
||||
* deterministic (but random-ish) time to wake up. */
|
||||
static void
|
||||
|
@ -158,10 +158,6 @@ int can_complete_circuit=0;
|
||||
/** How long do we let a directory connection stall before expiring it? */
|
||||
#define DIR_CONN_MAX_STALL (5*60)
|
||||
|
||||
/** How long do we let OR connections handshake before we decide that
|
||||
* they are obsolete? */
|
||||
#define TLS_HANDSHAKE_TIMEOUT (60)
|
||||
|
||||
/** Decides our behavior when no logs are configured/before any
|
||||
* logs have been configured. For 0, we log notice to stdout as normal.
|
||||
* For 1, we log warnings only. For 2, we log nothing.
|
||||
|
@ -1432,18 +1432,6 @@ consensus_is_waiting_for_certs(void)
|
||||
? 1 : 0;
|
||||
}
|
||||
|
||||
/** Return the network status with a given identity digest. */
|
||||
networkstatus_v2_t *
|
||||
networkstatus_v2_get_by_digest(const char *digest)
|
||||
{
|
||||
SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
|
||||
{
|
||||
if (tor_memeq(ns->identity_digest, digest, DIGEST_LEN))
|
||||
return ns;
|
||||
});
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return the most recent consensus that we have downloaded, or NULL if we
|
||||
* don't have one. */
|
||||
networkstatus_t *
|
||||
|
@ -75,7 +75,6 @@ void update_certificate_downloads(time_t now);
|
||||
int consensus_is_waiting_for_certs(void);
|
||||
int client_would_use_router(const routerstatus_t *rs, time_t now,
|
||||
const or_options_t *options);
|
||||
networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
|
||||
networkstatus_t *networkstatus_get_latest_consensus(void);
|
||||
networkstatus_t *networkstatus_get_latest_consensus_by_flavor(
|
||||
consensus_flavor_t f);
|
||||
|
@ -4465,15 +4465,6 @@ typedef struct vote_timing_t {
|
||||
|
||||
/********************************* geoip.c **************************/
|
||||
|
||||
/** Round all GeoIP results to the next multiple of this value, to avoid
|
||||
* leaking information. */
|
||||
#define DIR_RECORD_USAGE_GRANULARITY 8
|
||||
/** Time interval: Flush geoip data to disk this often. */
|
||||
#define DIR_ENTRY_RECORD_USAGE_RETAIN_IPS (24*60*60)
|
||||
/** How long do we have to have observed per-country request history before
|
||||
* we are willing to talk about it? */
|
||||
#define DIR_RECORD_USAGE_MIN_OBSERVATION_TIME (12*60*60)
|
||||
|
||||
/** Indicates an action that we might be noting geoip statistics on.
|
||||
* Note that if we're noticing CONNECT, we're a bridge, and if we're noticing
|
||||
* the others, we're not.
|
||||
|
@ -1452,13 +1452,6 @@ rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
|
||||
command);
|
||||
}
|
||||
|
||||
/** Return the number of entries in our rendezvous descriptor cache. */
|
||||
int
|
||||
rend_cache_size(void)
|
||||
{
|
||||
return strmap_size(rend_cache);
|
||||
}
|
||||
|
||||
/** Allocate and return a new rend_data_t with the same
|
||||
* contents as <b>query</b>. */
|
||||
rend_data_t *
|
||||
|
@ -49,7 +49,6 @@ int rend_cache_store(const char *desc, size_t desc_len, int published,
|
||||
int rend_cache_store_v2_desc_as_client(const char *desc,
|
||||
const rend_data_t *rend_query);
|
||||
int rend_cache_store_v2_desc_as_dir(const char *desc);
|
||||
int rend_cache_size(void);
|
||||
int rend_encode_v2_descriptors(smartlist_t *descs_out,
|
||||
rend_service_descriptor_t *desc, time_t now,
|
||||
uint8_t period, rend_auth_type_t auth_type,
|
||||
|
@ -2983,23 +2983,6 @@ router_get_verbose_nickname(char *buf, const routerinfo_t *router)
|
||||
strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
|
||||
}
|
||||
|
||||
/** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
|
||||
* verbose representation of the identity of <b>router</b>. The format is:
|
||||
* A dollar sign.
|
||||
* The upper-case hexadecimal encoding of the SHA1 hash of router's identity.
|
||||
* A "=" if the router is named; a "~" if it is not.
|
||||
* The router's nickname.
|
||||
**/
|
||||
void
|
||||
routerstatus_get_verbose_nickname(char *buf, const routerstatus_t *router)
|
||||
{
|
||||
buf[0] = '$';
|
||||
base16_encode(buf+1, HEX_DIGEST_LEN+1, router->identity_digest,
|
||||
DIGEST_LEN);
|
||||
buf[1+HEX_DIGEST_LEN] = router->is_named ? '=' : '~';
|
||||
strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
|
||||
}
|
||||
|
||||
/** Forget that we have issued any router-related warnings, so that we'll
|
||||
* warn again if we see the same errors. */
|
||||
void
|
||||
|
@ -132,8 +132,6 @@ const char *routerstatus_describe(const routerstatus_t *ri);
|
||||
const char *extend_info_describe(const extend_info_t *ei);
|
||||
|
||||
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
|
||||
void routerstatus_get_verbose_nickname(char *buf,
|
||||
const routerstatus_t *router);
|
||||
void router_reset_warnings(void);
|
||||
void router_reset_reachability(void);
|
||||
void router_free_all(void);
|
||||
|
@ -54,8 +54,6 @@ static const routerstatus_t *router_pick_dirserver_generic(
|
||||
smartlist_t *sourcelist,
|
||||
dirinfo_type_t type, int flags);
|
||||
static void mark_all_dirservers_up(smartlist_t *server_list);
|
||||
static int router_nickname_matches(const routerinfo_t *router,
|
||||
const char *nickname);
|
||||
static void dir_server_free(dir_server_t *ds);
|
||||
static int signed_desc_digest_is_recognized(signed_descriptor_t *desc);
|
||||
static const char *signed_descriptor_get_body_impl(
|
||||
@ -339,7 +337,6 @@ trusted_dirs_remove_old_certs(void)
|
||||
time_t now = time(NULL);
|
||||
#define DEAD_CERT_LIFETIME (2*24*60*60)
|
||||
#define OLD_CERT_LIFETIME (7*24*60*60)
|
||||
#define CERT_EXPIRY_SKEW (60*60)
|
||||
if (!trusted_dir_certs)
|
||||
return;
|
||||
|
||||
@ -1462,30 +1459,6 @@ routerlist_add_node_and_family(smartlist_t *sl, const routerinfo_t *router)
|
||||
nodelist_add_node_and_family(sl, node);
|
||||
}
|
||||
|
||||
/** Return 1 iff any member of the (possibly NULL) comma-separated list
|
||||
* <b>list</b> is an acceptable nickname or hexdigest for <b>router</b>. Else
|
||||
* return 0.
|
||||
*/
|
||||
int
|
||||
router_nickname_is_in_list(const routerinfo_t *router, const char *list)
|
||||
{
|
||||
smartlist_t *nickname_list;
|
||||
int v = 0;
|
||||
|
||||
if (!list)
|
||||
return 0; /* definitely not */
|
||||
tor_assert(router);
|
||||
|
||||
nickname_list = smartlist_new();
|
||||
smartlist_split_string(nickname_list, list, ",",
|
||||
SPLIT_SKIP_SPACE|SPLIT_STRIP_SPACE|SPLIT_IGNORE_BLANK, 0);
|
||||
SMARTLIST_FOREACH(nickname_list, const char *, cp,
|
||||
if (router_nickname_matches(router, cp)) {v=1;break;});
|
||||
SMARTLIST_FOREACH(nickname_list, char *, cp, tor_free(cp));
|
||||
smartlist_free(nickname_list);
|
||||
return v;
|
||||
}
|
||||
|
||||
/** Add every suitable node from our nodelist to <b>sl</b>, so that
|
||||
* we can pick a node for a circuit.
|
||||
*/
|
||||
@ -2312,18 +2285,6 @@ router_hex_digest_matches(const routerinfo_t *router, const char *hexdigest)
|
||||
router_is_named(router));
|
||||
}
|
||||
|
||||
/** Return true if <b>router</b>'s nickname matches <b>nickname</b>
|
||||
* (case-insensitive), or if <b>router's</b> identity key digest
|
||||
* matches a hexadecimal value stored in <b>nickname</b>. Return
|
||||
* false otherwise. */
|
||||
static int
|
||||
router_nickname_matches(const routerinfo_t *router, const char *nickname)
|
||||
{
|
||||
if (nickname[0]!='$' && !strcasecmp(router->nickname, nickname))
|
||||
return 1;
|
||||
return router_hex_digest_matches(router, nickname);
|
||||
}
|
||||
|
||||
/** Return true iff <b>digest</b> is the digest of the identity key of a
|
||||
* trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
|
||||
* is zero, any authority is okay. */
|
||||
@ -4052,17 +4013,6 @@ clear_dir_servers(void)
|
||||
router_dir_info_changed();
|
||||
}
|
||||
|
||||
/** Return 1 if any trusted dir server supports v1 directories,
|
||||
* else return 0. */
|
||||
int
|
||||
any_trusted_dir_is_v1_authority(void)
|
||||
{
|
||||
if (trusted_dir_servers)
|
||||
return get_n_authorities(V1_DIRINFO) > 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** For every current directory connection whose purpose is <b>purpose</b>,
|
||||
* and where the resource being downloaded begins with <b>prefix</b>, split
|
||||
* rest of the resource into base16 fingerprints (or base64 fingerprints if
|
||||
|
@ -42,7 +42,6 @@ int router_get_my_share_of_directory_requests(double *v2_share_out,
|
||||
double *v3_share_out);
|
||||
void router_reset_status_download_failures(void);
|
||||
int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2);
|
||||
int router_nickname_is_in_list(const routerinfo_t *router, const char *list);
|
||||
const routerinfo_t *routerlist_find_my_routerinfo(void);
|
||||
uint32_t router_get_advertised_bandwidth(const routerinfo_t *router);
|
||||
uint32_t router_get_advertised_bandwidth_capped(const routerinfo_t *router);
|
||||
@ -146,7 +145,6 @@ void dir_server_add(dir_server_t *ent);
|
||||
|
||||
void authority_cert_free(authority_cert_t *cert);
|
||||
void clear_dir_servers(void);
|
||||
int any_trusted_dir_is_v1_authority(void);
|
||||
void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
||||
networkstatus_t *consensus);
|
||||
void update_router_descriptor_downloads(time_t now);
|
||||
|
@ -124,10 +124,6 @@ static INLINE void free_execve_args(char **arg);
|
||||
#define PROTO_CMETHODS_DONE "CMETHODS DONE"
|
||||
#define PROTO_SMETHODS_DONE "SMETHODS DONE"
|
||||
|
||||
/** Number of environment variables for managed proxy clients/servers. */
|
||||
#define ENVIRON_SIZE_CLIENT 3
|
||||
#define ENVIRON_SIZE_SERVER 7 /* XXX known to be too high, but that's ok */
|
||||
|
||||
/** The first and only supported - at the moment - configuration
|
||||
protocol version. */
|
||||
#define PROTO_VERSION_ONE 1
|
||||
|
@ -1979,11 +1979,6 @@ const struct testcase_setup_t legacy_setup = {
|
||||
|
||||
#define ENT(name) \
|
||||
{ #name, legacy_test_helper, 0, &legacy_setup, test_ ## name }
|
||||
#define SUBENT(group, name) \
|
||||
{ #group "_" #name, legacy_test_helper, 0, &legacy_setup, \
|
||||
test_ ## group ## _ ## name }
|
||||
#define DISABLED(name) \
|
||||
{ #name, legacy_test_helper, TT_SKIP, &legacy_setup, test_ ## name }
|
||||
#define FORK(name) \
|
||||
{ #name, legacy_test_helper, TT_FORK, &legacy_setup, test_ ## name }
|
||||
|
||||
|
@ -636,22 +636,6 @@ test_crypto_formats(void)
|
||||
tor_free(data2);
|
||||
}
|
||||
|
||||
/* Check fingerprint */
|
||||
{
|
||||
test_assert(crypto_pk_check_fingerprint_syntax(
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 0000"));
|
||||
test_assert(!crypto_pk_check_fingerprint_syntax(
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 000"));
|
||||
test_assert(!crypto_pk_check_fingerprint_syntax(
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 00000"));
|
||||
test_assert(!crypto_pk_check_fingerprint_syntax(
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD1234 ABCD 5678 0000"));
|
||||
test_assert(!crypto_pk_check_fingerprint_syntax(
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD1234 ABCD 5678 00000"));
|
||||
test_assert(!crypto_pk_check_fingerprint_syntax(
|
||||
"ACD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 00000"));
|
||||
}
|
||||
|
||||
done:
|
||||
tor_free(data1);
|
||||
tor_free(data2);
|
||||
|
@ -407,10 +407,8 @@ test_dir_split_fps(void *testdata)
|
||||
"0123456789ABCdef0123456789ABCdef0123456789ABCdef0123456789ABCdef"
|
||||
#define B64_1 "/g2v+JEnOJvGdVhpEjEjRVEZPu4"
|
||||
#define B64_2 "3q2+75mZmZERERmZmRERERHwC6Q"
|
||||
#define B64_3 "sz/wDbM/8A2zP/ANsz/wDbM/8A0"
|
||||
#define B64_256_1 "8/Pz8/u7vz8/Pz+7vz8/Pz+7u/Pz8/P7u/Pz8/P7u78"
|
||||
#define B64_256_2 "zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMw"
|
||||
#define B64_256_3 "ASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8"
|
||||
|
||||
/* no flags set */
|
||||
dir_split_resource_into_fingerprints("A+C+B", sl, NULL, 0);
|
||||
|
@ -1054,79 +1054,6 @@ test_util_strmisc(void)
|
||||
test_assert(!tor_memstr(haystack, 7, "ababcade"));
|
||||
}
|
||||
|
||||
/* Test wrap_string */
|
||||
{
|
||||
smartlist_t *sl = smartlist_new();
|
||||
wrap_string(sl,
|
||||
"This is a test of string wrapping functionality: woot. "
|
||||
"a functionality? w00t w00t...!",
|
||||
10, "", "");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp,
|
||||
"This is a\ntest of\nstring\nwrapping\nfunctional\nity: woot.\n"
|
||||
"a\nfunctional\nity? w00t\nw00t...!\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "This is a test of string wrapping functionality: woot.",
|
||||
16, "### ", "# ");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp,
|
||||
"### This is a\n# test of string\n# wrapping\n# functionality:\n"
|
||||
"# woot.\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "A test of string wrapping...", 6, "### ", "# ");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp,
|
||||
"### A\n# test\n# of\n# stri\n# ng\n# wrap\n# ping\n# ...\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "Wrapping test", 6, "#### ", "# ");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp, "#### W\n# rapp\n# ing\n# test\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "Small test", 6, "### ", "#### ");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp, "### Sm\n#### a\n#### l\n#### l\n#### t\n#### e"
|
||||
"\n#### s\n#### t\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "First null", 6, NULL, "> ");
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp, "First\n> null\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "Second null", 6, "> ", NULL);
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp, "> Seco\nnd\nnull\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_clear(sl);
|
||||
|
||||
wrap_string(sl, "Both null", 6, NULL, NULL);
|
||||
cp = smartlist_join_strings(sl, "", 0, NULL);
|
||||
test_streq(cp, "Both\nnull\n");
|
||||
tor_free(cp);
|
||||
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
||||
smartlist_free(sl);
|
||||
|
||||
/* Can't test prefixes that have the same length as the line width, because
|
||||
the function has an assert */
|
||||
}
|
||||
|
||||
/* Test hex_str */
|
||||
{
|
||||
char binary_data[68];
|
||||
|
Loading…
Reference in New Issue
Block a user