mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Merge branch 'master' of https://git.torproject.org/tor into bug13111-empty-key-files-fn-empty
Conflicts: src/or/connection_edge.c Merged in favour of origin.
This commit is contained in:
+10
-8
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -89,13 +89,14 @@ tor_addr_to_sockaddr(const tor_addr_t *a,
|
||||
struct sockaddr *sa_out,
|
||||
socklen_t len)
|
||||
{
|
||||
memset(sa_out, 0, len);
|
||||
|
||||
sa_family_t family = tor_addr_family(a);
|
||||
if (family == AF_INET) {
|
||||
struct sockaddr_in *sin;
|
||||
if (len < (int)sizeof(struct sockaddr_in))
|
||||
return 0;
|
||||
sin = (struct sockaddr_in *)sa_out;
|
||||
memset(sin, 0, sizeof(struct sockaddr_in));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
||||
sin->sin_len = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
@@ -108,7 +109,6 @@ tor_addr_to_sockaddr(const tor_addr_t *a,
|
||||
if (len < (int)sizeof(struct sockaddr_in6))
|
||||
return 0;
|
||||
sin6 = (struct sockaddr_in6 *)sa_out;
|
||||
memset(sin6, 0, sizeof(struct sockaddr_in6));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
@@ -129,6 +129,9 @@ tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa,
|
||||
{
|
||||
tor_assert(a);
|
||||
tor_assert(sa);
|
||||
|
||||
memset(a, 0, sizeof(*a));
|
||||
|
||||
if (sa->sa_family == AF_INET) {
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *) sa;
|
||||
tor_addr_from_ipv4n(a, sin->sin_addr.s_addr);
|
||||
@@ -1023,7 +1026,6 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
|
||||
} else {
|
||||
a2 = tor_addr_to_ipv4h(addr2);
|
||||
}
|
||||
if (mbits <= 0) return 0;
|
||||
if (mbits > 32) mbits = 32;
|
||||
a1 >>= (32-mbits);
|
||||
a2 >>= (32-mbits);
|
||||
@@ -1369,8 +1371,8 @@ tor_addr_is_multicast(const tor_addr_t *a)
|
||||
* connects to the Internet. This address should only be used in checking
|
||||
* whether our address has changed. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr)
|
||||
MOCK_IMPL(int,
|
||||
get_interface_address6,(int severity, sa_family_t family, tor_addr_t *addr))
|
||||
{
|
||||
/* XXX really, this function should yield a smartlist of addresses. */
|
||||
smartlist_t *addrs;
|
||||
@@ -1699,8 +1701,8 @@ tor_dup_ip(uint32_t addr)
|
||||
* checking whether our address has changed. Return 0 on success, -1 on
|
||||
* failure.
|
||||
*/
|
||||
int
|
||||
get_interface_address(int severity, uint32_t *addr)
|
||||
MOCK_IMPL(int,
|
||||
get_interface_address,(int severity, uint32_t *addr))
|
||||
{
|
||||
tor_addr_t local_addr;
|
||||
int r;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,8 @@ char *tor_dup_addr(const tor_addr_t *addr) ATTR_MALLOC;
|
||||
const char *fmt_addr_impl(const tor_addr_t *addr, int decorate);
|
||||
const char *fmt_addrport(const tor_addr_t *addr, uint16_t port);
|
||||
const char * fmt_addr32(uint32_t addr);
|
||||
int get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr);
|
||||
MOCK_DECL(int,get_interface_address6,(int severity, sa_family_t family,
|
||||
tor_addr_t *addr));
|
||||
|
||||
/** Flag to specify how to do a comparison between addresses. In an "exact"
|
||||
* comparison, addresses are equivalent only if they are in the same family
|
||||
@@ -236,7 +237,7 @@ int addr_mask_get_bits(uint32_t mask);
|
||||
#define INET_NTOA_BUF_LEN 16
|
||||
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len);
|
||||
char *tor_dup_ip(uint32_t addr) ATTR_MALLOC;
|
||||
int get_interface_address(int severity, uint32_t *addr);
|
||||
MOCK_DECL(int,get_interface_address,(int severity, uint32_t *addr));
|
||||
|
||||
tor_addr_port_t *tor_addr_port_new(const tor_addr_t *addr, uint16_t port);
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/* Implements a minimal interface to counter-mode AES. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2013-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define __USE_GNU
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2013-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_BACKTRACE_H
|
||||
|
||||
+18
-6
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -2198,9 +2198,20 @@ get_environment(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Set *addr to the IP address (in dotted-quad notation) stored in c.
|
||||
* Return 1 on success, 0 if c is badly formatted. (Like inet_aton(c,addr),
|
||||
* but works on Windows and Solaris.)
|
||||
/** Get name of current host and write it to <b>name</b> array, whose
|
||||
* length is specified by <b>namelen</b> argument. Return 0 upon
|
||||
* successfull completion; otherwise return return -1. (Currently,
|
||||
* this function is merely a mockable wrapper for POSIX gethostname().)
|
||||
*/
|
||||
MOCK_IMPL(int,
|
||||
tor_gethostname,(char *name, size_t namelen))
|
||||
{
|
||||
return gethostname(name,namelen);
|
||||
}
|
||||
|
||||
/** Set *addr to the IP address (in dotted-quad notation) stored in *str.
|
||||
* Return 1 on success, 0 if *str is badly formatted.
|
||||
* (Like inet_aton(str,addr), but works on Windows and Solaris.)
|
||||
*/
|
||||
int
|
||||
tor_inet_aton(const char *str, struct in_addr* addr)
|
||||
@@ -2420,8 +2431,9 @@ tor_inet_pton(int af, const char *src, void *dst)
|
||||
* (This function exists because standard windows gethostbyname
|
||||
* doesn't treat raw IP addresses properly.)
|
||||
*/
|
||||
int
|
||||
tor_lookup_hostname(const char *name, uint32_t *addr)
|
||||
|
||||
MOCK_IMPL(int,
|
||||
tor_lookup_hostname,(const char *name, uint32_t *addr))
|
||||
{
|
||||
tor_addr_t myaddr;
|
||||
int ret;
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_COMPAT_H
|
||||
@@ -532,10 +532,11 @@ struct sockaddr_in6 {
|
||||
};
|
||||
#endif
|
||||
|
||||
MOCK_DECL(int,tor_gethostname,(char *name, size_t namelen));
|
||||
int tor_inet_aton(const char *cp, struct in_addr *addr) ATTR_NONNULL((1,2));
|
||||
const char *tor_inet_ntop(int af, const void *src, char *dst, size_t len);
|
||||
int tor_inet_pton(int af, const char *src, void *dst);
|
||||
int tor_lookup_hostname(const char *name, uint32_t *addr) ATTR_NONNULL((1,2));
|
||||
MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));
|
||||
int set_socket_nonblocking(tor_socket_t socket);
|
||||
int tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]);
|
||||
int network_init(void);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2009-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -146,13 +146,25 @@ tor_evsignal_new(struct event_base * base, int sig,
|
||||
{
|
||||
return tor_event_new(base, sig, EV_SIGNAL|EV_PERSIST, cb, arg);
|
||||
}
|
||||
/** Work-alike replacement for event_free() on pre-Libevent-2.0 systems. */
|
||||
/** Work-alike replacement for event_free() on pre-Libevent-2.0 systems,
|
||||
* except tolerate tor_event_free(NULL). */
|
||||
void
|
||||
tor_event_free(struct event *ev)
|
||||
{
|
||||
if (ev == NULL)
|
||||
return;
|
||||
event_del(ev);
|
||||
tor_free(ev);
|
||||
}
|
||||
#else
|
||||
/* Wrapper for event_free() that tolerates tor_event_free(NULL) */
|
||||
void
|
||||
tor_event_free(struct event *ev)
|
||||
{
|
||||
if (ev == NULL)
|
||||
return;
|
||||
event_free(ev);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Global event base for use by the main thread. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2009-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_COMPAT_LIBEVENT_H
|
||||
@@ -28,11 +28,9 @@ void suppress_libevent_log_msg(const char *msg);
|
||||
#define tor_event_new event_new
|
||||
#define tor_evtimer_new evtimer_new
|
||||
#define tor_evsignal_new evsignal_new
|
||||
#define tor_event_free event_free
|
||||
#define tor_evdns_add_server_port(sock, tcp, cb, data) \
|
||||
evdns_add_server_port_with_base(tor_libevent_get_base(), \
|
||||
(sock),(tcp),(cb),(data));
|
||||
|
||||
#else
|
||||
struct event *tor_event_new(struct event_base * base, evutil_socket_t sock,
|
||||
short what, void (*cb)(evutil_socket_t, short, void *), void *arg);
|
||||
@@ -40,10 +38,11 @@ struct event *tor_evtimer_new(struct event_base * base,
|
||||
void (*cb)(evutil_socket_t, short, void *), void *arg);
|
||||
struct event *tor_evsignal_new(struct event_base * base, int sig,
|
||||
void (*cb)(evutil_socket_t, short, void *), void *arg);
|
||||
void tor_event_free(struct event *ev);
|
||||
#define tor_evdns_add_server_port evdns_add_server_port
|
||||
#endif
|
||||
|
||||
void tor_event_free(struct event *ev);
|
||||
|
||||
typedef struct periodic_timer_t periodic_timer_t;
|
||||
|
||||
periodic_timer_t *periodic_timer_new(struct event_base *base,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_CONTAINER_H
|
||||
|
||||
+8
-2
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1293,7 +1293,7 @@ crypto_pk_asn1_decode(const char *str, size_t len)
|
||||
* Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
crypto_pk_get_digest(crypto_pk_t *pk, char *digest_out)
|
||||
crypto_pk_get_digest(const crypto_pk_t *pk, char *digest_out)
|
||||
{
|
||||
unsigned char *buf = NULL;
|
||||
int len;
|
||||
@@ -2752,6 +2752,8 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
|
||||
if (destlen > SIZE_T_CEILING)
|
||||
return -1;
|
||||
|
||||
memset(dest, 0, destlen);
|
||||
|
||||
EVP_DecodeInit(&ctx);
|
||||
EVP_DecodeUpdate(&ctx, (unsigned char*)dest, &len,
|
||||
(unsigned char*)src, srclen);
|
||||
@@ -2773,6 +2775,8 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
|
||||
if (destlen > SIZE_T_CEILING)
|
||||
return -1;
|
||||
|
||||
memset(dest, 0, destlen);
|
||||
|
||||
/* Iterate over all the bytes in src. Each one will add 0 or 6 bits to the
|
||||
* value we're decoding. Accumulate bits in <b>n</b>, and whenever we have
|
||||
* 24 bits, batch them into 3 bytes and flush those bytes to dest.
|
||||
@@ -2952,6 +2956,8 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
|
||||
tor_assert((nbits/8) <= destlen); /* We need enough space. */
|
||||
tor_assert(destlen < SIZE_T_CEILING);
|
||||
|
||||
memset(dest, 0, destlen);
|
||||
|
||||
/* Convert base32 encoded chars to the 5-bit values that they represent. */
|
||||
tmp = tor_malloc_zero(srclen);
|
||||
for (j = 0; j < srclen; ++j) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_t *env, char *to,
|
||||
|
||||
int crypto_pk_asn1_encode(crypto_pk_t *pk, char *dest, size_t dest_len);
|
||||
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_digest(const 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_get_hashed_fingerprint(crypto_pk_t *pk, char *fp_out);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/* Wrapper code for a curve25519 implementation. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_CRYPTO_CURVE25519_H
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2013-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/* Wrapper code for an ed25519 implementation. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_CRYPTO_ED25519_H
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/* Formatting and parsing code for crypto-related data structures. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define CRYPTO_S2K_PRIVATE
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_CRYPTO_S2K_H_INCLUDED
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2011-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2008-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/** \file memarea.c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2008-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
/* Tor dependencies */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
#if 1
|
||||
/* Tor dependencies */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2011-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2011-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+34
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -58,6 +58,16 @@
|
||||
#include <time.h>
|
||||
#include <poll.h>
|
||||
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV4_H
|
||||
#include <linux/netfilter_ipv4.h>
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_IF_H
|
||||
#include <linux/if.h>
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
|
||||
#include <linux/netfilter_ipv6/ip6_tables.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \
|
||||
defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)
|
||||
#define USE_BACKTRACE
|
||||
@@ -634,6 +644,22 @@ sb_getsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV4_H
|
||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
||||
SCMP_CMP(1, SCMP_CMP_EQ, SOL_IP),
|
||||
SCMP_CMP(2, SCMP_CMP_EQ, SO_ORIGINAL_DST));
|
||||
if (rc)
|
||||
return rc;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
|
||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
||||
SCMP_CMP(1, SCMP_CMP_EQ, SOL_IPV6),
|
||||
SCMP_CMP(2, SCMP_CMP_EQ, IP6T_SO_ORIGINAL_DST));
|
||||
if (rc)
|
||||
return rc;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1309,6 +1335,13 @@ sandbox_disable_getaddrinfo_cache(void)
|
||||
sandbox_getaddrinfo_cache_disabled = 1;
|
||||
}
|
||||
|
||||
void
|
||||
sandbox_freeaddrinfo(struct addrinfo *ai)
|
||||
{
|
||||
if (sandbox_getaddrinfo_cache_disabled)
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
int
|
||||
sandbox_getaddrinfo(const char *name, const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ struct addrinfo;
|
||||
int sandbox_getaddrinfo(const char *name, const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res);
|
||||
#define sandbox_freeaddrinfo(addrinfo) ((void)0)
|
||||
void sandbox_freeaddrinfo(struct addrinfo *addrinfo);
|
||||
void sandbox_free_getaddrinfo_cache(void);
|
||||
#else
|
||||
#define sandbox_getaddrinfo(name, servname, hints, res) \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2013-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_TESTSUPPORT_H
|
||||
@@ -20,8 +20,8 @@
|
||||
*
|
||||
* and implement it as:
|
||||
*
|
||||
* MOCK_IMPL(void
|
||||
* writebuf,(size_t n, char *buf)
|
||||
* MOCK_IMPL(void,
|
||||
* writebuf,(size_t n, char *buf))
|
||||
* {
|
||||
* ...
|
||||
* }
|
||||
|
||||
+40
-12
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -92,10 +92,27 @@ tor_zlib_get_header_version_str(void)
|
||||
|
||||
/** Return the 'bits' value to tell zlib to use <b>method</b>.*/
|
||||
static INLINE int
|
||||
method_bits(compress_method_t method)
|
||||
method_bits(compress_method_t method, zlib_compression_level_t level)
|
||||
{
|
||||
/* Bits+16 means "use gzip" in zlib >= 1.2 */
|
||||
return method == GZIP_METHOD ? 15+16 : 15;
|
||||
const int flag = method == GZIP_METHOD ? 16 : 0;
|
||||
switch (level) {
|
||||
default:
|
||||
case HIGH_COMPRESSION: return flag + 15;
|
||||
case MEDIUM_COMPRESSION: return flag + 13;
|
||||
case LOW_COMPRESSION: return flag + 11;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE int
|
||||
get_memlevel(zlib_compression_level_t level)
|
||||
{
|
||||
switch (level) {
|
||||
default:
|
||||
case HIGH_COMPRESSION: return 8;
|
||||
case MEDIUM_COMPRESSION: return 7;
|
||||
case LOW_COMPRESSION: return 6;
|
||||
}
|
||||
}
|
||||
|
||||
/** @{ */
|
||||
@@ -162,8 +179,9 @@ tor_gzip_compress(char **out, size_t *out_len,
|
||||
stream->avail_in = (unsigned int)in_len;
|
||||
|
||||
if (deflateInit2(stream, Z_BEST_COMPRESSION, Z_DEFLATED,
|
||||
method_bits(method),
|
||||
8, Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
method_bits(method, HIGH_COMPRESSION),
|
||||
get_memlevel(HIGH_COMPRESSION),
|
||||
Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
log_warn(LD_GENERAL, "Error from deflateInit2: %s",
|
||||
stream->msg?stream->msg:"<no message>");
|
||||
goto err;
|
||||
@@ -289,7 +307,7 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
||||
stream->avail_in = (unsigned int)in_len;
|
||||
|
||||
if (inflateInit2(stream,
|
||||
method_bits(method)) != Z_OK) {
|
||||
method_bits(method, HIGH_COMPRESSION)) != Z_OK) {
|
||||
log_warn(LD_GENERAL, "Error from inflateInit2: %s",
|
||||
stream->msg?stream->msg:"<no message>");
|
||||
goto err;
|
||||
@@ -315,7 +333,8 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
||||
log_warn(LD_BUG, "Error freeing gzip structures");
|
||||
goto err;
|
||||
}
|
||||
if (inflateInit2(stream, method_bits(method)) != Z_OK) {
|
||||
if (inflateInit2(stream,
|
||||
method_bits(method,HIGH_COMPRESSION)) != Z_OK) {
|
||||
log_warn(LD_GENERAL, "Error from second inflateInit2: %s",
|
||||
stream->msg?stream->msg:"<no message>");
|
||||
goto err;
|
||||
@@ -426,10 +445,11 @@ struct tor_zlib_state_t {
|
||||
* <b>compress</b>, it's for compression; otherwise it's for
|
||||
* decompression. */
|
||||
tor_zlib_state_t *
|
||||
tor_zlib_new(int compress, compress_method_t method)
|
||||
tor_zlib_new(int compress, compress_method_t method,
|
||||
zlib_compression_level_t compression_level)
|
||||
{
|
||||
tor_zlib_state_t *out;
|
||||
int bits;
|
||||
int bits, memlevel;
|
||||
|
||||
if (method == GZIP_METHOD && !is_gzip_supported()) {
|
||||
/* Old zlib version don't support gzip in inflateInit2 */
|
||||
@@ -437,21 +457,29 @@ tor_zlib_new(int compress, compress_method_t method)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (! compress) {
|
||||
/* use this setting for decompression, since we might have the
|
||||
* max number of window bits */
|
||||
compression_level = HIGH_COMPRESSION;
|
||||
}
|
||||
|
||||
out = tor_malloc_zero(sizeof(tor_zlib_state_t));
|
||||
out->stream.zalloc = Z_NULL;
|
||||
out->stream.zfree = Z_NULL;
|
||||
out->stream.opaque = NULL;
|
||||
out->compress = compress;
|
||||
bits = method_bits(method);
|
||||
bits = method_bits(method, compression_level);
|
||||
memlevel = get_memlevel(compression_level);
|
||||
if (compress) {
|
||||
if (deflateInit2(&out->stream, Z_BEST_COMPRESSION, Z_DEFLATED,
|
||||
bits, 8, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
bits, memlevel,
|
||||
Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
goto err;
|
||||
} else {
|
||||
if (inflateInit2(&out->stream, bits) != Z_OK)
|
||||
goto err;
|
||||
}
|
||||
out->allocation = tor_zlib_state_size_precalc(!compress, bits, 8);
|
||||
out->allocation = tor_zlib_state_size_precalc(!compress, bits, memlevel);
|
||||
|
||||
total_zlib_allocation += out->allocation;
|
||||
|
||||
|
||||
+12
-2
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -19,6 +19,15 @@ typedef enum {
|
||||
NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3
|
||||
} compress_method_t;
|
||||
|
||||
/**
|
||||
* Enumeration to define tradeoffs between memory usage and compression level.
|
||||
* HIGH_COMPRESSION saves the most bandwidth; LOW_COMPRESSION saves the most
|
||||
* memory.
|
||||
**/
|
||||
typedef enum {
|
||||
HIGH_COMPRESSION, MEDIUM_COMPRESSION, LOW_COMPRESSION
|
||||
} zlib_compression_level_t;
|
||||
|
||||
int
|
||||
tor_gzip_compress(char **out, size_t *out_len,
|
||||
const char *in, size_t in_len,
|
||||
@@ -47,7 +56,8 @@ typedef enum {
|
||||
} tor_zlib_output_t;
|
||||
/** Internal state for an incremental zlib compression/decompression. */
|
||||
typedef struct tor_zlib_state_t tor_zlib_state_t;
|
||||
tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
|
||||
tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method,
|
||||
zlib_compression_level_t level);
|
||||
|
||||
tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
|
||||
char **out, size_t *out_len,
|
||||
|
||||
+5
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -191,6 +191,10 @@ typedef unsigned __int64 uint64_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT64_MIN
|
||||
#define INT64_MIN ((- INT64_MAX) - 1)
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
#define SIZE_MAX UINT64_MAX
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001, Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_TORTLS_H
|
||||
|
||||
+67
-6
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -513,6 +513,51 @@ round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor)
|
||||
return number;
|
||||
}
|
||||
|
||||
/** Return the lowest x in [INT64_MIN, INT64_MAX] such that x is at least
|
||||
* <b>number</b>, and x modulo <b>divisor</b> == 0. */
|
||||
int64_t
|
||||
round_int64_to_next_multiple_of(int64_t number, int64_t divisor)
|
||||
{
|
||||
tor_assert(divisor > 0);
|
||||
if (number >= 0 && INT64_MAX - divisor + 1 >= number)
|
||||
number += divisor - 1;
|
||||
number -= number % divisor;
|
||||
return number;
|
||||
}
|
||||
|
||||
/** Transform a random value <b>p</b> from the uniform distribution in
|
||||
* [0.0, 1.0[ into a Laplace distributed value with location parameter
|
||||
* <b>mu</b> and scale parameter <b>b</b> in [-Inf, Inf[. */
|
||||
double
|
||||
sample_laplace_distribution(double mu, double b, double p)
|
||||
{
|
||||
tor_assert(p >= 0.0 && p < 1.0);
|
||||
/* This is the "inverse cumulative distribution function" from:
|
||||
* http://en.wikipedia.org/wiki/Laplace_distribution */
|
||||
return mu - b * (p > 0.5 ? 1.0 : -1.0)
|
||||
* tor_mathlog(1.0 - 2.0 * fabs(p - 0.5));
|
||||
}
|
||||
|
||||
/** Add random noise between INT64_MIN and INT64_MAX coming from a
|
||||
* Laplace distribution with mu = 0 and b = <b>delta_f</b>/<b>epsilon</b>
|
||||
* to <b>signal</b> based on the provided <b>random</b> value in
|
||||
* [0.0, 1.0[. */
|
||||
int64_t
|
||||
add_laplace_noise(int64_t signal, double random, double delta_f,
|
||||
double epsilon)
|
||||
{
|
||||
/* cast to int64_t intended */
|
||||
int64_t noise = sample_laplace_distribution(
|
||||
0.0, /* just add noise, no further signal */
|
||||
delta_f / epsilon, random);
|
||||
if (noise > 0 && INT64_MAX - noise < signal)
|
||||
return INT64_MAX;
|
||||
else if (noise < 0 && INT64_MIN - noise > signal)
|
||||
return INT64_MIN;
|
||||
else
|
||||
return signal + noise;
|
||||
}
|
||||
|
||||
/** Return the number of bits set in <b>v</b>. */
|
||||
int
|
||||
n_bits_set_u8(uint8_t v)
|
||||
@@ -1223,6 +1268,9 @@ base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
|
||||
return -1;
|
||||
if (destlen < srclen/2 || destlen > SIZE_T_CEILING)
|
||||
return -1;
|
||||
|
||||
memset(dest, 0, destlen);
|
||||
|
||||
end = src+srclen;
|
||||
while (src<end) {
|
||||
v1 = hex_decode_digit_(*src);
|
||||
@@ -1656,15 +1704,18 @@ format_iso_time_nospace_usec(char *buf, const struct timeval *tv)
|
||||
|
||||
/** Given an ISO-formatted UTC time value (after the epoch) in <b>cp</b>,
|
||||
* parse it and store its value in *<b>t</b>. Return 0 on success, -1 on
|
||||
* failure. Ignore extraneous stuff in <b>cp</b> separated by whitespace from
|
||||
* the end of the time string. */
|
||||
* failure. Ignore extraneous stuff in <b>cp</b> after the end of the time
|
||||
* string, unless <b>strict</b> is set. */
|
||||
int
|
||||
parse_iso_time(const char *cp, time_t *t)
|
||||
parse_iso_time_(const char *cp, time_t *t, int strict)
|
||||
{
|
||||
struct tm st_tm;
|
||||
unsigned int year=0, month=0, day=0, hour=0, minute=0, second=0;
|
||||
if (tor_sscanf(cp, "%u-%2u-%2u %2u:%2u:%2u", &year, &month,
|
||||
&day, &hour, &minute, &second) < 6) {
|
||||
int n_fields;
|
||||
char extra_char;
|
||||
n_fields = tor_sscanf(cp, "%u-%2u-%2u %2u:%2u:%2u%c", &year, &month,
|
||||
&day, &hour, &minute, &second, &extra_char);
|
||||
if (strict ? (n_fields != 6) : (n_fields < 6)) {
|
||||
char *esc = esc_for_log(cp);
|
||||
log_warn(LD_GENERAL, "ISO time %s was unparseable", esc);
|
||||
tor_free(esc);
|
||||
@@ -1693,6 +1744,16 @@ parse_iso_time(const char *cp, time_t *t)
|
||||
return tor_timegm(&st_tm, t);
|
||||
}
|
||||
|
||||
/** Given an ISO-formatted UTC time value (after the epoch) in <b>cp</b>,
|
||||
* parse it and store its value in *<b>t</b>. Return 0 on success, -1 on
|
||||
* failure. Reject the string if any characters are present after the time.
|
||||
*/
|
||||
int
|
||||
parse_iso_time(const char *cp, time_t *t)
|
||||
{
|
||||
return parse_iso_time_(cp, t, 1);
|
||||
}
|
||||
|
||||
/** Given a <b>date</b> in one of the three formats allowed by HTTP (ugh),
|
||||
* parse it into <b>tm</b>. Return 0 on success, negative on failure. */
|
||||
int
|
||||
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -172,6 +172,10 @@ uint64_t round_to_power_of_2(uint64_t u64);
|
||||
unsigned round_to_next_multiple_of(unsigned number, unsigned divisor);
|
||||
uint32_t round_uint32_to_next_multiple_of(uint32_t number, uint32_t divisor);
|
||||
uint64_t round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor);
|
||||
int64_t round_int64_to_next_multiple_of(int64_t number, int64_t divisor);
|
||||
double sample_laplace_distribution(double mu, double b, double p);
|
||||
int64_t add_laplace_noise(int64_t signal, double random, double delta_f,
|
||||
double epsilon);
|
||||
int n_bits_set_u8(uint8_t v);
|
||||
|
||||
/* Compute the CEIL of <b>a</b> divided by <b>b</b>, for nonnegative <b>a</b>
|
||||
@@ -270,6 +274,7 @@ void format_local_iso_time(char *buf, time_t t);
|
||||
void format_iso_time(char *buf, time_t t);
|
||||
void format_iso_time_nospace(char *buf, time_t t);
|
||||
void format_iso_time_nospace_usec(char *buf, const struct timeval *tv);
|
||||
int parse_iso_time_(const char *cp, time_t *t, int strict);
|
||||
int parse_iso_time(const char *buf, time_t *t);
|
||||
int parse_http_time(const char *buf, struct tm *tm);
|
||||
int format_time_interval(char *out, size_t out_len, long interval);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2011-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2002, Christopher Clark.
|
||||
* Copyright (c) 2005-2006, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See license at end. */
|
||||
|
||||
/* Based on ideas by Christopher Clark and interfaces from Niels Provos. */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* trunnel-impl.h -- Implementation helpers for trunnel, included by
|
||||
* generated trunnel files
|
||||
*
|
||||
* Copyright 2014, The Tor Project, Inc.
|
||||
* Copyright 2014-2015, The Tor Project, Inc.
|
||||
* See license at the end of this file for copying information.
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
/* trunnel.c -- Helper functions to implement trunnel.
|
||||
*
|
||||
* Copyright 2014, The Tor Project, Inc.
|
||||
* Copyright 2014-2015, The Tor Project, Inc.
|
||||
* See license at the end of this file for copying information.
|
||||
*
|
||||
* See trunnel-impl.h for documentation of these functions.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* trunnel.h -- Public declarations for trunnel, to be included
|
||||
* in trunnel header files.
|
||||
|
||||
* Copyright 2014, The Tor Project, Inc.
|
||||
* Copyright 2014-2015, The Tor Project, Inc.
|
||||
* See license at the end of this file for copying information.
|
||||
*/
|
||||
|
||||
|
||||
+18
-12
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define ADDRESSMAP_PRIVATE
|
||||
@@ -94,7 +94,7 @@ addressmap_ent_free(void *_ent)
|
||||
tor_free(ent);
|
||||
}
|
||||
|
||||
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b>. */
|
||||
/** Free storage held by a virtaddress_entry_t* entry in <b>_ent</b>. */
|
||||
static void
|
||||
addressmap_virtaddress_ent_free(void *_ent)
|
||||
{
|
||||
@@ -104,11 +104,13 @@ addressmap_virtaddress_ent_free(void *_ent)
|
||||
|
||||
ent = _ent;
|
||||
tor_free(ent->ipv4_address);
|
||||
tor_free(ent->ipv6_address);
|
||||
tor_free(ent->hostname_address);
|
||||
tor_free(ent);
|
||||
}
|
||||
|
||||
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b>. */
|
||||
/** Remove <b>address</b> (which must map to <b>ent</b>) from the
|
||||
* virtual address map. */
|
||||
static void
|
||||
addressmap_virtaddress_remove(const char *address, addressmap_entry_t *ent)
|
||||
{
|
||||
@@ -120,9 +122,11 @@ addressmap_virtaddress_remove(const char *address, addressmap_entry_t *ent)
|
||||
if (ve) {
|
||||
if (!strcmp(address, ve->ipv4_address))
|
||||
tor_free(ve->ipv4_address);
|
||||
if (!strcmp(address, ve->ipv6_address))
|
||||
tor_free(ve->ipv6_address);
|
||||
if (!strcmp(address, ve->hostname_address))
|
||||
tor_free(ve->hostname_address);
|
||||
if (!ve->ipv4_address && !ve->hostname_address) {
|
||||
if (!ve->ipv4_address && !ve->ipv6_address && !ve->hostname_address) {
|
||||
tor_free(ve);
|
||||
strmap_remove(virtaddress_reversemap, ent->new_address);
|
||||
}
|
||||
@@ -131,7 +135,7 @@ addressmap_virtaddress_remove(const char *address, addressmap_entry_t *ent)
|
||||
}
|
||||
|
||||
/** Remove <b>ent</b> (which must be mapped to by <b>address</b>) from the
|
||||
* client address maps. */
|
||||
* client address maps, and then free it. */
|
||||
static void
|
||||
addressmap_ent_remove(const char *address, addressmap_entry_t *ent)
|
||||
{
|
||||
@@ -226,6 +230,8 @@ addressmap_address_should_automap(const char *address,
|
||||
return 0;
|
||||
|
||||
SMARTLIST_FOREACH_BEGIN(suffix_list, const char *, suffix) {
|
||||
if (!strcmp(suffix, "."))
|
||||
return 1;
|
||||
if (!strcasecmpend(address, suffix))
|
||||
return 1;
|
||||
} SMARTLIST_FOREACH_END(suffix);
|
||||
@@ -496,7 +502,7 @@ addressmap_have_mapping(const char *address, int update_expiry)
|
||||
* equal to <b>address</b>, or any address ending with a period followed by
|
||||
* <b>address</b>. If <b>wildcard_addr</b> and <b>wildcard_new_addr</b> are
|
||||
* both true, the mapping will rewrite addresses that end with
|
||||
* ".<b>address</b>" into ones that end with ".<b>new_address</b>."
|
||||
* ".<b>address</b>" into ones that end with ".<b>new_address</b>".
|
||||
*
|
||||
* If <b>new_address</b> is NULL, or <b>new_address</b> is equal to
|
||||
* <b>address</b> and <b>wildcard_addr</b> is equal to
|
||||
@@ -535,9 +541,9 @@ addressmap_register(const char *address, char *new_address, time_t expires,
|
||||
if (expires > 1) {
|
||||
log_info(LD_APP,"Temporary addressmap ('%s' to '%s') not performed, "
|
||||
"since it's already mapped to '%s'",
|
||||
safe_str_client(address),
|
||||
safe_str_client(new_address),
|
||||
safe_str_client(ent->new_address));
|
||||
safe_str_client(address),
|
||||
safe_str_client(new_address),
|
||||
safe_str_client(ent->new_address));
|
||||
tor_free(new_address);
|
||||
return;
|
||||
}
|
||||
@@ -839,8 +845,8 @@ get_random_virtual_addr(const virtual_addr_conf_t *conf, tor_addr_t *addr_out)
|
||||
}
|
||||
|
||||
/** Return a newly allocated string holding an address of <b>type</b>
|
||||
* (one of RESOLVED_TYPE_{IPV4|HOSTNAME}) that has not yet been mapped,
|
||||
* and that is very unlikely to be the address of any real host.
|
||||
* (one of RESOLVED_TYPE_{IPV4|IPV6|HOSTNAME}) that has not yet been
|
||||
* mapped, and that is very unlikely to be the address of any real host.
|
||||
*
|
||||
* May return NULL if we have run out of virtual addresses.
|
||||
*/
|
||||
@@ -888,7 +894,7 @@ addressmap_get_virtual_address(int type)
|
||||
/* XXXX This code is to make sure I didn't add an undecorated version
|
||||
* by mistake. I hope it's needless. */
|
||||
char tmp[TOR_ADDR_BUF_LEN];
|
||||
tor_addr_to_str(buf, &addr, sizeof(tmp), 0);
|
||||
tor_addr_to_str(tmp, &addr, sizeof(tmp), 0);
|
||||
if (strmap_get(addressmap, tmp)) {
|
||||
log_warn(LD_BUG, "%s wasn't in the addressmap, but %s was.",
|
||||
buf, tmp);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_ADDRESSMAP_H
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -2063,9 +2063,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
|
||||
socks_request_set_socks5_error(req, SOCKS5_NOT_ALLOWED);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string_is_valid_hostname(req->address)) {
|
||||
} else if (!string_is_valid_hostname(req->address)) {
|
||||
socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
|
||||
|
||||
log_warn(LD_PROTOCOL,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+43
-81
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,6 @@ HT_GENERATE2(channel_idmap, channel_idmap_entry_s, node, channel_idmap_hash,
|
||||
channel_idmap_eq, 0.5, tor_reallocarray_, tor_free_);
|
||||
|
||||
static cell_queue_entry_t * cell_queue_entry_dup(cell_queue_entry_t *q);
|
||||
static void cell_queue_entry_free(cell_queue_entry_t *q, int handed_off);
|
||||
#if 0
|
||||
static int cell_queue_entry_is_padding(cell_queue_entry_t *q);
|
||||
#endif
|
||||
@@ -417,8 +416,7 @@ channel_register(channel_t *chan)
|
||||
smartlist_add(all_channels, chan);
|
||||
|
||||
/* Is it finished? */
|
||||
if (chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) {
|
||||
if (CHANNEL_FINISHED(chan)) {
|
||||
/* Put it in the finished list, creating it if necessary */
|
||||
if (!finished_channels) finished_channels = smartlist_new();
|
||||
smartlist_add(finished_channels, chan);
|
||||
@@ -427,7 +425,7 @@ channel_register(channel_t *chan)
|
||||
if (!active_channels) active_channels = smartlist_new();
|
||||
smartlist_add(active_channels, chan);
|
||||
|
||||
if (chan->state != CHANNEL_STATE_CLOSING) {
|
||||
if (!CHANNEL_IS_CLOSING(chan)) {
|
||||
/* It should have a digest set */
|
||||
if (!tor_digest_is_zero(chan->identity_digest)) {
|
||||
/* Yeah, we're good, add it to the map */
|
||||
@@ -462,8 +460,7 @@ channel_unregister(channel_t *chan)
|
||||
if (!(chan->registered)) return;
|
||||
|
||||
/* Is it finished? */
|
||||
if (chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) {
|
||||
if (CHANNEL_FINISHED(chan)) {
|
||||
/* Get it out of the finished list */
|
||||
if (finished_channels) smartlist_remove(finished_channels, chan);
|
||||
} else {
|
||||
@@ -479,9 +476,7 @@ channel_unregister(channel_t *chan)
|
||||
|
||||
/* Should it be in the digest map? */
|
||||
if (!tor_digest_is_zero(chan->identity_digest) &&
|
||||
!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR)) {
|
||||
!(CHANNEL_CONDEMNED(chan))) {
|
||||
/* Remove it */
|
||||
channel_remove_from_digest_map(chan);
|
||||
}
|
||||
@@ -581,9 +576,7 @@ channel_add_to_digest_map(channel_t *chan)
|
||||
tor_assert(chan);
|
||||
|
||||
/* Assert that the state makes sense */
|
||||
tor_assert(!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR));
|
||||
tor_assert(!CHANNEL_CONDEMNED(chan));
|
||||
|
||||
/* Assert that there is a digest */
|
||||
tor_assert(!tor_digest_is_zero(chan->identity_digest));
|
||||
@@ -821,8 +814,8 @@ channel_free(channel_t *chan)
|
||||
if (!chan) return;
|
||||
|
||||
/* It must be closed or errored */
|
||||
tor_assert(chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
tor_assert(CHANNEL_FINISHED(chan));
|
||||
|
||||
/* It must be deregistered */
|
||||
tor_assert(!(chan->registered));
|
||||
|
||||
@@ -1036,9 +1029,7 @@ channel_get_cell_handler(channel_t *chan)
|
||||
{
|
||||
tor_assert(chan);
|
||||
|
||||
if (chan->state == CHANNEL_STATE_OPENING ||
|
||||
chan->state == CHANNEL_STATE_OPEN ||
|
||||
chan->state == CHANNEL_STATE_MAINT)
|
||||
if (CHANNEL_CAN_HANDLE_CELLS(chan))
|
||||
return chan->cell_handler;
|
||||
|
||||
return NULL;
|
||||
@@ -1056,9 +1047,7 @@ channel_get_var_cell_handler(channel_t *chan)
|
||||
{
|
||||
tor_assert(chan);
|
||||
|
||||
if (chan->state == CHANNEL_STATE_OPENING ||
|
||||
chan->state == CHANNEL_STATE_OPEN ||
|
||||
chan->state == CHANNEL_STATE_MAINT)
|
||||
if (CHANNEL_CAN_HANDLE_CELLS(chan))
|
||||
return chan->var_cell_handler;
|
||||
|
||||
return NULL;
|
||||
@@ -1081,9 +1070,7 @@ channel_set_cell_handlers(channel_t *chan,
|
||||
int try_again = 0;
|
||||
|
||||
tor_assert(chan);
|
||||
tor_assert(chan->state == CHANNEL_STATE_OPENING ||
|
||||
chan->state == CHANNEL_STATE_OPEN ||
|
||||
chan->state == CHANNEL_STATE_MAINT);
|
||||
tor_assert(CHANNEL_CAN_HANDLE_CELLS(chan));
|
||||
|
||||
log_debug(LD_CHANNEL,
|
||||
"Setting cell_handler callback for channel %p to %p",
|
||||
@@ -1137,9 +1124,8 @@ channel_mark_for_close(channel_t *chan)
|
||||
tor_assert(chan->close != NULL);
|
||||
|
||||
/* If it's already in CLOSING, CLOSED or ERROR, this is a no-op */
|
||||
if (chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) return;
|
||||
if (CHANNEL_CONDEMNED(chan))
|
||||
return;
|
||||
|
||||
log_debug(LD_CHANNEL,
|
||||
"Closing channel %p (global ID " U64_FORMAT ") "
|
||||
@@ -1218,9 +1204,8 @@ channel_close_from_lower_layer(channel_t *chan)
|
||||
tor_assert(chan != NULL);
|
||||
|
||||
/* If it's already in CLOSING, CLOSED or ERROR, this is a no-op */
|
||||
if (chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) return;
|
||||
if (CHANNEL_CONDEMNED(chan))
|
||||
return;
|
||||
|
||||
log_debug(LD_CHANNEL,
|
||||
"Closing channel %p (global ID " U64_FORMAT ") "
|
||||
@@ -1278,9 +1263,8 @@ channel_close_for_error(channel_t *chan)
|
||||
tor_assert(chan != NULL);
|
||||
|
||||
/* If it's already in CLOSING, CLOSED or ERROR, this is a no-op */
|
||||
if (chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) return;
|
||||
if (CHANNEL_CONDEMNED(chan))
|
||||
return;
|
||||
|
||||
log_debug(LD_CHANNEL,
|
||||
"Closing channel %p due to lower-layer error",
|
||||
@@ -1336,13 +1320,11 @@ void
|
||||
channel_closed(channel_t *chan)
|
||||
{
|
||||
tor_assert(chan);
|
||||
tor_assert(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
tor_assert(CHANNEL_CONDEMNED(chan));
|
||||
|
||||
/* No-op if already inactive */
|
||||
if (chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) return;
|
||||
if (CHANNEL_FINISHED(chan))
|
||||
return;
|
||||
|
||||
/* Inform any pending (not attached) circs that they should
|
||||
* give up. */
|
||||
@@ -1405,10 +1387,7 @@ channel_clear_identity_digest(channel_t *chan)
|
||||
"global ID " U64_FORMAT,
|
||||
chan, U64_PRINTF_ARG(chan->global_identifier));
|
||||
|
||||
state_not_in_map =
|
||||
(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
state_not_in_map = CHANNEL_CONDEMNED(chan);
|
||||
|
||||
if (!state_not_in_map && chan->registered &&
|
||||
!tor_digest_is_zero(chan->identity_digest))
|
||||
@@ -1441,10 +1420,8 @@ channel_set_identity_digest(channel_t *chan,
|
||||
identity_digest ?
|
||||
hex_str(identity_digest, DIGEST_LEN) : "(null)");
|
||||
|
||||
state_not_in_map =
|
||||
(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
state_not_in_map = CHANNEL_CONDEMNED(chan);
|
||||
|
||||
was_in_digest_map =
|
||||
!state_not_in_map &&
|
||||
chan->registered &&
|
||||
@@ -1494,10 +1471,7 @@ channel_clear_remote_end(channel_t *chan)
|
||||
"global ID " U64_FORMAT,
|
||||
chan, U64_PRINTF_ARG(chan->global_identifier));
|
||||
|
||||
state_not_in_map =
|
||||
(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
state_not_in_map = CHANNEL_CONDEMNED(chan);
|
||||
|
||||
if (!state_not_in_map && chan->registered &&
|
||||
!tor_digest_is_zero(chan->identity_digest))
|
||||
@@ -1533,10 +1507,8 @@ channel_set_remote_end(channel_t *chan,
|
||||
identity_digest ?
|
||||
hex_str(identity_digest, DIGEST_LEN) : "(null)");
|
||||
|
||||
state_not_in_map =
|
||||
(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR);
|
||||
state_not_in_map = CHANNEL_CONDEMNED(chan);
|
||||
|
||||
was_in_digest_map =
|
||||
!state_not_in_map &&
|
||||
chan->registered &&
|
||||
@@ -1596,7 +1568,7 @@ cell_queue_entry_dup(cell_queue_entry_t *q)
|
||||
* them) or not (we should free).
|
||||
*/
|
||||
|
||||
static void
|
||||
STATIC void
|
||||
cell_queue_entry_free(cell_queue_entry_t *q, int handed_off)
|
||||
{
|
||||
if (!q) return;
|
||||
@@ -1761,9 +1733,7 @@ channel_write_cell_queue_entry(channel_t *chan, cell_queue_entry_t *q)
|
||||
tor_assert(q);
|
||||
|
||||
/* Assert that the state makes sense for a cell write */
|
||||
tor_assert(chan->state == CHANNEL_STATE_OPENING ||
|
||||
chan->state == CHANNEL_STATE_OPEN ||
|
||||
chan->state == CHANNEL_STATE_MAINT);
|
||||
tor_assert(CHANNEL_CAN_HANDLE_CELLS(chan));
|
||||
|
||||
{
|
||||
circid_t circ_id;
|
||||
@@ -1777,7 +1747,7 @@ channel_write_cell_queue_entry(channel_t *chan, cell_queue_entry_t *q)
|
||||
|
||||
/* Can we send it right out? If so, try */
|
||||
if (TOR_SIMPLEQ_EMPTY(&chan->outgoing_queue) &&
|
||||
chan->state == CHANNEL_STATE_OPEN) {
|
||||
CHANNEL_IS_OPEN(chan)) {
|
||||
/* Pick the right write function for this cell type and save the result */
|
||||
switch (q->type) {
|
||||
case CELL_QUEUE_FIXED:
|
||||
@@ -1835,7 +1805,7 @@ channel_write_cell_queue_entry(channel_t *chan, cell_queue_entry_t *q)
|
||||
/* Update channel queue size */
|
||||
chan->bytes_in_queue += cell_bytes;
|
||||
/* Try to process the queue? */
|
||||
if (chan->state == CHANNEL_STATE_OPEN) channel_flush_cells(chan);
|
||||
if (CHANNEL_IS_OPEN(chan)) channel_flush_cells(chan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1856,7 +1826,7 @@ channel_write_cell(channel_t *chan, cell_t *cell)
|
||||
tor_assert(chan);
|
||||
tor_assert(cell);
|
||||
|
||||
if (chan->state == CHANNEL_STATE_CLOSING) {
|
||||
if (CHANNEL_IS_CLOSING(chan)) {
|
||||
log_debug(LD_CHANNEL, "Discarding cell_t %p on closing channel %p with "
|
||||
"global ID "U64_FORMAT, cell, chan,
|
||||
U64_PRINTF_ARG(chan->global_identifier));
|
||||
@@ -1893,7 +1863,7 @@ channel_write_packed_cell(channel_t *chan, packed_cell_t *packed_cell)
|
||||
tor_assert(chan);
|
||||
tor_assert(packed_cell);
|
||||
|
||||
if (chan->state == CHANNEL_STATE_CLOSING) {
|
||||
if (CHANNEL_IS_CLOSING(chan)) {
|
||||
log_debug(LD_CHANNEL, "Discarding packed_cell_t %p on closing channel %p "
|
||||
"with global ID "U64_FORMAT, packed_cell, chan,
|
||||
U64_PRINTF_ARG(chan->global_identifier));
|
||||
@@ -1932,7 +1902,7 @@ channel_write_var_cell(channel_t *chan, var_cell_t *var_cell)
|
||||
tor_assert(chan);
|
||||
tor_assert(var_cell);
|
||||
|
||||
if (chan->state == CHANNEL_STATE_CLOSING) {
|
||||
if (CHANNEL_IS_CLOSING(chan)) {
|
||||
log_debug(LD_CHANNEL, "Discarding var_cell_t %p on closing channel %p "
|
||||
"with global ID "U64_FORMAT, var_cell, chan,
|
||||
U64_PRINTF_ARG(chan->global_identifier));
|
||||
@@ -2211,7 +2181,7 @@ channel_flush_some_cells, (channel_t *chan, ssize_t num_cells))
|
||||
if (!unlimited && num_cells <= flushed) goto done;
|
||||
|
||||
/* If we aren't in CHANNEL_STATE_OPEN, nothing goes through */
|
||||
if (chan->state == CHANNEL_STATE_OPEN) {
|
||||
if (CHANNEL_IS_OPEN(chan)) {
|
||||
/* Try to flush as much as we can that's already queued */
|
||||
flushed += channel_flush_some_cells_from_outgoing_queue(chan,
|
||||
(unlimited ? -1 : num_cells - flushed));
|
||||
@@ -2302,7 +2272,7 @@ channel_flush_some_cells_from_outgoing_queue(channel_t *chan,
|
||||
if (!unlimited && num_cells <= flushed) return 0;
|
||||
|
||||
/* If we aren't in CHANNEL_STATE_OPEN, nothing goes through */
|
||||
if (chan->state == CHANNEL_STATE_OPEN) {
|
||||
if (CHANNEL_IS_OPEN(chan)) {
|
||||
while ((unlimited || num_cells > flushed) &&
|
||||
NULL != (q = TOR_SIMPLEQ_FIRST(&chan->outgoing_queue))) {
|
||||
free_q = 0;
|
||||
@@ -2667,9 +2637,8 @@ channel_process_cells(channel_t *chan)
|
||||
{
|
||||
cell_queue_entry_t *q;
|
||||
tor_assert(chan);
|
||||
tor_assert(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_MAINT ||
|
||||
chan->state == CHANNEL_STATE_OPEN);
|
||||
tor_assert(CHANNEL_IS_CLOSING(chan) || CHANNEL_IS_MAINT(chan) ||
|
||||
CHANNEL_IS_OPEN(chan));
|
||||
|
||||
log_debug(LD_CHANNEL,
|
||||
"Processing as many incoming cells as we can for channel %p",
|
||||
@@ -2736,7 +2705,7 @@ channel_queue_cell(channel_t *chan, cell_t *cell)
|
||||
|
||||
tor_assert(chan);
|
||||
tor_assert(cell);
|
||||
tor_assert(chan->state == CHANNEL_STATE_OPEN);
|
||||
tor_assert(CHANNEL_IS_OPEN(chan));
|
||||
|
||||
/* Do we need to queue it, or can we just call the handler right away? */
|
||||
if (!(chan->cell_handler)) need_to_queue = 1;
|
||||
@@ -2790,7 +2759,7 @@ channel_queue_var_cell(channel_t *chan, var_cell_t *var_cell)
|
||||
|
||||
tor_assert(chan);
|
||||
tor_assert(var_cell);
|
||||
tor_assert(chan->state == CHANNEL_STATE_OPEN);
|
||||
tor_assert(CHANNEL_IS_OPEN(chan));
|
||||
|
||||
/* Do we need to queue it, or can we just call the handler right away? */
|
||||
if (!(chan->var_cell_handler)) need_to_queue = 1;
|
||||
@@ -2913,10 +2882,7 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
|
||||
}
|
||||
|
||||
/* Check to make sure we can send on this channel first */
|
||||
if (!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR) &&
|
||||
chan->cmux) {
|
||||
if (!CHANNEL_CONDEMNED(chan) && chan->cmux) {
|
||||
channel_note_destroy_pending(chan, circ_id);
|
||||
circuitmux_append_destroy_cell(chan, chan->cmux, circ_id, reason);
|
||||
log_debug(LD_OR,
|
||||
@@ -3106,9 +3072,7 @@ channel_free_list(smartlist_t *channels, int mark_for_close)
|
||||
}
|
||||
channel_unregister(curr);
|
||||
if (mark_for_close) {
|
||||
if (!(curr->state == CHANNEL_STATE_CLOSING ||
|
||||
curr->state == CHANNEL_STATE_CLOSED ||
|
||||
curr->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(curr)) {
|
||||
channel_mark_for_close(curr);
|
||||
}
|
||||
channel_force_free(curr);
|
||||
@@ -3322,9 +3286,7 @@ channel_get_for_extend(const char *digest,
|
||||
tor_assert(tor_memeq(chan->identity_digest,
|
||||
digest, DIGEST_LEN));
|
||||
|
||||
if (chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR)
|
||||
if (CHANNEL_CONDEMNED(chan))
|
||||
continue;
|
||||
|
||||
/* Never return a channel on which the other end appears to be
|
||||
@@ -3334,7 +3296,7 @@ channel_get_for_extend(const char *digest,
|
||||
}
|
||||
|
||||
/* Never return a non-open connection. */
|
||||
if (chan->state != CHANNEL_STATE_OPEN) {
|
||||
if (!CHANNEL_IS_OPEN(chan)) {
|
||||
/* If the address matches, don't launch a new connection for this
|
||||
* circuit. */
|
||||
if (channel_matches_target_addr_for_extend(chan, target_addr))
|
||||
|
||||
+36
-1
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -380,6 +380,8 @@ struct cell_queue_entry_s {
|
||||
|
||||
/* Cell queue functions for benefit of test suite */
|
||||
STATIC int chan_cell_queue_len(const chan_cell_queue_t *queue);
|
||||
|
||||
STATIC void cell_queue_entry_free(cell_queue_entry_t *q, int handed_off);
|
||||
#endif
|
||||
|
||||
/* Channel operations for subclasses and internal use only */
|
||||
@@ -502,6 +504,39 @@ channel_t * channel_find_by_remote_digest(const char *identity_digest);
|
||||
*/
|
||||
channel_t * channel_next_with_digest(channel_t *chan);
|
||||
|
||||
/*
|
||||
* Helper macros to lookup state of given channel.
|
||||
*/
|
||||
|
||||
#define CHANNEL_IS_CLOSED(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_CLOSED))
|
||||
#define CHANNEL_IS_OPENING(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_OPENING))
|
||||
#define CHANNEL_IS_OPEN(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_OPEN))
|
||||
#define CHANNEL_IS_MAINT(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_MAINT))
|
||||
#define CHANNEL_IS_CLOSING(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_CLOSING))
|
||||
#define CHANNEL_IS_ERROR(chan) (channel_is_in_state((chan), \
|
||||
CHANNEL_STATE_ERROR))
|
||||
|
||||
#define CHANNEL_FINISHED(chan) (CHANNEL_IS_CLOSED(chan) || \
|
||||
CHANNEL_IS_ERROR(chan))
|
||||
|
||||
#define CHANNEL_CONDEMNED(chan) (CHANNEL_IS_CLOSING(chan) || \
|
||||
CHANNEL_FINISHED(chan))
|
||||
|
||||
#define CHANNEL_CAN_HANDLE_CELLS(chan) (CHANNEL_IS_OPENING(chan) || \
|
||||
CHANNEL_IS_OPEN(chan) || \
|
||||
CHANNEL_IS_MAINT(chan))
|
||||
|
||||
static INLINE int
|
||||
channel_is_in_state(channel_t *chan, channel_state_t state)
|
||||
{
|
||||
return chan->state == state;
|
||||
}
|
||||
|
||||
/*
|
||||
* Metadata queries/updates
|
||||
*/
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -940,13 +940,13 @@ channel_tls_handle_state_change_on_orconn(channel_tls_t *chan,
|
||||
|
||||
base_chan = TLS_CHAN_TO_BASE(chan);
|
||||
|
||||
/* Make sure the base connection state makes sense - shouldn't be error,
|
||||
* closed or listening. */
|
||||
/* Make sure the base connection state makes sense - shouldn't be error
|
||||
* or closed. */
|
||||
|
||||
tor_assert(base_chan->state == CHANNEL_STATE_OPENING ||
|
||||
base_chan->state == CHANNEL_STATE_OPEN ||
|
||||
base_chan->state == CHANNEL_STATE_MAINT ||
|
||||
base_chan->state == CHANNEL_STATE_CLOSING);
|
||||
tor_assert(CHANNEL_IS_OPENING(base_chan) ||
|
||||
CHANNEL_IS_OPEN(base_chan) ||
|
||||
CHANNEL_IS_MAINT(base_chan) ||
|
||||
CHANNEL_IS_CLOSING(base_chan));
|
||||
|
||||
/* Did we just go to state open? */
|
||||
if (state == OR_CONN_STATE_OPEN) {
|
||||
@@ -964,7 +964,7 @@ channel_tls_handle_state_change_on_orconn(channel_tls_t *chan,
|
||||
* Not open, so from CHANNEL_STATE_OPEN we go to CHANNEL_STATE_MAINT,
|
||||
* otherwise no change.
|
||||
*/
|
||||
if (base_chan->state == CHANNEL_STATE_OPEN) {
|
||||
if (CHANNEL_IS_OPEN(base_chan)) {
|
||||
channel_change_state(base_chan, CHANNEL_STATE_MAINT);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#include "or.h"
|
||||
@@ -768,8 +768,8 @@ pathbias_send_usable_probe(circuit_t *circ)
|
||||
|
||||
/* Can't probe if the channel isn't open */
|
||||
if (circ->n_chan == NULL ||
|
||||
(circ->n_chan->state != CHANNEL_STATE_OPEN
|
||||
&& circ->n_chan->state != CHANNEL_STATE_MAINT)) {
|
||||
(!CHANNEL_IS_OPEN(circ->n_chan)
|
||||
&& !CHANNEL_IS_MAINT(circ->n_chan))) {
|
||||
log_info(LD_CIRC,
|
||||
"Skipping pathbias probe for circuit %d: Channel is not open.",
|
||||
ocirc->global_identifier);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+20
-8
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -672,7 +672,7 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell,
|
||||
if (CIRCUIT_IS_ORIGIN(circ)) {
|
||||
/* Update began timestamp for circuits starting their first hop */
|
||||
if (TO_ORIGIN_CIRCUIT(circ)->cpath->state == CPATH_STATE_CLOSED) {
|
||||
if (circ->n_chan->state != CHANNEL_STATE_OPEN) {
|
||||
if (!CHANNEL_IS_OPEN(circ->n_chan)) {
|
||||
log_warn(LD_CIRC,
|
||||
"Got first hop for a circuit without an opened channel. "
|
||||
"State: %s.", channel_state_to_string(circ->n_chan->state));
|
||||
@@ -1378,8 +1378,10 @@ onionskin_answer(or_circuit_t *circ,
|
||||
log_debug(LD_CIRC,"Finished sending '%s' cell.",
|
||||
circ->is_first_hop ? "created_fast" : "created");
|
||||
|
||||
if (!channel_is_local(circ->p_chan) &&
|
||||
!channel_is_outgoing(circ->p_chan)) {
|
||||
/* Ignore the local bit when testing - many test networks run on local
|
||||
* addresses */
|
||||
if ((!channel_is_local(circ->p_chan) || get_options()->TestingTorNetwork)
|
||||
&& !channel_is_outgoing(circ->p_chan)) {
|
||||
/* record that we could process create cells from a non-local conn
|
||||
* that we didn't initiate; presumably this means that create cells
|
||||
* can reach us too. */
|
||||
@@ -1863,7 +1865,7 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
|
||||
choose_good_exit_server(circ->base_.purpose, state->need_uptime,
|
||||
state->need_capacity, state->is_internal);
|
||||
if (!node) {
|
||||
log_warn(LD_CIRC,"failed to choose an exit server");
|
||||
log_warn(LD_CIRC,"Failed to choose an exit server");
|
||||
return -1;
|
||||
}
|
||||
exit = extend_info_from_node(node, 0);
|
||||
@@ -1990,7 +1992,8 @@ choose_good_middle_server(uint8_t purpose,
|
||||
tor_assert(CIRCUIT_PURPOSE_MIN_ <= purpose &&
|
||||
purpose <= CIRCUIT_PURPOSE_MAX_);
|
||||
|
||||
log_debug(LD_CIRC, "Contemplating intermediate hop: random choice.");
|
||||
log_debug(LD_CIRC, "Contemplating intermediate hop %d: random choice.",
|
||||
cur_len);
|
||||
excluded = smartlist_new();
|
||||
if ((r = build_state_get_exit_node(state))) {
|
||||
nodelist_add_node_and_family(excluded, r);
|
||||
@@ -2052,9 +2055,18 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
|
||||
smartlist_add(excluded, (void*)node);
|
||||
});
|
||||
}
|
||||
/* and exclude current entry guards and their families, if applicable */
|
||||
/* and exclude current entry guards and their families,
|
||||
* unless we're in a test network, and excluding guards
|
||||
* would exclude all nodes (i.e. we're in an incredibly small tor network,
|
||||
* or we're using TestingAuthVoteGuard *).
|
||||
* This is an incomplete fix, but is no worse than the previous behaviour,
|
||||
* and only applies to minimal, testing tor networks
|
||||
* (so it's no less secure) */
|
||||
/*XXXX025 use the using_as_guard flag to accomplish this.*/
|
||||
if (options->UseEntryGuards) {
|
||||
if (options->UseEntryGuards
|
||||
&& (!options->TestingTorNetwork ||
|
||||
smartlist_len(nodelist_get_list()) > smartlist_len(get_entry_guards())
|
||||
)) {
|
||||
SMARTLIST_FOREACH(get_entry_guards(), const entry_guard_t *, entry,
|
||||
{
|
||||
if ((node = node_get_by_id(entry->identity))) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1752,9 +1752,7 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line,
|
||||
if (circ->n_chan) {
|
||||
circuit_clear_cell_queue(circ, circ->n_chan);
|
||||
/* Only send destroy if the channel isn't closing anyway */
|
||||
if (!(circ->n_chan->state == CHANNEL_STATE_CLOSING ||
|
||||
circ->n_chan->state == CHANNEL_STATE_CLOSED ||
|
||||
circ->n_chan->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(circ->n_chan)) {
|
||||
channel_send_destroy(circ->n_circ_id, circ->n_chan, reason);
|
||||
}
|
||||
circuitmux_detach_circuit(circ->n_chan->cmux, circ);
|
||||
@@ -1786,9 +1784,7 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line,
|
||||
if (or_circ->p_chan) {
|
||||
circuit_clear_cell_queue(circ, or_circ->p_chan);
|
||||
/* Only send destroy if the channel isn't closing anyway */
|
||||
if (!(or_circ->p_chan->state == CHANNEL_STATE_CLOSING ||
|
||||
or_circ->p_chan->state == CHANNEL_STATE_CLOSED ||
|
||||
or_circ->p_chan->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(or_circ->p_chan)) {
|
||||
channel_send_destroy(or_circ->p_circ_id, or_circ->p_chan, reason);
|
||||
}
|
||||
circuitmux_detach_circuit(or_circ->p_chan->cmux, circ);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
|
||||
/* * Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define CIRCUITSTATS_PRIVATE
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+71
-29
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1024,9 +1024,11 @@ circuit_predict_and_launch_new(void)
|
||||
|
||||
/* Second, see if we need any more exit circuits. */
|
||||
/* check if we know of a port that's been requested recently
|
||||
* and no circuit is currently available that can handle it. */
|
||||
* and no circuit is currently available that can handle it.
|
||||
* Exits (obviously) require an exit circuit. */
|
||||
if (!circuit_all_predicted_ports_handled(now, &port_needs_uptime,
|
||||
&port_needs_capacity)) {
|
||||
&port_needs_capacity)
|
||||
&& router_have_consensus_path() == CONSENSUS_PATH_EXIT) {
|
||||
if (port_needs_uptime)
|
||||
flags |= CIRCLAUNCH_NEED_UPTIME;
|
||||
if (port_needs_capacity)
|
||||
@@ -1038,8 +1040,10 @@ circuit_predict_and_launch_new(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Third, see if we need any more hidden service (server) circuits. */
|
||||
if (num_rend_services() && num_uptime_internal < 3) {
|
||||
/* Third, see if we need any more hidden service (server) circuits.
|
||||
* HS servers only need an internal circuit. */
|
||||
if (num_rend_services() && num_uptime_internal < 3
|
||||
&& router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN) {
|
||||
flags = (CIRCLAUNCH_NEED_CAPACITY | CIRCLAUNCH_NEED_UPTIME |
|
||||
CIRCLAUNCH_IS_INTERNAL);
|
||||
log_info(LD_CIRC,
|
||||
@@ -1050,11 +1054,13 @@ circuit_predict_and_launch_new(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fourth, see if we need any more hidden service (client) circuits. */
|
||||
/* Fourth, see if we need any more hidden service (client) circuits.
|
||||
* HS clients only need an internal circuit. */
|
||||
if (rep_hist_get_predicted_internal(now, &hidserv_needs_uptime,
|
||||
&hidserv_needs_capacity) &&
|
||||
((num_uptime_internal<2 && hidserv_needs_uptime) ||
|
||||
num_internal<2)) {
|
||||
num_internal<2)
|
||||
&& router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN) {
|
||||
if (hidserv_needs_uptime)
|
||||
flags |= CIRCLAUNCH_NEED_UPTIME;
|
||||
if (hidserv_needs_capacity)
|
||||
@@ -1071,15 +1077,23 @@ circuit_predict_and_launch_new(void)
|
||||
/* Finally, check to see if we still need more circuits to learn
|
||||
* a good build timeout. But if we're close to our max number we
|
||||
* want, don't do another -- we want to leave a few slots open so
|
||||
* we can still build circuits preemptively as needed. */
|
||||
if (num < MAX_UNUSED_OPEN_CIRCUITS-2 &&
|
||||
! circuit_build_times_disabled() &&
|
||||
circuit_build_times_needs_circuits_now(get_circuit_build_times())) {
|
||||
flags = CIRCLAUNCH_NEED_CAPACITY;
|
||||
log_info(LD_CIRC,
|
||||
"Have %d clean circs need another buildtime test circ.", num);
|
||||
circuit_launch(CIRCUIT_PURPOSE_C_GENERAL, flags);
|
||||
return;
|
||||
* we can still build circuits preemptively as needed.
|
||||
* XXXX make the assumption that build timeout streams should be
|
||||
* created whenever we can build internal circuits. */
|
||||
if (router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN) {
|
||||
if (num < MAX_UNUSED_OPEN_CIRCUITS-2 &&
|
||||
! circuit_build_times_disabled() &&
|
||||
circuit_build_times_needs_circuits_now(get_circuit_build_times())) {
|
||||
flags = CIRCLAUNCH_NEED_CAPACITY;
|
||||
/* if there are no exits in the consensus, make timeout
|
||||
* circuits internal */
|
||||
if (router_have_consensus_path() == CONSENSUS_PATH_INTERNAL)
|
||||
flags |= CIRCLAUNCH_IS_INTERNAL;
|
||||
log_info(LD_CIRC,
|
||||
"Have %d clean circs need another buildtime test circ.", num);
|
||||
circuit_launch(CIRCUIT_PURPOSE_C_GENERAL, flags);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1096,11 +1110,17 @@ circuit_build_needed_circs(time_t now)
|
||||
{
|
||||
const or_options_t *options = get_options();
|
||||
|
||||
/* launch a new circ for any pending streams that need one */
|
||||
connection_ap_attach_pending();
|
||||
/* launch a new circ for any pending streams that need one
|
||||
* XXXX make the assumption that (some) AP streams (i.e. HS clients)
|
||||
* don't require an exit circuit, review in #13814.
|
||||
* This allows HSs to function in a consensus without exits. */
|
||||
if (router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN)
|
||||
connection_ap_attach_pending();
|
||||
|
||||
/* make sure any hidden services have enough intro points */
|
||||
rend_services_introduce();
|
||||
/* make sure any hidden services have enough intro points
|
||||
* HS intro point streams only require an internal circuit */
|
||||
if (router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN)
|
||||
rend_services_introduce();
|
||||
|
||||
circuit_expire_old_circs_as_needed(now);
|
||||
|
||||
@@ -1632,6 +1652,16 @@ circuit_launch(uint8_t purpose, int flags)
|
||||
return circuit_launch_by_extend_info(purpose, NULL, flags);
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
static int
|
||||
have_enough_path_info(int need_exit)
|
||||
{
|
||||
if (need_exit)
|
||||
return router_have_consensus_path() == CONSENSUS_PATH_EXIT;
|
||||
else
|
||||
return router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN;
|
||||
}
|
||||
|
||||
/** Launch a new circuit with purpose <b>purpose</b> and exit node
|
||||
* <b>extend_info</b> (or NULL to select a random exit node). If flags
|
||||
* contains CIRCLAUNCH_NEED_UPTIME, choose among routers with high uptime. If
|
||||
@@ -1646,10 +1676,14 @@ circuit_launch_by_extend_info(uint8_t purpose,
|
||||
{
|
||||
origin_circuit_t *circ;
|
||||
int onehop_tunnel = (flags & CIRCLAUNCH_ONEHOP_TUNNEL) != 0;
|
||||
int have_path = have_enough_path_info(! (flags & CIRCLAUNCH_IS_INTERNAL) );
|
||||
|
||||
if (!onehop_tunnel && !router_have_minimum_dir_info()) {
|
||||
log_debug(LD_CIRC,"Haven't fetched enough directory info yet; canceling "
|
||||
"circuit launch.");
|
||||
if (!onehop_tunnel && (!router_have_minimum_dir_info() || !have_path)) {
|
||||
log_debug(LD_CIRC,"Haven't %s yet; canceling "
|
||||
"circuit launch.",
|
||||
!router_have_minimum_dir_info() ?
|
||||
"fetched enough directory info" :
|
||||
"received a consensus with exits");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1806,7 +1840,9 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
|
||||
return 1; /* we're happy */
|
||||
}
|
||||
|
||||
if (!want_onehop && !router_have_minimum_dir_info()) {
|
||||
int have_path = have_enough_path_info(!need_internal);
|
||||
|
||||
if (!want_onehop && (!router_have_minimum_dir_info() || !have_path)) {
|
||||
if (!connection_get_by_type(CONN_TYPE_DIR)) {
|
||||
int severity = LOG_NOTICE;
|
||||
/* FFFF if this is a tunneled directory fetch, don't yell
|
||||
@@ -1814,14 +1850,20 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
|
||||
if (entry_list_is_constrained(options) &&
|
||||
entries_known_but_down(options)) {
|
||||
log_fn(severity, LD_APP|LD_DIR,
|
||||
"Application request when we haven't used client functionality "
|
||||
"lately. Optimistically trying known %s again.",
|
||||
"Application request when we haven't %s. "
|
||||
"Optimistically trying known %s again.",
|
||||
!router_have_minimum_dir_info() ?
|
||||
"used client functionality lately" :
|
||||
"received a consensus with exits",
|
||||
options->UseBridges ? "bridges" : "entrynodes");
|
||||
entries_retry_all(options);
|
||||
} else if (!options->UseBridges || any_bridge_descriptors_known()) {
|
||||
log_fn(severity, LD_APP|LD_DIR,
|
||||
"Application request when we haven't used client functionality "
|
||||
"lately. Optimistically trying directory fetches again.");
|
||||
"Application request when we haven't %s. "
|
||||
"Optimistically trying directory fetches again.",
|
||||
!router_have_minimum_dir_info() ?
|
||||
"used client functionality lately" :
|
||||
"received a consensus with exits");
|
||||
routerlist_retry_directory_downloads(time(NULL));
|
||||
}
|
||||
}
|
||||
@@ -2012,7 +2054,7 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
|
||||
circ->rend_data = rend_data_dup(ENTRY_TO_EDGE_CONN(conn)->rend_data);
|
||||
if (circ->base_.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND &&
|
||||
circ->base_.state == CIRCUIT_STATE_OPEN)
|
||||
rend_client_rendcirc_has_opened(circ);
|
||||
circuit_has_opened(circ);
|
||||
}
|
||||
}
|
||||
} /* endif (!circ) */
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+10
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -438,6 +438,7 @@ command_process_created_cell(cell_t *cell, channel_t *chan)
|
||||
static void
|
||||
command_process_relay_cell(cell_t *cell, channel_t *chan)
|
||||
{
|
||||
const or_options_t *options = get_options();
|
||||
circuit_t *circ;
|
||||
int reason, direction;
|
||||
|
||||
@@ -511,6 +512,14 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
|
||||
direction==CELL_DIRECTION_OUT?"forward":"backward");
|
||||
circuit_mark_for_close(circ, -reason);
|
||||
}
|
||||
|
||||
/* If this is a cell in an RP circuit, count it as part of the
|
||||
hidden service stats */
|
||||
if (options->HiddenServiceStatistics &&
|
||||
!CIRCUIT_IS_ORIGIN(circ) &&
|
||||
TO_OR_CIRCUIT(circ)->circuit_carries_hs_traffic_stats) {
|
||||
rep_hist_seen_new_rp_cell();
|
||||
}
|
||||
}
|
||||
|
||||
/** Process a 'destroy' <b>cell</b> that just arrived from
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+127
-33
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#define CONFIG_PRIVATE
|
||||
#include "or.h"
|
||||
#include "compat.h"
|
||||
#include "addressmap.h"
|
||||
#include "channel.h"
|
||||
#include "circuitbuild.h"
|
||||
@@ -64,7 +65,6 @@ static config_abbrev_t option_abbrevs_[] = {
|
||||
PLURAL(AuthDirBadExitCC),
|
||||
PLURAL(AuthDirInvalidCC),
|
||||
PLURAL(AuthDirRejectCC),
|
||||
PLURAL(ExitNode),
|
||||
PLURAL(EntryNode),
|
||||
PLURAL(ExcludeNode),
|
||||
PLURAL(FirewallPort),
|
||||
@@ -228,6 +228,7 @@ static config_var_t option_vars_[] = {
|
||||
V(ExitPolicyRejectPrivate, BOOL, "1"),
|
||||
V(ExitPortStatistics, BOOL, "0"),
|
||||
V(ExtendAllowPrivateAddresses, BOOL, "0"),
|
||||
V(ExitRelay, AUTOBOOL, "auto"),
|
||||
VPORT(ExtORPort, LINELIST, NULL),
|
||||
V(ExtORPortCookieAuthFile, STRING, NULL),
|
||||
V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"),
|
||||
@@ -268,6 +269,7 @@ static config_var_t option_vars_[] = {
|
||||
VAR("HiddenServicePort", LINELIST_S, RendConfigLines, NULL),
|
||||
VAR("HiddenServiceVersion",LINELIST_S, RendConfigLines, NULL),
|
||||
VAR("HiddenServiceAuthorizeClient",LINELIST_S,RendConfigLines, NULL),
|
||||
V(HiddenServiceStatistics, BOOL, "0"),
|
||||
V(HidServAuth, LINELIST, NULL),
|
||||
V(CloseHSClientCircuitsImmediatelyOnTimeout, BOOL, "0"),
|
||||
V(CloseHSServiceRendCircuitsImmediatelyOnTimeout, BOOL, "0"),
|
||||
@@ -468,7 +470,7 @@ static const config_var_t testing_tor_network_defaults[] = {
|
||||
V(V3AuthVotingInterval, INTERVAL, "5 minutes"),
|
||||
V(V3AuthVoteDelay, INTERVAL, "20 seconds"),
|
||||
V(V3AuthDistDelay, INTERVAL, "20 seconds"),
|
||||
V(TestingV3AuthInitialVotingInterval, INTERVAL, "5 minutes"),
|
||||
V(TestingV3AuthInitialVotingInterval, INTERVAL, "150 seconds"),
|
||||
V(TestingV3AuthInitialVoteDelay, INTERVAL, "20 seconds"),
|
||||
V(TestingV3AuthInitialDistDelay, INTERVAL, "20 seconds"),
|
||||
V(TestingV3AuthVotingStartOffset, INTERVAL, "0"),
|
||||
@@ -1714,6 +1716,7 @@ options_act(const or_options_t *old_options)
|
||||
if (options->CellStatistics || options->DirReqStatistics ||
|
||||
options->EntryStatistics || options->ExitPortStatistics ||
|
||||
options->ConnDirectionStatistics ||
|
||||
options->HiddenServiceStatistics ||
|
||||
options->BridgeAuthoritativeDir) {
|
||||
time_t now = time(NULL);
|
||||
int print_notice = 0;
|
||||
@@ -1722,6 +1725,7 @@ options_act(const or_options_t *old_options)
|
||||
if (!public_server_mode(options)) {
|
||||
options->CellStatistics = 0;
|
||||
options->EntryStatistics = 0;
|
||||
options->HiddenServiceStatistics = 0;
|
||||
options->ExitPortStatistics = 0;
|
||||
}
|
||||
|
||||
@@ -1767,6 +1771,11 @@ options_act(const or_options_t *old_options)
|
||||
options->ConnDirectionStatistics) {
|
||||
rep_hist_conn_stats_init(now);
|
||||
}
|
||||
if ((!old_options || !old_options->HiddenServiceStatistics) &&
|
||||
options->HiddenServiceStatistics) {
|
||||
log_info(LD_CONFIG, "Configured to measure hidden service statistics.");
|
||||
rep_hist_hs_stats_init(now);
|
||||
}
|
||||
if ((!old_options || !old_options->BridgeAuthoritativeDir) &&
|
||||
options->BridgeAuthoritativeDir) {
|
||||
rep_hist_desc_stats_init(now);
|
||||
@@ -1778,6 +1787,8 @@ options_act(const or_options_t *old_options)
|
||||
"data directory in 24 hours from now.");
|
||||
}
|
||||
|
||||
/* If we used to have statistics enabled but we just disabled them,
|
||||
stop gathering them. */
|
||||
if (old_options && old_options->CellStatistics &&
|
||||
!options->CellStatistics)
|
||||
rep_hist_buffer_stats_term();
|
||||
@@ -1787,6 +1798,9 @@ options_act(const or_options_t *old_options)
|
||||
if (old_options && old_options->EntryStatistics &&
|
||||
!options->EntryStatistics)
|
||||
geoip_entry_stats_term();
|
||||
if (old_options && old_options->HiddenServiceStatistics &&
|
||||
!options->HiddenServiceStatistics)
|
||||
rep_hist_hs_stats_term();
|
||||
if (old_options && old_options->ExitPortStatistics &&
|
||||
!options->ExitPortStatistics)
|
||||
rep_hist_exit_stats_term();
|
||||
@@ -1819,7 +1833,7 @@ options_act(const or_options_t *old_options)
|
||||
directory_fetches_dir_info_early(old_options)) ||
|
||||
!bool_eq(directory_fetches_dir_info_later(options),
|
||||
directory_fetches_dir_info_later(old_options))) {
|
||||
/* Make sure update_router_have_min_dir_info gets called. */
|
||||
/* Make sure update_router_have_minimum_dir_info() gets called. */
|
||||
router_dir_info_changed();
|
||||
/* We might need to download a new consensus status later or sooner than
|
||||
* we had expected. */
|
||||
@@ -2033,7 +2047,7 @@ print_usage(void)
|
||||
printf(
|
||||
"Copyright (c) 2001-2004, Roger Dingledine\n"
|
||||
"Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson\n"
|
||||
"Copyright (c) 2007-2014, The Tor Project, Inc.\n\n"
|
||||
"Copyright (c) 2007-2015, The Tor Project, Inc.\n\n"
|
||||
"tor -f <torrc> [args]\n"
|
||||
"See man page for options, or https://www.torproject.org/ for "
|
||||
"documentation.\n");
|
||||
@@ -2073,7 +2087,33 @@ reset_last_resolved_addr(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use <b>options-\>Address</b> to guess our public IP address.
|
||||
* Attempt getting our non-local (as judged by tor_addr_is_internal()
|
||||
* function) IP address using following techniques, listed in
|
||||
* order from best (most desirable, try first) to worst (least
|
||||
* desirable, try if everything else fails).
|
||||
*
|
||||
* First, attempt using <b>options-\>Address</b> to get our
|
||||
* non-local IP address.
|
||||
*
|
||||
* If <b>options-\>Address</b> represents a non-local IP address,
|
||||
* consider it ours.
|
||||
*
|
||||
* If <b>options-\>Address</b> is a DNS name that resolves to
|
||||
* a non-local IP address, consider this IP address ours.
|
||||
*
|
||||
* If <b>options-\>Address</b> is NULL, fall back to getting local
|
||||
* hostname and using it in above-described ways to try and
|
||||
* get our IP address.
|
||||
*
|
||||
* In case local hostname cannot be resolved to a non-local IP
|
||||
* address, try getting an IP address of network interface
|
||||
* in hopes it will be non-local one.
|
||||
*
|
||||
* Fail if one or more of the following is true:
|
||||
* - DNS name in <b>options-\>Address</b> cannot be resolved.
|
||||
* - <b>options-\>Address</b> is a local host address.
|
||||
* - Attempt to getting local hostname fails.
|
||||
* - Attempt to getting network interface address fails.
|
||||
*
|
||||
* Return 0 if all is well, or -1 if we can't find a suitable
|
||||
* public IP address.
|
||||
@@ -2082,6 +2122,11 @@ reset_last_resolved_addr(void)
|
||||
* - Put our public IP address (in host order) into *<b>addr_out</b>.
|
||||
* - If <b>method_out</b> is non-NULL, set *<b>method_out</b> to a static
|
||||
* string describing how we arrived at our answer.
|
||||
* - "CONFIGURED" - parsed from IP address string in
|
||||
* <b>options-\>Address</b>
|
||||
* - "RESOLVED" - resolved from DNS name in <b>options-\>Address</b>
|
||||
* - "GETHOSTNAME" - resolved from a local hostname.
|
||||
* - "INTERFACE" - retrieved from a network interface.
|
||||
* - If <b>hostname_out</b> is non-NULL, and we resolved a hostname to
|
||||
* get our address, set *<b>hostname_out</b> to a newly allocated string
|
||||
* holding that hostname. (If we didn't get our address by resolving a
|
||||
@@ -2120,7 +2165,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
|
||||
explicit_ip = 0; /* it's implicit */
|
||||
explicit_hostname = 0; /* it's implicit */
|
||||
|
||||
if (gethostname(hostname, sizeof(hostname)) < 0) {
|
||||
if (tor_gethostname(hostname, sizeof(hostname)) < 0) {
|
||||
log_fn(warn_severity, LD_NET,"Error obtaining local hostname");
|
||||
return -1;
|
||||
}
|
||||
@@ -2597,20 +2642,24 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
if (!strcasecmp(options->TransProxyType, "default")) {
|
||||
options->TransProxyType_parsed = TPT_DEFAULT;
|
||||
} else if (!strcasecmp(options->TransProxyType, "pf-divert")) {
|
||||
#ifndef __OpenBSD__
|
||||
REJECT("pf-divert is a OpenBSD-specific feature.");
|
||||
#if !defined(__OpenBSD__) && !defined( DARWIN )
|
||||
/* Later versions of OS X have pf */
|
||||
REJECT("pf-divert is a OpenBSD-specific "
|
||||
"and OS X/Darwin-specific feature.");
|
||||
#else
|
||||
options->TransProxyType_parsed = TPT_PF_DIVERT;
|
||||
#endif
|
||||
} else if (!strcasecmp(options->TransProxyType, "tproxy")) {
|
||||
#ifndef __linux__
|
||||
#if !defined(__linux__)
|
||||
REJECT("TPROXY is a Linux-specific feature.");
|
||||
#else
|
||||
options->TransProxyType_parsed = TPT_TPROXY;
|
||||
#endif
|
||||
} else if (!strcasecmp(options->TransProxyType, "ipfw")) {
|
||||
#ifndef __FreeBSD__
|
||||
REJECT("ipfw is a FreeBSD-specific feature.");
|
||||
#if !defined(__FreeBSD__) && !defined( DARWIN )
|
||||
/* Earlier versions of OS X have ipfw */
|
||||
REJECT("ipfw is a FreeBSD-specific"
|
||||
"and OS X/Darwin-specific feature.");
|
||||
#else
|
||||
options->TransProxyType_parsed = TPT_IPFW;
|
||||
#endif
|
||||
@@ -2862,6 +2911,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
options->MaxMemInQueues =
|
||||
compute_real_max_mem_in_queues(options->MaxMemInQueues_raw,
|
||||
server_mode(options));
|
||||
options->MaxMemInQueues_low_threshold = (options->MaxMemInQueues / 4) * 3;
|
||||
|
||||
options->AllowInvalid_ = 0;
|
||||
|
||||
@@ -3397,19 +3447,68 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
|
||||
if (options->V3AuthVoteDelay + options->V3AuthDistDelay >=
|
||||
options->V3AuthVotingInterval/2) {
|
||||
REJECT("V3AuthVoteDelay plus V3AuthDistDelay must be less than half "
|
||||
"V3AuthVotingInterval");
|
||||
/*
|
||||
This doesn't work, but it seems like it should:
|
||||
what code is preventing the interval being less than twice the lead-up?
|
||||
if (options->TestingTorNetwork) {
|
||||
if (options->V3AuthVoteDelay + options->V3AuthDistDelay >=
|
||||
options->V3AuthVotingInterval) {
|
||||
REJECT("V3AuthVoteDelay plus V3AuthDistDelay must be less than "
|
||||
"V3AuthVotingInterval");
|
||||
} else {
|
||||
COMPLAIN("V3AuthVoteDelay plus V3AuthDistDelay is more than half "
|
||||
"V3AuthVotingInterval. This may lead to "
|
||||
"consensus instability, particularly if clocks drift.");
|
||||
}
|
||||
} else {
|
||||
*/
|
||||
REJECT("V3AuthVoteDelay plus V3AuthDistDelay must be less than half "
|
||||
"V3AuthVotingInterval");
|
||||
/*
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (options->V3AuthVoteDelay < MIN_VOTE_SECONDS) {
|
||||
if (options->TestingTorNetwork) {
|
||||
if (options->V3AuthVoteDelay < MIN_VOTE_SECONDS_TESTING) {
|
||||
REJECT("V3AuthVoteDelay is way too low.");
|
||||
} else {
|
||||
COMPLAIN("V3AuthVoteDelay is very low. "
|
||||
"This may lead to failure to vote for a consensus.");
|
||||
}
|
||||
} else {
|
||||
REJECT("V3AuthVoteDelay is way too low.");
|
||||
}
|
||||
}
|
||||
|
||||
if (options->V3AuthDistDelay < MIN_DIST_SECONDS) {
|
||||
if (options->TestingTorNetwork) {
|
||||
if (options->V3AuthDistDelay < MIN_DIST_SECONDS_TESTING) {
|
||||
REJECT("V3AuthDistDelay is way too low.");
|
||||
} else {
|
||||
COMPLAIN("V3AuthDistDelay is very low. "
|
||||
"This may lead to missing votes in a consensus.");
|
||||
}
|
||||
} else {
|
||||
REJECT("V3AuthDistDelay is way too low.");
|
||||
}
|
||||
}
|
||||
if (options->V3AuthVoteDelay < MIN_VOTE_SECONDS)
|
||||
REJECT("V3AuthVoteDelay is way too low.");
|
||||
if (options->V3AuthDistDelay < MIN_DIST_SECONDS)
|
||||
REJECT("V3AuthDistDelay is way too low.");
|
||||
|
||||
if (options->V3AuthNIntervalsValid < 2)
|
||||
REJECT("V3AuthNIntervalsValid must be at least 2.");
|
||||
|
||||
if (options->V3AuthVotingInterval < MIN_VOTE_INTERVAL) {
|
||||
REJECT("V3AuthVotingInterval is insanely low.");
|
||||
if (options->TestingTorNetwork) {
|
||||
if (options->V3AuthVotingInterval < MIN_VOTE_INTERVAL_TESTING) {
|
||||
REJECT("V3AuthVotingInterval is insanely low.");
|
||||
} else {
|
||||
COMPLAIN("V3AuthVotingInterval is very low. "
|
||||
"This may lead to failure to synchronise for a consensus.");
|
||||
}
|
||||
} else {
|
||||
REJECT("V3AuthVotingInterval is insanely low.");
|
||||
}
|
||||
} else if (options->V3AuthVotingInterval > 24*60*60) {
|
||||
REJECT("V3AuthVotingInterval is insanely high.");
|
||||
} else if (((24*60*60) % options->V3AuthVotingInterval) != 0) {
|
||||
@@ -3431,15 +3530,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
AF_INET6, 1, msg)<0)
|
||||
return -1;
|
||||
|
||||
if (options->AutomapHostsSuffixes) {
|
||||
SMARTLIST_FOREACH(options->AutomapHostsSuffixes, char *, suf,
|
||||
{
|
||||
size_t len = strlen(suf);
|
||||
if (len && suf[len-1] == '.')
|
||||
suf[len-1] = '\0';
|
||||
});
|
||||
}
|
||||
|
||||
if (options->TestingTorNetwork &&
|
||||
!(options->DirAuthorities ||
|
||||
(options->AlternateDirAuthority &&
|
||||
@@ -3484,26 +3574,27 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
CHECK_DEFAULT(TestingCertMaxDownloadTries);
|
||||
#undef CHECK_DEFAULT
|
||||
|
||||
if (options->TestingV3AuthInitialVotingInterval < MIN_VOTE_INTERVAL) {
|
||||
if (options->TestingV3AuthInitialVotingInterval
|
||||
< MIN_VOTE_INTERVAL_TESTING_INITIAL) {
|
||||
REJECT("TestingV3AuthInitialVotingInterval is insanely low.");
|
||||
} else if (((30*60) % options->TestingV3AuthInitialVotingInterval) != 0) {
|
||||
REJECT("TestingV3AuthInitialVotingInterval does not divide evenly into "
|
||||
"30 minutes.");
|
||||
}
|
||||
|
||||
if (options->TestingV3AuthInitialVoteDelay < MIN_VOTE_SECONDS) {
|
||||
if (options->TestingV3AuthInitialVoteDelay < MIN_VOTE_SECONDS_TESTING) {
|
||||
REJECT("TestingV3AuthInitialVoteDelay is way too low.");
|
||||
}
|
||||
|
||||
if (options->TestingV3AuthInitialDistDelay < MIN_DIST_SECONDS) {
|
||||
if (options->TestingV3AuthInitialDistDelay < MIN_DIST_SECONDS_TESTING) {
|
||||
REJECT("TestingV3AuthInitialDistDelay is way too low.");
|
||||
}
|
||||
|
||||
if (options->TestingV3AuthInitialVoteDelay +
|
||||
options->TestingV3AuthInitialDistDelay >=
|
||||
options->TestingV3AuthInitialVotingInterval/2) {
|
||||
options->TestingV3AuthInitialVotingInterval) {
|
||||
REJECT("TestingV3AuthInitialVoteDelay plus TestingV3AuthInitialDistDelay "
|
||||
"must be less than half TestingV3AuthInitialVotingInterval");
|
||||
"must be less than TestingV3AuthInitialVotingInterval");
|
||||
}
|
||||
|
||||
if (options->TestingV3AuthVotingStartOffset >
|
||||
@@ -3511,6 +3602,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
options->V3AuthVotingInterval)) {
|
||||
REJECT("TestingV3AuthVotingStartOffset is higher than the voting "
|
||||
"interval.");
|
||||
} else if (options->TestingV3AuthVotingStartOffset < 0) {
|
||||
REJECT("TestingV3AuthVotingStartOffset must be non-negative.");
|
||||
}
|
||||
|
||||
if (options->TestingAuthDirTimeToLearnReachability < 0) {
|
||||
@@ -3831,6 +3924,7 @@ options_transition_affects_descriptor(const or_options_t *old_options,
|
||||
!opt_streq(old_options->Nickname,new_options->Nickname) ||
|
||||
!opt_streq(old_options->Address,new_options->Address) ||
|
||||
!config_lines_eq(old_options->ExitPolicy,new_options->ExitPolicy) ||
|
||||
old_options->ExitRelay != new_options->ExitRelay ||
|
||||
old_options->ExitPolicyRejectPrivate !=
|
||||
new_options->ExitPolicyRejectPrivate ||
|
||||
old_options->IPv6Exit != new_options->IPv6Exit ||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#include "or.h"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_CONFPARSE_H
|
||||
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -544,8 +544,7 @@ connection_free_(connection_t *conn)
|
||||
or_conn, TLS_CHAN_TO_BASE(or_conn->chan),
|
||||
U64_PRINTF_ARG(
|
||||
TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier));
|
||||
if (!(TLS_CHAN_TO_BASE(or_conn->chan)->state == CHANNEL_STATE_CLOSED ||
|
||||
TLS_CHAN_TO_BASE(or_conn->chan)->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_FINISHED(TLS_CHAN_TO_BASE(or_conn->chan))) {
|
||||
channel_close_for_error(TLS_CHAN_TO_BASE(or_conn->chan));
|
||||
}
|
||||
|
||||
@@ -575,8 +574,10 @@ connection_free_(connection_t *conn)
|
||||
tor_free(control_conn->incoming_cmd);
|
||||
}
|
||||
|
||||
tor_free(conn->read_event); /* Probably already freed by connection_free. */
|
||||
tor_free(conn->write_event); /* Probably already freed by connection_free. */
|
||||
/* Probably already freed by connection_free. */
|
||||
tor_event_free(conn->read_event);
|
||||
tor_event_free(conn->write_event);
|
||||
conn->read_event = conn->write_event = NULL;
|
||||
IF_HAS_BUFFEREVENT(conn, {
|
||||
/* This was a workaround to handle bugs in some old versions of libevent
|
||||
* where callbacks can occur after calling bufferevent_free(). Setting
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+48
-13
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -46,6 +46,19 @@
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV4_H
|
||||
#include <linux/netfilter_ipv4.h>
|
||||
#define TRANS_NETFILTER
|
||||
#define TRANS_NETFILTER_IPV4
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_IF_H
|
||||
#include <linux/if.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
|
||||
#include <linux/netfilter_ipv6/ip6_tables.h>
|
||||
#if defined(IP6T_SO_ORIGINAL_DST)
|
||||
#define TRANS_NETFILTER
|
||||
#define TRANS_NETFILTER_IPV6
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
|
||||
@@ -745,14 +758,6 @@ connection_ap_fail_onehop(const char *failed_digest,
|
||||
tor_addr_t addr;
|
||||
if (!build_state || !build_state->chosen_exit ||
|
||||
!entry_conn->socks_request) {
|
||||
/* clang thinks that an array midway through a structure
|
||||
* will never have a NULL address, under either:
|
||||
* -Wpointer-bool-conversion if using !, or
|
||||
* -Wtautological-pointer-compare if using == or !=
|
||||
* It's probably right (unless pointers overflow and wrap),
|
||||
* so we just skip this check
|
||||
|| !entry_conn->socks_request->address
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
if (tor_addr_parse(&addr, entry_conn->socks_request->address)<0 ||
|
||||
@@ -1409,10 +1414,29 @@ destination_from_socket(entry_connection_t *conn, socks_request_t *req)
|
||||
struct sockaddr_storage orig_dst;
|
||||
socklen_t orig_dst_len = sizeof(orig_dst);
|
||||
tor_addr_t addr;
|
||||
int rv;
|
||||
|
||||
#ifdef TRANS_NETFILTER
|
||||
if (getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IP, SO_ORIGINAL_DST,
|
||||
(struct sockaddr*)&orig_dst, &orig_dst_len) < 0) {
|
||||
switch (ENTRY_TO_CONN(conn)->socket_family) {
|
||||
#ifdef TRANS_NETFILTER_IPV4
|
||||
case AF_INET:
|
||||
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IP, SO_ORIGINAL_DST,
|
||||
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
||||
break;
|
||||
#endif
|
||||
#ifdef TRANS_NETFILTER_IPV6
|
||||
case AF_INET6:
|
||||
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IPV6, IP6T_SO_ORIGINAL_DST,
|
||||
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
log_warn(LD_BUG,
|
||||
"Received transparent data from an unsuported socket family %d",
|
||||
ENTRY_TO_CONN(conn)->socket_family);
|
||||
return -1;
|
||||
}
|
||||
if (rv < 0) {
|
||||
int e = tor_socket_errno(ENTRY_TO_CONN(conn)->s);
|
||||
log_warn(LD_NET, "getsockopt() failed: %s", tor_socket_strerror(e));
|
||||
return -1;
|
||||
@@ -2589,12 +2613,23 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
|
||||
if (rend_service_set_connection_addr_port(n_stream, origin_circ) < 0) {
|
||||
log_info(LD_REND,"Didn't find rendezvous service (port %d)",
|
||||
n_stream->base_.port);
|
||||
/* Send back reason DONE because we want to make hidden service port
|
||||
* scanning harder thus instead of returning that the exit policy
|
||||
* didn't match, which makes it obvious that the port is closed,
|
||||
* return DONE and kill the circuit. That way, a user (malicious or
|
||||
* not) needs one circuit per bad port unless it matches the policy of
|
||||
* the hidden service. */
|
||||
relay_send_end_cell_from_edge(rh.stream_id, circ,
|
||||
END_STREAM_REASON_EXITPOLICY,
|
||||
END_STREAM_REASON_DONE,
|
||||
origin_circ->cpath->prev);
|
||||
connection_free(TO_CONN(n_stream));
|
||||
tor_free(address);
|
||||
return 0;
|
||||
|
||||
/* Drop the circuit here since it might be someone deliberately
|
||||
* scanning the hidden service ports. Note that this mitigates port
|
||||
* scanning by adding more work on the attacker side to successfully
|
||||
* scan but does not fully solve it. */
|
||||
return END_CIRC_AT_ORIGIN;
|
||||
}
|
||||
assert_circuit_ok(circ);
|
||||
log_debug(LD_REND,"Finished assigning addr/port");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+4
-10
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1149,9 +1149,7 @@ connection_or_notify_error(or_connection_t *conn,
|
||||
if (conn->chan) {
|
||||
chan = TLS_CHAN_TO_BASE(conn->chan);
|
||||
/* Don't transition if we're already in closing, closed or error */
|
||||
if (!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(chan)) {
|
||||
channel_close_for_error(chan);
|
||||
}
|
||||
}
|
||||
@@ -1310,9 +1308,7 @@ connection_or_close_normally(or_connection_t *orconn, int flush)
|
||||
if (orconn->chan) {
|
||||
chan = TLS_CHAN_TO_BASE(orconn->chan);
|
||||
/* Don't transition if we're already in closing, closed or error */
|
||||
if (!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(chan)) {
|
||||
channel_close_from_lower_layer(chan);
|
||||
}
|
||||
}
|
||||
@@ -1333,9 +1329,7 @@ connection_or_close_for_error(or_connection_t *orconn, int flush)
|
||||
if (orconn->chan) {
|
||||
chan = TLS_CHAN_TO_BASE(orconn->chan);
|
||||
/* Don't transition if we're already in closing, closed or error */
|
||||
if (!(chan->state == CHANNEL_STATE_CLOSING ||
|
||||
chan->state == CHANNEL_STATE_CLOSED ||
|
||||
chan->state == CHANNEL_STATE_ERROR)) {
|
||||
if (!CHANNEL_CONDEMNED(chan)) {
|
||||
channel_close_for_error(chan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+84
-6
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1438,6 +1438,8 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
|
||||
(void) conn;
|
||||
if (!strcmp(question, "version")) {
|
||||
*answer = tor_strdup(get_version());
|
||||
} else if (!strcmp(question, "bw-event-cache")) {
|
||||
*answer = get_bw_samples();
|
||||
} else if (!strcmp(question, "config-file")) {
|
||||
*answer = tor_strdup(get_torrc_fname(0));
|
||||
} else if (!strcmp(question, "config-defaults-file")) {
|
||||
@@ -2113,6 +2115,7 @@ typedef struct getinfo_item_t {
|
||||
* to answer them. */
|
||||
static const getinfo_item_t getinfo_items[] = {
|
||||
ITEM("version", misc, "The current version of Tor."),
|
||||
ITEM("bw-event-cache", misc, "Cached BW events for a short interval."),
|
||||
ITEM("config-file", misc, "Current location of the \"torrc\" file."),
|
||||
ITEM("config-defaults-file", misc, "Current location of the defaults file."),
|
||||
ITEM("config-text", misc,
|
||||
@@ -2465,6 +2468,14 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len,
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (smartlist_len(args) < 2) {
|
||||
connection_printf_to_buf(conn,
|
||||
"512 syntax error: not enough arguments.\r\n");
|
||||
SMARTLIST_FOREACH(args, char *, cp, tor_free(cp));
|
||||
smartlist_free(args);
|
||||
goto done;
|
||||
}
|
||||
|
||||
smartlist_split_string(router_nicknames, smartlist_get(args,1), ",", 0, 0);
|
||||
|
||||
SMARTLIST_FOREACH(args, char *, cp, tor_free(cp));
|
||||
@@ -4147,11 +4158,29 @@ control_event_tb_empty(const char *bucket, uint32_t read_empty_time,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* about 5 minutes worth. */
|
||||
#define N_BW_EVENTS_TO_CACHE 300
|
||||
/* Index into cached_bw_events to next write. */
|
||||
static int next_measurement_idx = 0;
|
||||
/* number of entries set in n_measurements */
|
||||
static int n_measurements = 0;
|
||||
static struct cached_bw_event_s {
|
||||
uint32_t n_read;
|
||||
uint32_t n_written;
|
||||
} cached_bw_events[N_BW_EVENTS_TO_CACHE];
|
||||
|
||||
/** A second or more has elapsed: tell any interested control
|
||||
* connections how much bandwidth we used. */
|
||||
int
|
||||
control_event_bandwidth_used(uint32_t n_read, uint32_t n_written)
|
||||
{
|
||||
cached_bw_events[next_measurement_idx].n_read = n_read;
|
||||
cached_bw_events[next_measurement_idx].n_written = n_written;
|
||||
if (++next_measurement_idx == N_BW_EVENTS_TO_CACHE)
|
||||
next_measurement_idx = 0;
|
||||
if (n_measurements < N_BW_EVENTS_TO_CACHE)
|
||||
++n_measurements;
|
||||
|
||||
if (EVENT_IS_INTERESTING(EVENT_BANDWIDTH_USED)) {
|
||||
send_control_event(EVENT_BANDWIDTH_USED, ALL_FORMATS,
|
||||
"650 BW %lu %lu\r\n",
|
||||
@@ -4162,6 +4191,35 @@ control_event_bandwidth_used(uint32_t n_read, uint32_t n_written)
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
get_bw_samples(void)
|
||||
{
|
||||
int i;
|
||||
int idx = (next_measurement_idx + N_BW_EVENTS_TO_CACHE - n_measurements)
|
||||
% N_BW_EVENTS_TO_CACHE;
|
||||
tor_assert(0 <= idx && idx < N_BW_EVENTS_TO_CACHE);
|
||||
|
||||
smartlist_t *elements = smartlist_new();
|
||||
|
||||
for (i = 0; i < n_measurements; ++i) {
|
||||
tor_assert(0 <= idx && idx < N_BW_EVENTS_TO_CACHE);
|
||||
const struct cached_bw_event_s *bwe = &cached_bw_events[idx];
|
||||
|
||||
smartlist_add_asprintf(elements, "%u,%u",
|
||||
(unsigned)bwe->n_read,
|
||||
(unsigned)bwe->n_written);
|
||||
|
||||
idx = (idx + 1) % N_BW_EVENTS_TO_CACHE;
|
||||
}
|
||||
|
||||
char *result = smartlist_join_strings(elements, " ", 0, NULL);
|
||||
|
||||
SMARTLIST_FOREACH(elements, char *, cp, tor_free(cp));
|
||||
smartlist_free(elements);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Called when we are sending a log message to the controllers: suspend
|
||||
* sending further log messages to the controllers until we're done. Used by
|
||||
* CONN_LOG_PROTECT. */
|
||||
@@ -4807,23 +4865,43 @@ bootstrap_status_to_string(bootstrap_status_t s, const char **tag,
|
||||
break;
|
||||
case BOOTSTRAP_STATUS_REQUESTING_DESCRIPTORS:
|
||||
*tag = "requesting_descriptors";
|
||||
*summary = "Asking for relay descriptors";
|
||||
/* XXXX this appears to incorrectly report internal on most loads */
|
||||
*summary = router_have_consensus_path() == CONSENSUS_PATH_INTERNAL ?
|
||||
"Asking for relay descriptors for internal paths" :
|
||||
"Asking for relay descriptors";
|
||||
break;
|
||||
/* If we're sure there are no exits in the consensus,
|
||||
* inform the controller by adding "internal"
|
||||
* to the status summaries.
|
||||
* (We only check this while loading descriptors,
|
||||
* so we may not know in the earlier stages.)
|
||||
* But if there are exits, we can't be sure whether
|
||||
* we're creating internal or exit paths/circuits.
|
||||
* XXXX Or should be use different tags or statuses
|
||||
* for internal and exit/all? */
|
||||
case BOOTSTRAP_STATUS_LOADING_DESCRIPTORS:
|
||||
*tag = "loading_descriptors";
|
||||
*summary = "Loading relay descriptors";
|
||||
*summary = router_have_consensus_path() == CONSENSUS_PATH_INTERNAL ?
|
||||
"Loading relay descriptors for internal paths" :
|
||||
"Loading relay descriptors";
|
||||
break;
|
||||
case BOOTSTRAP_STATUS_CONN_OR:
|
||||
*tag = "conn_or";
|
||||
*summary = "Connecting to the Tor network";
|
||||
*summary = router_have_consensus_path() == CONSENSUS_PATH_INTERNAL ?
|
||||
"Connecting to the Tor network internally" :
|
||||
"Connecting to the Tor network";
|
||||
break;
|
||||
case BOOTSTRAP_STATUS_HANDSHAKE_OR:
|
||||
*tag = "handshake_or";
|
||||
*summary = "Finishing handshake with first hop";
|
||||
*summary = router_have_consensus_path() == CONSENSUS_PATH_INTERNAL ?
|
||||
"Finishing handshake with first hop of internal circuit" :
|
||||
"Finishing handshake with first hop";
|
||||
break;
|
||||
case BOOTSTRAP_STATUS_CIRCUIT_CREATE:
|
||||
*tag = "circuit_create";
|
||||
*summary = "Establishing a Tor circuit";
|
||||
*summary = router_have_consensus_path() == CONSENSUS_PATH_INTERNAL ?
|
||||
"Establishing an internal Tor circuit" :
|
||||
"Establishing a Tor circuit";
|
||||
break;
|
||||
case BOOTSTRAP_STATUS_DONE:
|
||||
*tag = "done";
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -203,6 +203,7 @@ void append_cell_stats_by_command(smartlist_t *event_parts,
|
||||
const uint64_t *number_to_include);
|
||||
void format_cell_stats(char **event_string, circuit_t *circ,
|
||||
cell_stats_t *cell_stats);
|
||||
STATIC char *get_bw_samples(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+52
-10
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#include "or.h"
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "networkstatus.h"
|
||||
#include "nodelist.h"
|
||||
#include "policies.h"
|
||||
#include "relay.h"
|
||||
#include "rendclient.h"
|
||||
#include "rendcommon.h"
|
||||
#include "rephist.h"
|
||||
@@ -433,18 +434,33 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
|
||||
if (resource)
|
||||
flav = networkstatus_parse_flavor_name(resource);
|
||||
|
||||
/* DEFAULT_IF_MODIFIED_SINCE_DELAY is 1/20 of the default consensus
|
||||
* period of 1 hour.
|
||||
*/
|
||||
#define DEFAULT_IF_MODIFIED_SINCE_DELAY (180)
|
||||
if (flav != -1) {
|
||||
/* IF we have a parsed consensus of this type, we can do an
|
||||
* if-modified-time based on it. */
|
||||
v = networkstatus_get_latest_consensus_by_flavor(flav);
|
||||
if (v)
|
||||
if_modified_since = v->valid_after + 180;
|
||||
if (v) {
|
||||
/* In networks with particularly short V3AuthVotingIntervals,
|
||||
* ask for the consensus if it's been modified since half the
|
||||
* V3AuthVotingInterval of the most recent consensus. */
|
||||
time_t ims_delay = DEFAULT_IF_MODIFIED_SINCE_DELAY;
|
||||
if (v->fresh_until > v->valid_after
|
||||
&& ims_delay > (v->fresh_until - v->valid_after)/2) {
|
||||
ims_delay = (v->fresh_until - v->valid_after)/2;
|
||||
}
|
||||
if_modified_since = v->valid_after + ims_delay;
|
||||
}
|
||||
} else {
|
||||
/* Otherwise it might be a consensus we don't parse, but which we
|
||||
* do cache. Look at the cached copy, perhaps. */
|
||||
cached_dir_t *cd = dirserv_get_consensus(resource);
|
||||
/* We have no method of determining the voting interval from an
|
||||
* unparsed consensus, so we use the default. */
|
||||
if (cd)
|
||||
if_modified_since = cd->published + 180;
|
||||
if_modified_since = cd->published + DEFAULT_IF_MODIFIED_SINCE_DELAY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2258,6 +2274,7 @@ write_http_status_line(dir_connection_t *conn, int status,
|
||||
log_warn(LD_BUG,"status line too long.");
|
||||
return;
|
||||
}
|
||||
log_debug(LD_DIRSERV,"Wrote status 'HTTP/1.0 %d %s'", status, reason_phrase);
|
||||
connection_write_to_buf(buf, strlen(buf), TO_CONN(conn));
|
||||
}
|
||||
|
||||
@@ -2523,6 +2540,24 @@ client_likes_consensus(networkstatus_t *v, const char *want_url)
|
||||
return (have >= need_at_least);
|
||||
}
|
||||
|
||||
/** Return the compression level we should use for sending a compressed
|
||||
* response of size <b>n_bytes</b>. */
|
||||
static zlib_compression_level_t
|
||||
choose_compression_level(ssize_t n_bytes)
|
||||
{
|
||||
if (! have_been_under_memory_pressure()) {
|
||||
return HIGH_COMPRESSION; /* we have plenty of RAM. */
|
||||
} else if (n_bytes < 0) {
|
||||
return HIGH_COMPRESSION; /* unknown; might be big. */
|
||||
} else if (n_bytes < 1024) {
|
||||
return LOW_COMPRESSION;
|
||||
} else if (n_bytes < 2048) {
|
||||
return MEDIUM_COMPRESSION;
|
||||
} else {
|
||||
return HIGH_COMPRESSION;
|
||||
}
|
||||
}
|
||||
|
||||
/** Helper function: called when a dirserver gets a complete HTTP GET
|
||||
* request. Look for a request for a directory or for a rendezvous
|
||||
* service descriptor. On finding one, write a response into
|
||||
@@ -2554,8 +2589,11 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
if ((header = http_get_header(headers, "If-Modified-Since: "))) {
|
||||
struct tm tm;
|
||||
if (parse_http_time(header, &tm) == 0) {
|
||||
if (tor_timegm(&tm, &if_modified_since)<0)
|
||||
if (tor_timegm(&tm, &if_modified_since)<0) {
|
||||
if_modified_since = 0;
|
||||
} else {
|
||||
log_debug(LD_DIRSERV, "If-Modified-Since is '%s'.", escaped(header));
|
||||
}
|
||||
}
|
||||
/* The correct behavior on a malformed If-Modified-Since header is to
|
||||
* act as if no If-Modified-Since header had been given. */
|
||||
@@ -2705,7 +2743,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
smartlist_len(dir_fps) == 1 ? lifetime : 0);
|
||||
conn->fingerprint_stack = dir_fps;
|
||||
if (! compressed)
|
||||
conn->zlib_state = tor_zlib_new(0, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(0, ZLIB_METHOD, HIGH_COMPRESSION);
|
||||
|
||||
/* Prime the connection with some data. */
|
||||
conn->dir_spool_src = DIR_SPOOL_NETWORKSTATUS;
|
||||
@@ -2793,7 +2831,8 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
|
||||
if (smartlist_len(items)) {
|
||||
if (compressed) {
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(estimated_len));
|
||||
SMARTLIST_FOREACH(items, const char *, c,
|
||||
connection_write_to_buf_zlib(c, strlen(c), conn, 0));
|
||||
connection_write_to_buf_zlib("", 0, conn, 1);
|
||||
@@ -2842,7 +2881,8 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
conn->fingerprint_stack = fps;
|
||||
|
||||
if (compressed)
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(dlen));
|
||||
|
||||
connection_dirserv_flushed_some(conn);
|
||||
goto done;
|
||||
@@ -2910,7 +2950,8 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
}
|
||||
write_http_response_header(conn, -1, compressed, cache_lifetime);
|
||||
if (compressed)
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(dlen));
|
||||
/* Prime the connection with some data. */
|
||||
connection_dirserv_flushed_some(conn);
|
||||
}
|
||||
@@ -2985,7 +3026,8 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
|
||||
write_http_response_header(conn, compressed?-1:len, compressed, 60*60);
|
||||
if (compressed) {
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(len));
|
||||
SMARTLIST_FOREACH(certs, authority_cert_t *, c,
|
||||
connection_write_to_buf_zlib(c->cache_info.signed_descriptor_body,
|
||||
c->cache_info.signed_descriptor_len,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+23
-9
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define DIRSERV_PRIVATE
|
||||
@@ -733,7 +733,7 @@ running_long_enough_to_decide_unreachable(void)
|
||||
}
|
||||
|
||||
/** Each server needs to have passed a reachability test no more
|
||||
* than this number of seconds ago, or he is listed as down in
|
||||
* than this number of seconds ago, or it is listed as down in
|
||||
* the directory. */
|
||||
#define REACHABLE_TIMEOUT (45*60)
|
||||
|
||||
@@ -887,12 +887,26 @@ static int
|
||||
router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
|
||||
{
|
||||
time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
|
||||
if (ri->cache_info.published_on < cutoff)
|
||||
if (ri->cache_info.published_on < cutoff) {
|
||||
return 0;
|
||||
if (!node->is_running || !node->is_valid || ri->is_hibernating)
|
||||
}
|
||||
if (!node->is_running || !node->is_valid || ri->is_hibernating) {
|
||||
return 0;
|
||||
if (!ri->bandwidthcapacity)
|
||||
}
|
||||
/* Only require bandwith capacity in non-test networks, or
|
||||
* if TestingTorNetwork, and TestingMinExitFlagThreshold is non-zero */
|
||||
if (!ri->bandwidthcapacity) {
|
||||
if (get_options()->TestingTorNetwork) {
|
||||
if (get_options()->TestingMinExitFlagThreshold > 0) {
|
||||
/* If we're in a TestingTorNetwork, and TestingMinExitFlagThreshold is,
|
||||
* then require bandwidthcapacity */
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* If we're not in a TestingTorNetwork, then require bandwidthcapacity */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1051,7 @@ directory_fetches_dir_info_later(const or_options_t *options)
|
||||
}
|
||||
|
||||
/** Return true iff we want to fetch and keep certificates for authorities
|
||||
* that we don't acknowledge as aurthorities ourself.
|
||||
* that we don't acknowledge as authorities ourself.
|
||||
*/
|
||||
int
|
||||
directory_caches_unknown_auth_certs(const or_options_t *options)
|
||||
@@ -1498,7 +1512,7 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
|
||||
(unsigned long)guard_tk,
|
||||
(unsigned long)guard_bandwidth_including_exits_kb,
|
||||
(unsigned long)guard_bandwidth_excluding_exits_kb,
|
||||
enough_mtbf_info ? "" : " don't ");
|
||||
enough_mtbf_info ? "" : " don't");
|
||||
|
||||
tor_free(uptimes);
|
||||
tor_free(mtbfs);
|
||||
@@ -2246,7 +2260,7 @@ int
|
||||
dirserv_read_measured_bandwidths(const char *from_file,
|
||||
smartlist_t *routerstatuses)
|
||||
{
|
||||
char line[256];
|
||||
char line[512];
|
||||
FILE *fp = tor_fopen_cloexec(from_file, "r");
|
||||
int applied_lines = 0;
|
||||
time_t file_time, now;
|
||||
@@ -3182,7 +3196,7 @@ connection_dirserv_add_networkstatus_bytes_to_outbuf(dir_connection_t *conn)
|
||||
if (uncompressing && ! conn->zlib_state &&
|
||||
conn->fingerprint_stack &&
|
||||
smartlist_len(conn->fingerprint_stack)) {
|
||||
conn->zlib_state = tor_zlib_new(0, ZLIB_METHOD);
|
||||
conn->zlib_state = tor_zlib_new(0, ZLIB_METHOD, HIGH_COMPRESSION);
|
||||
}
|
||||
}
|
||||
if (r) return r;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#define DIRVOTE_PRIVATE
|
||||
@@ -1107,8 +1107,12 @@ networkstatus_compute_consensus(smartlist_t *votes,
|
||||
vote_seconds = median_int(votesec_list, n_votes);
|
||||
dist_seconds = median_int(distsec_list, n_votes);
|
||||
|
||||
tor_assert(valid_after+MIN_VOTE_INTERVAL <= fresh_until);
|
||||
tor_assert(fresh_until+MIN_VOTE_INTERVAL <= valid_until);
|
||||
tor_assert(valid_after +
|
||||
(get_options()->TestingTorNetwork ?
|
||||
MIN_VOTE_INTERVAL_TESTING : MIN_VOTE_INTERVAL) <= fresh_until);
|
||||
tor_assert(fresh_until +
|
||||
(get_options()->TestingTorNetwork ?
|
||||
MIN_VOTE_INTERVAL_TESTING : MIN_VOTE_INTERVAL) <= valid_until);
|
||||
tor_assert(vote_seconds >= MIN_VOTE_SECONDS);
|
||||
tor_assert(dist_seconds >= MIN_DIST_SECONDS);
|
||||
|
||||
@@ -2706,7 +2710,7 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
|
||||
goto discard;
|
||||
} else if (v->vote->published < vote->published) {
|
||||
log_notice(LD_DIR, "Replacing an older pending vote from this "
|
||||
"directory.");
|
||||
"directory (%s)", vi->address);
|
||||
cached_dir_decref(v->vote_body);
|
||||
networkstatus_vote_free(v->vote);
|
||||
v->vote_body = new_cached_dir(tor_strndup(vote_body,
|
||||
|
||||
+32
-2
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -14,12 +14,42 @@
|
||||
|
||||
#include "testsupport.h"
|
||||
|
||||
/*
|
||||
* Ideally, assuming synced clocks, we should only need 1 second for each of:
|
||||
* - Vote
|
||||
* - Distribute
|
||||
* - Consensus Publication
|
||||
* As we can gather descriptors continuously.
|
||||
* (Could we even go as far as publishing the previous consensus,
|
||||
* in the same second that we vote for the next one?)
|
||||
* But we're not there yet: these are the lowest working values at this time.
|
||||
*/
|
||||
|
||||
/** Lowest allowable value for VoteSeconds. */
|
||||
#define MIN_VOTE_SECONDS 2
|
||||
/** Lowest allowable value for VoteSeconds when TestingTorNetwork is 1 */
|
||||
#define MIN_VOTE_SECONDS_TESTING 2
|
||||
|
||||
/** Lowest allowable value for DistSeconds. */
|
||||
#define MIN_DIST_SECONDS 2
|
||||
/** Smallest allowable voting interval. */
|
||||
/** Lowest allowable value for DistSeconds when TestingTorNetwork is 1 */
|
||||
#define MIN_DIST_SECONDS_TESTING 2
|
||||
|
||||
/** Lowest allowable voting interval. */
|
||||
#define MIN_VOTE_INTERVAL 300
|
||||
/** Lowest allowable voting interval when TestingTorNetwork is 1:
|
||||
* Voting Interval can be:
|
||||
* 10, 12, 15, 18, 20, 24, 25, 30, 36, 40, 45, 50, 60, ...
|
||||
* Testing Initial Voting Interval can be:
|
||||
* 5, 6, 8, 9, or any of the possible values for Voting Interval,
|
||||
* as they both need to evenly divide 30 minutes.
|
||||
* If clock desynchronisation is an issue, use an interval of at least:
|
||||
* 18 * drift in seconds, to allow for a clock slop factor */
|
||||
#define MIN_VOTE_INTERVAL_TESTING \
|
||||
(((MIN_VOTE_SECONDS_TESTING)+(MIN_DIST_SECONDS_TESTING)+1)*2)
|
||||
|
||||
#define MIN_VOTE_INTERVAL_TESTING_INITIAL \
|
||||
((MIN_VOTE_SECONDS_TESTING)+(MIN_DIST_SECONDS_TESTING)+1)
|
||||
|
||||
/** The lowest consensus method that we currently support. */
|
||||
#define MIN_SUPPORTED_CONSENSUS_METHOD 13
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
@@ -1319,7 +1319,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
|
||||
"EntryGuardDownSince/UnlistedSince without EntryGuard");
|
||||
break;
|
||||
}
|
||||
if (parse_iso_time(line->value, &when)<0) {
|
||||
if (parse_iso_time_(line->value, &when, 0)<0) {
|
||||
*msg = tor_strdup("Unable to parse entry nodes: "
|
||||
"Bad time in EntryGuardDownSince/UnlistedSince");
|
||||
break;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_EVENTDNS_TOR_H
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012, The Tor Project, Inc. */
|
||||
/* Copyright (c) 2012-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2014, The Tor Project, Inc. */
|
||||
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef EXT_ORPORT_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user