56#define CONNECTION_EDGE_PRIVATE
76#include "core/or/dos.h"
85#include "feature/client/circpathbias.h"
117#include "core/or/or_circuit_st.h"
123#ifdef HAVE_LINUX_TYPES_H
124#include <linux/types.h>
126#ifdef HAVE_LINUX_NETFILTER_IPV4_H
127#include <linux/netfilter_ipv4.h>
128#define TRANS_NETFILTER
129#define TRANS_NETFILTER_IPV4
132#ifdef HAVE_LINUX_IF_H
136#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
137#include <linux/netfilter_ipv6/ip6_tables.h>
138#if defined(IP6T_SO_ORIGINAL_DST)
139#define TRANS_NETFILTER
140#define TRANS_NETFILTER_IPV6
147#ifdef HAVE_SYS_IOCTL_H
148#include <sys/ioctl.h>
150#ifdef HAVE_SYS_PARAM_H
151#include <sys/param.h>
154#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
156#include <net/pfvar.h>
164#define SOCKS4_GRANTED 90
165#define SOCKS4_REJECT 91
184 c->
magic == ENTRY_CONNECTION_MAGIC);
256 int line,
const char *file))
271 "stream (marked at %s:%d) sending two socks replies?",
278 RESOLVED_TYPE_ERROR_TRANSIENT,
294 if (connection_get_inbuf_len(
TO_CONN(conn)) &&
299 log_info(
LD_EDGE,
"conn (fd "TOR_SOCKET_T_FORMAT
") reached eof. Closing.",
310 connection_mark_for_close(
TO_CONN(conn));
330 switch (conn->base_.
state) {
349 if (! conn->base_.
linked) {
357 connection_mark_for_close(
TO_CONN(conn));
364 "data from edge while in '%s' state. Sending it anyway. "
365 "package_partial=%d, buflen=%ld",
368 (
long)connection_get_inbuf_len(
TO_CONN(conn)));
371 connection_mark_for_close(
TO_CONN(conn));
385 "data from edge while in '%s' state. Leaving it on buffer.",
389 log_warn(
LD_BUG,
"Got unexpected state %d. Closing.",conn->base_.
state);
392 connection_mark_for_close(
TO_CONN(conn));
403 log_info(
LD_EDGE,
"CircID %u: At an edge. Marking connection for close.",
407 connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_DESTROY);
410 END_STREAM_REASON_DESTROY);
417 connection_mark_and_flush(
TO_CONN(conn));
438 reason = END_STREAM_REASON_MISC;
441 payload[0] = (char) reason;
447 return relay_send_command_from_edge(stream_id, circ, RELAY_COMMAND_END,
448 payload, 1, cpath_layer);
462 (reason == END_STREAM_REASON_CONNECTREFUSED ||
463 reason == END_STREAM_REASON_TIMEOUT)) {
464#define WARN_FAILED_HS_CONNECTION 300
465 static ratelim_t warn_limit = RATELIM_INIT(WARN_FAILED_HS_CONNECTION);
468 log_warn(
LD_EDGE,
"Onion service connection to %s failed (%s)",
517 size_t payload_len=1;
519 uint8_t control_reason = reason;
522 log_warn(
LD_BUG,
"(Harmless.) Calling connection_edge_end (reason %d) "
523 "on an already ended stream?", reason);
530 "called on conn that's already marked for close at %s:%d.",
540 reason = END_STREAM_REASON_MISC;
543 payload[0] = (char)reason;
544 if (reason == END_STREAM_REASON_EXITPOLICY &&
555 payload_len += 4+addrlen;
559 log_debug(
LD_EDGE,
"Sending end on conn (fd "TOR_SOCKET_T_FORMAT
").",
568 payload, payload_len);
571 warn_if_hs_unreachable(conn, control_reason);
573 log_debug(
LD_EDGE,
"No circ to send end on conn "
574 "(fd "TOR_SOCKET_T_FORMAT
").",
624 log_warn(
LD_BUG,
"Duplicate stream close for stream %d on circuit %d",
651 if (conn->hs_ident) {
694 } SMARTLIST_FOREACH_END(half_conn);
833 int found, remove_idx;
844 half = smartlist_get(half_conns, remove_idx);
846 half_edge_free(half);
883 switch (conn->base_.
state) {
885 if (! conn->base_.
linked) {
912 switch (conn->base_.
state) {
927 log_warn(
LD_BUG,
"Called in unexpected state %d.",conn->base_.
state);
937#define MAX_CONNECTED_CELL_PAYLOAD_LEN 25
951 int connected_payload_len;
956 if (family == AF_INET) {
958 connected_payload_len = 4;
959 }
else if (family == AF_INET6) {
963 connected_payload_len = 21;
968 set_uint32(payload_out + connected_payload_len, htonl(ttl));
969 connected_payload_len += 4;
973 return connected_payload_len;
987 const char dst_ipv6[] =
"::1";
989 const char src_ipv6_prefix[] =
"fc00:dead:beef:4dad:";
990 uint16_t dst_port = 0;
991 uint16_t src_port = 1;
997 src_port = gid & 0x0000ffff;
1001 if (edge_conn->hs_ident) {
1008 gid >> 16, gid & 0x0000ffff,
1009 dst_ipv6, src_port, dst_port);
1011 connection_buf_add(buf, strlen(buf),
TO_CONN(edge_conn));
1029 log_info(LD_EXIT,
"%s established.",
1037 if (connection_get_outbuf_len(conn))
1043 RELAY_COMMAND_CONNECTED, NULL, 0) < 0)
1047 int connected_payload_len =
1050 if (connected_payload_len < 0)
1054 RELAY_COMMAND_CONNECTED,
1055 (
char*)connected_payload, connected_payload_len) < 0)
1071static int untried_pending_connections = 0;
1085 log_warn(
LD_BUG,
"(Harmless.) Edge connection (marked at %s:%d) "
1086 "hasn't sent end yet?",
1106 log_warn(
LD_BUG,
"Closing stream (marked at %s:%d) without sending"
1107 " back a socks reply.",
1111 log_warn(
LD_BUG,
"Closing stream (marked at %s:%d) without having"
1116 log_warn(
LD_BUG,
"Closing stream (marked at %s:%d) without having"
1117 " replied to DNS request.",
1130 connection_ap_warn_and_unmark_if_pending_circ(entry_conn,
1192 time_t now = time(NULL);
1196 int seconds_idle, seconds_since_born;
1200 if (base_conn->type !=
CONN_TYPE_AP || base_conn->marked_for_close)
1207 seconds_idle = (int)( now - base_conn->timestamp_last_read_allowed );
1208 seconds_since_born = (int)( now - base_conn->timestamp_created );
1223 "Tried for %d seconds to get a connection to %s:%d. "
1229 connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_TIMEOUT);
1238 if (seconds_idle < cutoff)
1242 log_info(
LD_APP,
"Conn is waiting (address %s), but lost its circ.",
1244 connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_TIMEOUT);
1250 "Rend stream is %d seconds late. Giving up on address"
1259 connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_TIMEOUT);
1265 circ->
purpose != CIRCUIT_PURPOSE_CONFLUX_LINKED &&
1271 log_warn(
LD_BUG,
"circuit->purpose == CIRCUIT_PURPOSE_C_GENERAL failed. "
1272 "The purpose on the circuit was %s; it was in state %s, "
1281 "We tried for %d seconds to connect to '%s' using exit %s."
1282 " Retrying on a new circuit.",
1303 END_STREAM_REASON_TIMEOUT)<0) {
1304 if (!base_conn->marked_for_close)
1305 connection_mark_unattached_ap(entry_conn,
1308 } SMARTLIST_FOREACH_END(base_conn);
1325 if (conn->marked_for_close ||
1333 log_warn(
LD_BUG,
"Found a connection %p that was supposed to be "
1334 "in pending_entry_connections, but wasn't. No worries; "
1337 untried_pending_connections = 1;
1338 connection_ap_mark_as_pending_circuit(entry_conn);
1341 } SMARTLIST_FOREACH_END(conn);
1360 if (untried_pending_connections == 0 && !retry)
1376 if (conn->
magic != ENTRY_CONNECTION_MAGIC) {
1377 log_warn(
LD_BUG,
"%p has impossible magic value %u.",
1378 entry_conn, (
unsigned)conn->
magic);
1392 connection_mark_unattached_ap(entry_conn,
1410 } SMARTLIST_FOREACH_END(entry_conn);
1412 smartlist_free(pending);
1413 untried_pending_connections = 0;
1433 const char *fname,
int lineno)
1446 attach_pending_entry_connections_cb, NULL);
1450 log_warn(
LD_BUG,
"What?? pending_entry_connections already contains %p! "
1451 "(Called from %s:%d.)",
1452 entry_conn, fname, lineno);
1453#ifdef DEBUGGING_17659
1454 const char *f2 = entry_conn->marked_pending_circ_file;
1455 log_warn(
LD_BUG,
"(Previously called from %s:%d.)\n",
1457 entry_conn->marked_pending_circ_line);
1463#ifdef DEBUGGING_17659
1464 entry_conn->marked_pending_circ_line = (uint16_t) lineno;
1465 entry_conn->marked_pending_circ_file = fname;
1468 untried_pending_connections = 1;
1505 log_warn(
LD_BUG,
"What was %p doing in pending_entry_connections in %s?",
1524 if (conn->marked_for_close ||
1546 log_info(
LD_APP,
"Closing one-hop stream to '%s/%s' because the OR conn "
1549 connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_TIMEOUT);
1550 } SMARTLIST_FOREACH_END(conn);
1565 if (conn->marked_for_close ||
1574 NNF_NO_WARN_UNNAMED);
1576 if (!r1 || !r2 || r1 != r2)
1580 log_info(
LD_APP,
"Giving up on enclave exit '%s' for destination %s.",
1598 } SMARTLIST_FOREACH_END(conn);
1606 CONNECTION_AP_EXPECT_NONPENDING(conn);
1624 ENTRY_TO_CONN(conn)->timestamp_last_read_allowed = time(NULL);
1640 connection_ap_mark_as_pending_circuit(conn);
1658 log_warn(
LD_APP,
"Application request to port %d: this port is "
1659 "commonly used for unencrypted protocols. Please make sure "
1660 "you don't send anything you would mind the rest of the "
1661 "Internet reading!%s", port, reject ?
" Closing." :
"");
1663 port, reject ?
"REJECT" :
"WARN");
1667 log_info(
LD_APP,
"Port %d listed in RejectPlaintextPorts. Closing.", port);
1668 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
1706 s = strrchr(address,
'.');
1708 *type_out = NORMAL_HOSTNAME;
1711 if (!strcmp(s+1,
"exit")) {
1713 *type_out = EXIT_HOSTNAME;
1716 if (strcmp(s+1,
"onion")) {
1717 *type_out = NORMAL_HOSTNAME;
1724 q = strrchr(address,
'.');
1726 *type_out = BAD_HOSTNAME;
1729 q = (NULL == q) ? address : q + 1;
1732 *type_out = BAD_HOSTNAME;
1736 memmove(address, q, strlen(q) + 1 );
1741 *type_out = ONION_V3_HOSTNAME;
1749 *type_out = BAD_HOSTNAME;
1757 const bool is_onion = (*type_out == ONION_V3_HOSTNAME);
1758 log_warn(
LD_APP,
"Invalid %shostname %s; rejecting",
1759 is_onion ?
"onion " :
"",
1760 safe_str_client(address));
1761 if (*type_out == ONION_V3_HOSTNAME) {
1762 *type_out = BAD_HOSTNAME;
1770#define TRACKHOSTEXITS_RETRIES 5
1798 rewrite_result_t *out)
1807 out->map_expires = TIME_MAX;
1808 out->end_reason = 0;
1809 out->should_close = 0;
1810 out->orig_address[0] = 0;
1815 strlcpy(out->orig_address, socks->
address,
sizeof(out->orig_address));
1816 log_debug(
LD_APP,
"Client asked for %s:%d",
1817 safe_str_client(socks->
address),
1824 static ratelim_t exit_warning_limit = RATELIM_INIT(60*15);
1826 "The \".exit\" notation is disabled in Tor due to "
1830 out->end_reason = END_STREAM_REASON_TORPROTOCOL;
1831 out->should_close = 1;
1850 const unsigned rewrite_flags = AMR_FLAG_USE_MAPADDRESS;
1852 rewrite_flags, &out->map_expires, &out->exit_source)) {
1872 const char *new_addr;
1875 int addr_type = RESOLVED_TYPE_IPV4;
1877 if (!conn->entry_cfg.ipv4_traffic ||
1878 (conn->entry_cfg.ipv6_traffic && conn->entry_cfg.prefer_ipv6) ||
1880 addr_type = RESOLVED_TYPE_IPV6;
1887 addr_type, tor_strdup(socks->
address));
1889 log_warn(
LD_APP,
"Unable to automap address %s",
1891 out->end_reason = END_STREAM_REASON_INTERNAL;
1892 out->should_close = 1;
1895 log_info(
LD_APP,
"Automapping %s to %s",
1897 safe_str_client(new_addr));
1906 unsigned rewrite_flags = 0;
1908 rewrite_flags |= AMR_FLAG_USE_IPV4_DNS;
1909 if (conn->entry_cfg.use_cached_ipv6_answers)
1910 rewrite_flags |= AMR_FLAG_USE_IPV6_DNS;
1913 rewrite_flags, &out->map_expires)) {
1914 char *result = tor_strdup(socks->
address);
1919 strlen(result), (uint8_t*)result,
1923 out->end_reason = END_STREAM_REASON_DONE |
1925 out->should_close = 1;
1937 &addr, socks->
address, AF_UNSPEC, 1);
1938 if (ok == 1 && tor_addr_is_internal(&addr, 0)) {
1940 0, NULL, -1, TIME_MAX);
1943 out->should_close = 1;
1958 unsigned rewrite_flags = AMR_FLAG_USE_AUTOMAP | AMR_FLAG_USE_TRACKEXIT;
1961 rewrite_flags |= AMR_FLAG_USE_IPV4_DNS;
1962 if (conn->entry_cfg.use_cached_ipv6_answers)
1963 rewrite_flags |= AMR_FLAG_USE_IPV6_DNS;
1965 rewrite_flags, &out->map_expires, &exit_source2)) {
1972 out->exit_source = exit_source2;
1985 log_warn(
LD_APP,
"Missing mapping for virtual address '%s'. Refusing.",
1986 safe_str_client(socks->
address));
1987 out->end_reason = END_STREAM_REASON_INTERNAL;
1988 out->should_close = 1;
2005 if (!conn->entry_cfg.onion_traffic) {
2006 log_warn(
LD_APP,
"Onion address %s requested from a port with .onion "
2007 "disabled", safe_str_client(socks->
address));
2008 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2014 if (SOCKS_COMMAND_IS_RESOLVE(socks->
command)) {
2018 "Resolve requests to hidden services not allowed. Failing.");
2020 0,NULL,-1,TIME_MAX);
2021 connection_mark_unattached_ap(conn,
2030 log_warn(
LD_CONTROL,
"Attachstream to a circuit is not "
2031 "supported for .onion addresses currently. Failing.");
2032 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2036 int descriptor_is_usable = 0;
2045 log_warn(
LD_GENERAL,
"failed to parse hs address");
2053 unsigned int refetch_desc = 0;
2056 descriptor_is_usable =
2064 log_info(
LD_REND,
"Descriptor PoW parameters have expired.");
2065 descriptor_is_usable = 0;
2072 log_info(
LD_GENERAL,
"Found %s descriptor in cache for %s. %s.",
2073 (descriptor_is_usable) ?
"usable" :
"unusable",
2074 safe_str_client(socks->
address),
2075 (descriptor_is_usable) ?
"Not fetching." :
"Refetching.");
2078 log_info(
LD_REND,
"No descriptor found in our cache for %s. Fetching.",
2079 safe_str_client(socks->
address));
2091 if (refetch_desc || !descriptor_is_usable) {
2118 log_info(
LD_REND,
"Descriptor is here. Great.");
2123 connection_ap_mark_as_pending_circuit(conn);
2150 time_t now = time(NULL);
2151 rewrite_result_t rr;
2156 memset(&rr, 0,
sizeof(rr));
2157 connection_ap_handshake_rewrite(conn,&rr);
2159 if (rr.should_close) {
2163 connection_mark_unattached_ap(conn, rr.end_reason);
2170 const time_t map_expires = rr.map_expires;
2171 const int automap = rr.automap;
2180 if (addresstype == BAD_HOSTNAME) {
2183 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2193 if (addresstype == EXIT_HOSTNAME) {
2198 const node_t *node = NULL;
2206 log_warn(
LD_APP,
"Stale automapped address for '%s.exit'. Refusing.",
2207 safe_str_client(socks->
address));
2210 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2220 log_warn(
LD_BUG,
"Address '%s.exit', with impossible source for the "
2221 ".exit part. Refusing.",
2222 safe_str_client(socks->
address));
2225 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2236 char *s = strrchr(socks->
address,
'.');
2251 log_warn(
LD_APP,
"Malformed exit address '%s.exit'. Refusing.",
2252 safe_str_client(socks->
address));
2255 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2273 "Unrecognized relay in exit address '%s.exit'. Refusing.",
2274 safe_str_client(socks->
address));
2275 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2281 "Excluded relay in exit address '%s.exit'. Refusing.",
2282 safe_str_client(socks->
address));
2283 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2292 if (addresstype != ONION_V3_HOSTNAME) {
2303 "Destination '%s' seems to be an invalid hostname. Failing.",
2304 safe_str_client(socks->
address));
2305 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2320 if (!conn->entry_cfg.dns_request && !conn->entry_cfg.ipv4_traffic
2321 && !conn->entry_cfg.ipv6_traffic) {
2322 log_warn(
LD_APP,
"Refusing to connect to non-hidden-service hostname "
2323 "or IP address %s because Port has OnionTrafficOnly set (or "
2324 "NoDNSRequest, NoIPv4Traffic, and NoIPv6Traffic).",
2325 safe_str_client(socks->
address));
2326 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2335 if (socks_family == -1) {
2336 if (!conn->entry_cfg.dns_request) {
2337 log_warn(
LD_APP,
"Refusing to connect to hostname %s "
2338 "because Port has NoDNSRequest set.",
2339 safe_str_client(socks->
address));
2340 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2343 }
else if (socks_family == AF_INET) {
2344 if (!conn->entry_cfg.ipv4_traffic) {
2345 log_warn(
LD_APP,
"Refusing to connect to IPv4 address %s because "
2346 "Port has NoIPv4Traffic set.",
2347 safe_str_client(socks->
address));
2348 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2351 }
else if (socks_family == AF_INET6) {
2352 if (!conn->entry_cfg.ipv6_traffic) {
2353 log_warn(
LD_APP,
"Refusing to connect to IPv6 address %s because "
2354 "Port has NoIPv6Traffic set.",
2355 safe_str_client(socks->
address));
2356 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2360 tor_assert_nonfatal_unreached_once();
2371 strlcpy(socks->
address, rr.orig_address,
sizeof(socks->
address));
2374 connection_mark_unattached_ap(conn,
2375 END_STREAM_REASON_DONE |
2386 if (socks->
port == 0) {
2387 log_notice(
LD_APP,
"Application asked to connect to port 0. Refusing.");
2388 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2402 tor_addr_is_internal(&addr, 0))) {
2407#define WARN_INTRVL_LOOP 300
2408 static ratelim_t loop_warn_limit = RATELIM_INIT(WARN_INTRVL_LOOP);
2412 "Rejecting request for anonymous connection to private "
2413 "address %s on a TransPort or NATDPort. Possible loop "
2414 "in your NAT rules?%s", safe_str_client(socks->
address),
2419#define WARN_INTRVL_PRIV 300
2420 static ratelim_t priv_warn_limit = RATELIM_INIT(WARN_INTRVL_PRIV);
2424 "Rejecting SOCKS request for anonymous connection to "
2425 "private address %s.%s",
2426 safe_str_client(socks->
address),m);
2446 if ((family == AF_INET && ! conn->entry_cfg.ipv4_traffic) ||
2447 (family == AF_INET6 && ! conn->entry_cfg.ipv6_traffic)) {
2450 log_warn(
LD_NET,
"Rejecting SOCKS request for an IP address "
2451 "family that this listener does not support.");
2452 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2454 }
else if (family == AF_INET6 && socks->
socks_version == 4) {
2457 log_warn(
LD_NET,
"Rejecting SOCKS4 request for an IPv6 address.");
2458 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2461 !conn->entry_cfg.ipv4_traffic) {
2465 log_warn(
LD_NET,
"Rejecting SOCKS4 request on a listener with "
2466 "no IPv4 traffic supported.");
2467 connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
2469 }
else if (family == AF_INET6) {
2472 conn->entry_cfg.ipv4_traffic = 0;
2473 }
else if (family == AF_INET) {
2476 conn->entry_cfg.ipv6_traffic = 0;
2488 log_warn(
LD_APP,
"Not attempting connection to %s:%d because "
2489 "the network would reject it. Are you trying to send "
2490 "Tor traffic over Tor? This traffic can be harmful to "
2491 "the Tor network. If you really need it, try using "
2492 "a bridge as a workaround.",
2494 connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
2502 conn->entry_cfg.ipv6_traffic = 0;
2516 "Redirecting address %s to exit at enclave router %s",
2560 connection_ap_mark_as_pending_circuit(conn);
2577 tor_assert(addresstype == ONION_V3_HOSTNAME);
2586static int pf_socket = -1;
2604 log_warn(
LD_NET,
"open(\"/dev/pf\") failed: %s", strerror(errno));
2613#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || \
2614 defined(TRANS_TPROXY)
2620 struct sockaddr_storage orig_dst;
2621 socklen_t orig_dst_len =
sizeof(orig_dst);
2626 if (getsockname(
ENTRY_TO_CONN(conn)->s, (
struct sockaddr*)&orig_dst,
2627 &orig_dst_len) < 0) {
2629 log_warn(
LD_NET,
"getsockname() failed: %s", tor_socket_strerror(e));
2636#ifdef TRANS_NETFILTER
2639#ifdef TRANS_NETFILTER_IPV4
2641 rv = getsockopt(
ENTRY_TO_CONN(conn)->s, SOL_IP, SO_ORIGINAL_DST,
2642 (
struct sockaddr*)&orig_dst, &orig_dst_len);
2645#ifdef TRANS_NETFILTER_IPV6
2647 rv = getsockopt(
ENTRY_TO_CONN(conn)->s, SOL_IPV6, IP6T_SO_ORIGINAL_DST,
2648 (
struct sockaddr*)&orig_dst, &orig_dst_len);
2652 log_warn(
LD_BUG,
"Received transparent data from an unsupported "
2659 log_warn(
LD_NET,
"getsockopt() failed: %s", tor_socket_strerror(e));
2663#elif defined(TRANS_PF)
2664 if (getsockname(
ENTRY_TO_CONN(conn)->s, (
struct sockaddr*)&orig_dst,
2665 &orig_dst_len) < 0) {
2667 log_warn(
LD_NET,
"getsockname() failed: %s", tor_socket_strerror(e));
2674 log_warn(
LD_BUG,
"Unable to determine destination from socket.");
2690 struct sockaddr_storage proxy_addr;
2691 socklen_t proxy_addr_len =
sizeof(proxy_addr);
2692 struct sockaddr *proxy_sa = (
struct sockaddr*) &proxy_addr;
2693 struct pfioc_natlook pnl;
2697 if (getsockname(
ENTRY_TO_CONN(conn)->s, (
struct sockaddr*)&proxy_addr,
2698 &proxy_addr_len) < 0) {
2700 log_warn(
LD_NET,
"getsockname() to determine transocks destination "
2701 "failed: %s", tor_socket_strerror(e));
2706 if (
get_options()->TransProxyType_parsed == TPT_IPFW) {
2720 memset(&pnl, 0,
sizeof(pnl));
2721 pnl.proto = IPPROTO_TCP;
2722 pnl.direction = PF_OUT;
2723 if (proxy_sa->sa_family == AF_INET) {
2724 struct sockaddr_in *sin = (
struct sockaddr_in *)proxy_sa;
2728 pnl.daddr.v4.s_addr = sin->sin_addr.s_addr;
2729 pnl.dport = sin->sin_port;
2730 }
else if (proxy_sa->sa_family == AF_INET6) {
2737 memcpy(&pnl.saddr.v6, dest_in6,
sizeof(
struct in6_addr));
2739 memcpy(&pnl.daddr.v6, &sin6->sin6_addr,
sizeof(
struct in6_addr));
2740 pnl.dport = sin6->sin6_port;
2742 log_warn(
LD_NET,
"getsockname() gave an unexpected address family (%d)",
2743 (
int)proxy_sa->sa_family);
2747 pf = get_pf_socket();
2751 if (ioctl(pf, DIOCNATLOOK, &pnl) < 0) {
2752 log_warn(
LD_NET,
"ioctl(DIOCNATLOOK) failed: %s", strerror(errno));
2756 if (pnl.af == AF_INET) {
2758 }
else if (pnl.af == AF_INET6) {
2766 req->
port = ntohs(pnl.rdport);
2783#ifdef TRANS_NETFILTER
2784 return destination_from_socket(conn, req);
2785#elif defined(TRANS_PF)
2789 return destination_from_socket(conn, req);
2793 return destination_from_pf(conn, req);
2797 log_warn(
LD_BUG,
"Proxy destination determination mechanism %s unknown.",
2803 log_warn(
LD_BUG,
"Called connection_ap_get_original_destination, but no "
2804 "transparent proxy method was configured.");
2834 log_debug(
LD_APP,
"entered.");
2841 connection_buf_add((
const char*)socks->
reply, socks->
replylen,
2844 if (sockshere == -1) {
2851 if (sockshere == 0) {
2852 log_debug(
LD_APP,
"socks handshake not all here yet.");
2854 }
else if (sockshere == -1) {
2856 log_warn(
LD_APP,
"Fetching socks handshake failed. Closing.");
2860 connection_mark_unattached_ap(conn,
2866 if (SOCKS_COMMAND_IS_CONNECT(socks->
command))
2895 log_debug(
LD_APP,
"entered.");
2898 log_warn(
LD_APP,
"Fetching original destination failed. Closing.");
2899 connection_mark_unattached_ap(conn,
2924 char tmp_buf[36], *tbuf, *daddr;
2934 log_debug(
LD_APP,
"entered.");
2942 log_warn(
LD_APP,
"NATD handshake failed (DEST too long). Closing");
2948 log_warn(
LD_APP,
"NATD handshake was ill-formed; closing. The client "
2955 daddr = tbuf = &tmp_buf[0] + 6;
2956 if (!(tbuf = strchr(tbuf,
' '))) {
2957 log_warn(
LD_APP,
"NATD handshake was ill-formed; closing. The client "
2968 socks->
port = (uint16_t)
2971 log_warn(
LD_APP,
"NATD handshake failed; port %s is ill-formed or out "
2987static const char HTTP_CONNECT_IS_NOT_AN_HTTP_PROXY_MSG[] =
2988 "HTTP/1.0 405 Method Not Allowed\r\n"
2989 "Content-Type: text/html; charset=iso-8859-1\r\n\r\n"
2992 "<title>This is an HTTP CONNECT tunnel, not a full HTTP Proxy</title>\n"
2995 "<h1>This is an HTTP CONNECT tunnel, not an HTTP proxy.</h1>\n"
2997 "It appears you have configured your web browser to use this Tor port as\n"
3000 "This is not correct: This port is configured as a CONNECT tunnel, not\n"
3001 "an HTTP proxy. Please configure your client accordingly. You can also\n"
3002 "use HTTPS; then the client should automatically use HTTP CONNECT."
3005 "See <a href=\"https://www.torproject.org/documentation.html\">"
3006 "https://www.torproject.org/documentation.html</a> for more "
3024 char *headers = NULL, *body = NULL;
3025 char *
command = NULL, *addrport = NULL;
3029 const char *errmsg = NULL;
3032 const int http_status =
3034 &body, &bodylen, 1024, 0);
3035 if (http_status < 0) {
3037 errmsg =
"HTTP/1.0 400 Bad Request\r\n\r\n";
3039 }
else if (http_status == 0) {
3045 if (cmd_status < 0) {
3046 errmsg =
"HTTP/1.0 400 Bad Request\r\n\r\n";
3051 if (strcasecmp(
command,
"connect")) {
3052 errmsg = HTTP_CONNECT_IS_NOT_AN_HTTP_PROXY_MSG;
3060 errmsg =
"HTTP/1.0 400 Bad Request\r\n\r\n";
3063 if (strlen(addr) >= MAX_SOCKS_ADDR_LEN) {
3064 errmsg =
"HTTP/1.0 414 Request-URI Too Long\r\n\r\n";
3071 char *authorization =
http_get_header(headers,
"Proxy-Authorization: ");
3072 if (authorization) {
3076 char *isolation =
http_get_header(headers,
"X-Tor-Stream-Isolation: ");
3097 if (BUG(errmsg == NULL))
3098 errmsg =
"HTTP/1.0 400 Bad Request\r\n\r\n";
3099 log_info(
LD_EDGE,
"HTTP tunnel error: saying %s",
escaped(errmsg));
3100 connection_buf_add(errmsg, strlen(errmsg),
ENTRY_TO_CONN(conn));
3104 connection_mark_unattached_ap(conn,
3125 uint32_t attempts=0;
3129 if (++attempts > 1<<16) {
3131 log_warn(
LD_APP,
"No unused stream IDs. Failing.");
3134 if (test_stream_id == 0)
3137 if (tmpconn->
stream_id == test_stream_id)
3148 return test_stream_id;
3178 const node_t *exitnode = NULL;
3192 if (ap_conn->entry_cfg.ipv4_traffic && !ap_conn->entry_cfg.ipv6_traffic)
3195 if (! cpath_layer ||
3199 if (!ap_conn->entry_cfg.ipv4_traffic)
3204 if (ap_conn->entry_cfg.ipv6_traffic && exitnode) {
3219 if (ap_conn->entry_cfg.prefer_ipv6)
3224 log_warn(
LD_EDGE,
"I'm about to ask a node for a connection that I "
3225 "am telling it to fulfil with neither IPv4 nor IPv6. That's "
3226 "not going to work. Did you perhaps ask for an IPv6 address "
3227 "on an IPv4Only port, or vice versa?");
3260 connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);
3269 RELAY_COMMAND_BEGIN);
3275 circ->base_.
purpose == CIRCUIT_PURPOSE_CONFLUX_LINKED ||
3279 payload_len = strlen(payload)+1;
3280 if (payload_len <= payload_max - 4 && edge_conn->begincell_flags) {
3281 set_uint32(payload + payload_len, htonl(edge_conn->begincell_flags));
3286 "Sending relay cell %d on circ %u to begin stream %d.",
3292 RELAY_COMMAND_BEGIN_DIR : RELAY_COMMAND_BEGIN;
3295 if (begin_type == RELAY_COMMAND_BEGIN) {
3299 assert_circ_anonymity_ok(circ, options);
3300 }
else if (begin_type == RELAY_COMMAND_BEGIN_DIR) {
3304 if (BUG(!base_conn->
linked)) {
3310 if (!linked_dir_conn_base) {
3318 TO_DIR_CONN(linked_dir_conn_base)->router_purpose,
3319 TO_DIR_CONN(linked_dir_conn_base)->requested_resource)) {
3320 assert_circ_anonymity_ok(circ, options);
3325 tor_assert_unreached();
3329 begin_type == RELAY_COMMAND_BEGIN ? payload : NULL,
3330 begin_type == RELAY_COMMAND_BEGIN ? payload_len : 0) < 0)
3336 log_info(
LD_APP,
"Address/port sent, ap socket "TOR_SOCKET_T_FORMAT
3338 base_conn->
s, (
unsigned)circ->base_.
n_circ_id);
3342 if ((connection_get_inbuf_len(base_conn) ||
3343 ap_conn->sending_optimistic_data) &&
3345 log_info(
LD_APP,
"Sending up to %ld + %ld bytes of queued-up data",
3346 (
long)connection_get_inbuf_len(base_conn),
3347 ap_conn->sending_optimistic_data ?
3348 (
long)
buf_datalen(ap_conn->sending_optimistic_data) : 0);
3350 connection_mark_for_close(base_conn);
3366 const char *string_addr;
3378 circ->base_.
purpose == CIRCUIT_PURPOSE_CONFLUX_LINKED);
3387 connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);
3396 payload_len = (int)strlen(string_addr)+1;
3407 log_warn(
LD_APP,
"Rejecting ill-formed reverse lookup of %s",
3408 safe_str_client(a));
3409 connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);
3415 log_warn(
LD_BUG,
"Couldn't generate reverse lookup hostname of %s",
3416 safe_str_client(a));
3417 connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);
3421 string_addr = inaddr_buf;
3422 payload_len = (int)strlen(inaddr_buf)+1;
3423 tor_assert(payload_len <= (
int)
sizeof(inaddr_buf));
3427 "Sending relay cell to begin stream %d.", edge_conn->
stream_id);
3430 RELAY_COMMAND_RESOLVE,
3431 string_addr, payload_len) < 0)
3439 log_info(
LD_APP,
"Address sent for resolve, ap socket "TOR_SOCKET_T_FORMAT
3441 base_conn->
s, (
unsigned)circ->base_.
n_circ_id);
3455 char *address, uint16_t port,
3457 int session_group,
int isolation_flags,
3458 int use_begindir,
int want_onehop)
3463 log_info(
LD_APP,
"Making internal %s tunnel to %s:%d ...",
3464 want_onehop ?
"direct" :
"anonymized",
3465 safe_str_client(address), port);
3496 base_conn->
address = tor_strdup(
"(Tor_internal)");
3498 base_conn->
port = 0;
3502 if (connection_add(base_conn) < 0) {
3503 connection_free(base_conn);
3512 connection_ap_mark_as_pending_circuit(conn);
3513 log_info(
LD_APP,
"... application connection created and linked.");
3528 uint64_t stream_id = 0;
3536 expires = time(NULL) + ttl;
3537 if (answer_type == RESOLVED_TYPE_IPV4 && answer_len >= 4) {
3541 cp, expires, NULL, 0, stream_id);
3543 }
else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len < 256) {
3544 char *cp = tor_strndup(answer, answer_len);
3546 cp, expires, NULL, 0, stream_id);
3550 "<error>", time(NULL)+ttl,
3551 "error=yes", 0, stream_id);
3576 log_warn(
LD_BUG,
"Got called with address of unexpected family %d",
3579 RESOLVED_TYPE_ERROR,0,NULL,-1,-1);
3596 const uint8_t *answer,
3604 if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
3612 }
else if (answer_type == RESOLVED_TYPE_IPV6 && answer_len == 16) {
3620 }
else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len < 256) {
3621 char *cp = tor_strndup((
char*)answer, answer_len);
3641 (
char*)answer, ttl, expires);
3650 if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
3651 buf[1] = SOCKS4_GRANTED;
3653 memcpy(buf+4, answer, 4);
3656 buf[1] = SOCKS4_REJECT;
3657 memset(buf+2, 0, 6);
3663 if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
3664 buf[1] = SOCKS5_SUCCEEDED;
3667 memcpy(buf+4, answer, 4);
3670 }
else if (answer_type == RESOLVED_TYPE_IPV6 && answer_len == 16) {
3671 buf[1] = SOCKS5_SUCCEEDED;
3674 memcpy(buf+4, answer, 16);
3677 }
else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len < 256) {
3678 buf[1] = SOCKS5_SUCCEEDED;
3681 buf[4] = (char)answer_len;
3682 memcpy(buf+5, answer, answer_len);
3684 replylen = 5+answer_len+2;
3686 buf[1] = SOCKS5_HOST_UNREACHABLE;
3687 memset(buf+2, 0, 8);
3695 (answer_type == RESOLVED_TYPE_IPV4 ||
3696 answer_type == RESOLVED_TYPE_IPV6 ||
3697 answer_type == RESOLVED_TYPE_HOSTNAME) ?
3698 0 : END_STREAM_REASON_RESOLVEFAILED);
3712 size_t replylen,
int endreason)
3728 STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED,
3734 if (status == SOCKS5_SUCCEEDED ||
3735 endreason == END_STREAM_REASON_RESOLVEFAILED ||
3736 endreason == END_STREAM_REASON_CONNECTREFUSED ||
3737 endreason == END_STREAM_REASON_CONNRESET ||
3738 endreason == END_STREAM_REASON_NOROUTE ||
3739 endreason == END_STREAM_REASON_RESOURCELIMIT) {
3742 if (endreason != END_STREAM_REASON_RESOLVEFAILED) {
3744 "No origin circuit for successful SOCKS stream %"PRIu64
3766 log_warn(
LD_BUG,
"(Harmless.) duplicate calls to "
3767 "connection_ap_handshake_socks_reply.");
3779 response =
"HTTP/1.0 400 Bad Request\r\n\r\n";
3781 connection_buf_add(response, strlen(response),
ENTRY_TO_CONN(conn));
3784 buf[1] = (status==SOCKS5_SUCCEEDED ? SOCKS4_GRANTED : SOCKS4_REJECT);
3789 memset(buf,0,
sizeof(buf));
3792 buf[1] = (char)status;
3799 buf[1] = (char)status;
3823 uint8_t *end_reason_out)
3825 const uint8_t *body, *nul;
3827 memset(bcell, 0,
sizeof(*bcell));
3828 *end_reason_out = END_STREAM_REASON_MISC;
3830 bcell->stream_id = msg->stream_id;
3832 if (msg->command == RELAY_COMMAND_BEGIN_DIR) {
3833 bcell->is_begindir = 1;
3835 }
else if (msg->command != RELAY_COMMAND_BEGIN) {
3836 log_warn(
LD_BUG,
"Got an unexpected command %u", msg->command);
3837 *end_reason_out = END_STREAM_REASON_INTERNAL;
3842 nul = memchr(body, 0, msg->length);
3845 "Relay begin cell has no \\0. Closing.");
3846 *end_reason_out = END_STREAM_REASON_TORPROTOCOL;
3852 &bcell->address,&bcell->port)<0) {
3854 "Unable to parse addr:port in relay begin cell. Closing.");
3855 *end_reason_out = END_STREAM_REASON_TORPROTOCOL;
3858 if (bcell->port == 0) {
3860 "Missing port in relay begin cell. Closing.");
3862 *end_reason_out = END_STREAM_REASON_TORPROTOCOL;
3865 if (body + msg->length >= nul + 4)
3885 log_debug(
LD_REND,
"Connecting the hidden service rendezvous circuit "
3886 "to the service destination.");
3889 conn->base_.
address = tor_strdup(
"(rendezvous)");
3904 log_info(
LD_REND,
"Didn't find rendezvous service at %s",
3913 END_STREAM_REASON_DONE,
3945 if (conn->hs_ident) {
3948 export_hs_client_circuit_id(conn, circuit_id_protocol);
3981 char *address = NULL;
3989 uint8_t end_reason=0;
3990 dos_stream_defense_type_t dos_defense_type;
4004 "Relay begin cell at non-server. Closing.");
4006 END_STREAM_REASON_EXITPOLICY, NULL);
4012 return -END_CIRC_REASON_TORPROTOCOL;
4013 }
else if (rv == -1) {
4020 if (! bcell.is_begindir) {
4023 address = bcell.address;
4026 if (or_circ && or_circ->
p_chan) {
4036 "Attempt by %s to open a stream %s. Closing.",
4038 client_chan ?
"on first hop of circuit" :
4039 "from unknown relay");
4042 END_STREAM_REASON_TORPROTOCOL :
4043 END_STREAM_REASON_MISC,
4049 }
else if (msg->command == RELAY_COMMAND_BEGIN_DIR) {
4053 END_STREAM_REASON_NOTDIRECTORY,
4062 if (or_circ && or_circ->
p_chan &&
4066 address = tor_strdup(
"127.0.0.1");
4072 log_warn(
LD_BUG,
"Got an unexpected command %u", msg->command);
4074 END_STREAM_REASON_INTERNAL, layer_hint);
4080 bcell.flags &= ~BEGIN_FLAG_IPV6_PREFERRED;
4085 END_STREAM_REASON_EXITPOLICY, layer_hint);
4090 log_debug(LD_EXIT,
"Creating new exit connection.");
4100 n_stream->begincell_flags = bcell.flags;
4102 n_stream->base_.
port = port;
4121 n_stream->base_.
address = address;
4128 END_STREAM_REASON_HIBERNATING, NULL);
4135 if (msg->command == RELAY_COMMAND_BEGIN_DIR) {
4145 log_debug(LD_EXIT,
"about to start the dns_resolve().");
4149 dos_defense_type = dos_stream_new_begin_or_resolve_cell(or_circ);
4150 switch (dos_defense_type) {
4151 case DOS_STREAM_DEFENSE_NONE:
4153 case DOS_STREAM_DEFENSE_REFUSE_STREAM:
4157 END_STREAM_REASON_MISC, layer_hint);
4160 case DOS_STREAM_DEFENSE_CLOSE_CIRCUIT:
4162 return -END_CIRC_REASON_RESOURCELIMIT;
4169 log_debug(LD_EXIT,
"about to call connection_exit_connect().");
4174 END_STREAM_REASON_RESOLVEFAILED, NULL);
4196 dos_stream_defense_type_t dos_defense_type;
4212 dummy_conn->base_.
address = tor_strndup((
char *) msg->body, msg->length);
4213 dummy_conn->base_.
port = 0;
4219 dos_defense_type = dos_stream_new_begin_or_resolve_cell(circ);
4220 switch (dos_defense_type) {
4221 case DOS_STREAM_DEFENSE_NONE:
4223 case DOS_STREAM_DEFENSE_REFUSE_STREAM:
4224 dns_send_resolved_error_cell(dummy_conn, RESOLVED_TYPE_ERROR_TRANSIENT);
4227 case DOS_STREAM_DEFENSE_CLOSE_CIRCUIT:
4229 return -END_CIRC_REASON_RESOURCELIMIT;
4254 const char **why_rejected)
4260 *why_rejected =
" (IPv6 address without IPv6Exit configured)";
4273 int marked_for_close = 0;
4276 int config_change_relevant = 0;
4283 line && !config_change_relevant;
4284 line = line->next) {
4285 const char* exit_policy_options[] = {
4288 "ReducedExitPolicy",
4289 "ReevaluateExitPolicy",
4293 for (
unsigned int i = 0; exit_policy_options[i] != NULL; ++i) {
4294 if (strcmp(line->key, exit_policy_options[i]) == 0) {
4295 config_change_relevant = 1;
4301 if (!config_change_relevant) {
4324 connection_mark_for_close(conn);
4327 } SMARTLIST_FOREACH_END(conn);
4329 smartlist_free(conn_list);
4330 smartlist_free(policy);
4332 log_info(
LD_GENERAL,
"Marked %d connections to be closed as no longer "
4333 "allowed per ExitPolicy", marked_for_close);
4358 int socket_error = 0, result;
4359 const char *why_failed_exit_policy = NULL;
4364 edge_conn->base_.
port,
4365 &why_failed_exit_policy)) {
4366 if (BUG(!why_failed_exit_policy))
4367 why_failed_exit_policy =
"";
4368 log_info(LD_EXIT,
"%s failed exit policy%s. Closing.",
4370 why_failed_exit_policy);
4374 connection_free(conn);
4397 log_info(LD_EXIT,
"%s tried to connect back to a known relay address. "
4402 connection_free(conn);
4421 log_debug(LD_EXIT,
"about to try connecting");
4423 addr, port, &socket_error);
4434 log_debug(LD_EXIT,
"about to try connecting");
4435 result = connection_connect_unix(conn, conn->
address, &socket_error);
4444 connection_free(conn);
4458 if (connection_get_outbuf_len(conn)) {
4469 RELAY_COMMAND_CONNECTED,
4473 int connected_payload_len =
4476 if (connected_payload_len < 0) {
4479 connection_free(conn);
4484 RELAY_COMMAND_CONNECTED,
4485 (
char*)connected_payload,
4486 connected_payload_len);
4503 log_info(LD_EXIT,
"Opening local connection for anonymized directory exit");
4513 dirconn->base_.
port = 0;
4525 if (connection_add(
TO_CONN(exitconn))<0) {
4536 if (connection_add(
TO_CONN(dirconn))<0) {
4539 connection_mark_for_close(
TO_CONN(exitconn));
4548 RELAY_COMMAND_CONNECTED, NULL, 0) < 0) {
4549 connection_mark_for_close(
TO_CONN(exitconn));
4550 connection_mark_for_close(
TO_CONN(dirconn));
4565 if (conn->hs_ident) {
4590 const node_t *chosen_exit =
4611 }
else if (!conn->entry_cfg.ipv4_traffic && conn->entry_cfg.ipv6_traffic) {
4614 }
else if (conn->entry_cfg.ipv4_traffic && !conn->entry_cfg.ipv6_traffic) {
4643memeq_opt(
const char *a,
size_t alen,
const char *b,
size_t blen)
4647 }
else if (b == NULL) {
4649 }
else if (alen != blen) {
4684 log_warn(
LD_BUG,
"Reached connection_edge_compatible_with_circuit without "
4685 "having set conn->original_dest_address");
4702 circ->socks_username, circ->socks_username_len) ||
4704 circ->socks_password, circ->socks_password_len)))
4737 log_warn(
LD_BUG,
"Reached connection_update_circuit_isolation without "
4738 "having set conn->original_dest_address");
4755 circ->socks_username = sr->
username ?
4757 circ->socks_password = sr->
password ?
4771 circ->socks_username, circ->socks_username_len) ||
4773 circ->socks_password, circ->socks_password_len))
4789 log_warn(
LD_BUG,
"Updating a circuit with seemingly incompatible "
4790 "isolation flags.");
4812 log_warn(
LD_BUG,
"Tried to clear the isolation status of a dirty circuit");
4816 log_warn(
LD_BUG,
"Tried to clear the isolation status of a non-open "
4824 circ->client_proto_type = 0;
4825 circ->client_proto_socksver = 0;
4826 circ->dest_port = 0;
4829 circ->session_group = -1;
4830 circ->nym_epoch = 0;
4831 if (circ->socks_username) {
4832 memwipe(circ->socks_username, 0x11, circ->socks_username_len);
4835 if (circ->socks_password) {
4836 memwipe(circ->socks_password, 0x05, circ->socks_password_len);
4839 circ->socks_username_len = circ->socks_password_len = 0;
4858 connection_mark_for_close(
TO_CONN(conn));
4865 untried_pending_connections = 0;
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
void tor_addr_from_ipv4n(tor_addr_t *dest, uint32_t v4addr)
void tor_addr_make_unspec(tor_addr_t *a)
int tor_addr_hostname_is_local(const char *name)
int tor_addr_parse(tor_addr_t *addr, const char *src)
void tor_addr_make_null(tor_addr_t *a, sa_family_t family)
int tor_addr_port_split(int severity, const char *addrport, char **address_out, uint16_t *port_out)
int tor_addr_is_null(const tor_addr_t *addr)
char * tor_addr_to_str_dup(const tor_addr_t *addr)
int tor_addr_parse_PTR_name(tor_addr_t *result, const char *address, int family, int accept_regular)
void tor_addr_from_in6(tor_addr_t *dest, const struct in6_addr *in6)
const char * tor_addr_to_str(char *dest, const tor_addr_t *addr, size_t len, int decorate)
int tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa, uint16_t *port_out)
void tor_addr_from_ipv6_bytes(tor_addr_t *dest, const uint8_t *ipv6_bytes)
char * tor_dup_ip(uint32_t addr)
int tor_addr_to_PTR_name(char *out, size_t outlen, const tor_addr_t *addr)
static uint32_t tor_addr_to_ipv4n(const tor_addr_t *a)
#define REVERSE_LOOKUP_NAME_BUF_LEN
static sa_family_t tor_addr_family(const tor_addr_t *a)
static const struct in6_addr * tor_addr_to_in6(const tor_addr_t *a)
#define tor_addr_to_in6_addr8(x)
#define tor_addr_eq(a, b)
void client_dns_set_reverse_addressmap(entry_connection_t *for_conn, const char *address, const char *v, const char *exitname, int ttl)
void clear_trackexithost_mappings(const char *exitname)
int address_is_in_virtual_range(const char *address)
void client_dns_set_addressmap(entry_connection_t *for_conn, const char *address, const tor_addr_t *val, const char *exitname, int ttl)
int addressmap_rewrite(char *address, size_t maxlen, unsigned flags, time_t *expires_out, addressmap_entry_source_t *exit_source_out)
int addressmap_address_should_automap(const char *address, const or_options_t *options)
const char * addressmap_register_virtual_address(int type, char *new_address)
int addressmap_rewrite_reverse(char *address, size_t maxlen, unsigned flags, time_t *expires_out)
const char * hex_str(const char *from, size_t fromlen)
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
size_t buf_datalen(const buf_t *buf)
int buf_set_to_copy(buf_t **output, const buf_t *input)
Header file for buffers.c.
static void set_uint16(void *cp, uint16_t v)
static void set_uint32(void *cp, uint32_t v)
static void set_uint8(void *cp, uint8_t v)
static uint32_t get_uint32(const void *cp)
Fixed-size cell structure.
int channel_is_client(const channel_t *chan)
int channel_get_addr_if_possible(const channel_t *chan, tor_addr_t *addr_out)
const char * channel_describe_peer(channel_t *chan)
Header file for channel.c.
const char * pathbias_state_to_string(path_state_t state)
void pathbias_mark_use_rollback(origin_circuit_t *circ)
void pathbias_mark_use_success(origin_circuit_t *circ)
Header file for circuitbuild.c.
circuit_t * circuit_get_by_edge_conn(edge_connection_t *conn)
origin_circuit_t * TO_ORIGIN_CIRCUIT(circuit_t *x)
void assert_circuit_ok(const circuit_t *c)
const char * circuit_state_to_string(int state)
or_circuit_t * TO_OR_CIRCUIT(circuit_t *x)
const char * circuit_purpose_to_string(uint8_t purpose)
Header file for circuitlist.c.
#define CIRCUIT_PURPOSE_IS_CLIENT(p)
#define CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT
#define CIRCUIT_PURPOSE_PATH_BIAS_TESTING
#define CIRCUIT_STATE_OPEN
#define CIRCUIT_PURPOSE_C_REND_JOINED
#define CIRCUIT_PURPOSE_CONTROLLER
#define CIRCUIT_IS_ORIGIN(c)
#define CIRCUIT_PURPOSE_OR
#define CIRCUIT_PURPOSE_S_REND_JOINED
#define CIRCUIT_PURPOSE_S_HSDIR_POST
#define CIRCUIT_PURPOSE_C_HSDIR_GET
#define CIRCUIT_PURPOSE_C_GENERAL
void circpad_machine_event_circ_has_streams(origin_circuit_t *circ)
Header file for circuitpadding.c.
double get_circuit_build_timeout_ms(void)
Header file for circuitstats.c.
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
int connection_ap_handshake_attach_circuit(entry_connection_t *conn)
int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ)
Header file for circuituse.c.
#define SUBTYPE_P(p, subtype, basemember)
mainloop_event_t * mainloop_event_postloop_new(void(*cb)(mainloop_event_t *, void *), void *userdata)
void mainloop_event_activate(mainloop_event_t *event)
Header for compat_libevent.c.
uint64_t monotime_absolute_usec(void)
const char * escaped_safe_str_client(const char *address)
const char * escaped_safe_str(const char *address)
const or_options_t * get_options(void)
tor_cmdline_mode_t command
Header file for config.c.
uint64_t edge_get_max_rtt(const edge_connection_t *stream)
void conflux_sync_circ_fields(conflux_t *cfx, origin_circuit_t *ref_circ)
void conflux_update_half_streams(origin_circuit_t *circ, smartlist_t *half_streams)
Header file for conflux_util.c.
bool edge_uses_flow_control(const edge_connection_t *stream)
APIs for stream flow control on congestion controlled circuits.
edge_connection_t * edge_connection_new(int type, int socket_family)
void connection_link_connections(connection_t *conn_a, connection_t *conn_b)
int connection_buf_get_line(connection_t *conn, char *data, size_t *data_len)
void connection_mark_for_close_(connection_t *conn, int line, const char *file)
void connection_close_immediate(connection_t *conn)
int connection_state_is_open(connection_t *conn)
const char * connection_describe_peer(const connection_t *conn)
entry_connection_t * entry_connection_new(int type, int socket_family)
const char * connection_describe(const connection_t *conn)
dir_connection_t * dir_connection_new(int socket_family)
void connection_free_(connection_t *conn)
int connection_connect(connection_t *conn, const char *address, const tor_addr_t *addr, uint16_t port, int *socket_error)
const char * conn_state_to_string(int type, int state)
Header file for connection.c.
#define CONN_TYPE_AP_HTTP_CONNECT_LISTENER
#define CONN_TYPE_DIR_LISTENER
#define connection_mark_and_flush_(c, line, file)
int connection_edge_compatible_with_circuit(const entry_connection_t *conn, const origin_circuit_t *circ)
int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
int connection_half_edge_is_valid_data(const smartlist_t *half_conns, streamid_t stream_id)
void connection_ap_mark_as_waiting_for_renddesc(entry_connection_t *entry_conn)
void connection_mark_unattached_ap_(entry_connection_t *conn, int endreason, int line, const char *file)
static uint32_t connection_ap_get_begincell_flags(entry_connection_t *ap_conn)
void connection_edge_free_all(void)
void connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn)
static int connection_half_edge_compare_bsearch(const void *key, const void **member)
static size_t n_half_conns_allocated
int connection_ap_rewrite_and_attach_if_allowed(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
uint32_t clip_dns_fuzzy_ttl(uint32_t ttl)
int connection_exit_begin_resolve(const relay_msg_t *msg, or_circuit_t *circ)
static int connection_ap_supports_optimistic_data(const entry_connection_t *)
STATIC int connection_ap_process_http_connect(entry_connection_t *conn)
const edge_connection_t * CONST_TO_EDGE_CONN(const connection_t *c)
#define MAX_CONNECTED_CELL_PAYLOAD_LEN
entry_connection_t * connection_ap_make_link(connection_t *partner, char *address, uint16_t port, const char *digest, int session_group, int isolation_flags, int use_begindir, int want_onehop)
void connection_ap_expire_beginning(void)
void connection_ap_fail_onehop(const char *failed_digest, cpath_build_state_t *build_state)
static void connection_edge_about_to_close(edge_connection_t *edge_conn)
int connection_ap_detach_retriable(entry_connection_t *conn, origin_circuit_t *circ, int reason)
STATIC int connected_cell_format_payload(uint8_t *payload_out, const tor_addr_t *addr, uint32_t ttl)
void connection_ap_rescan_and_attach_pending(void)
int connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
static int connection_ap_process_natd(entry_connection_t *conn)
static int consider_plaintext_ports(entry_connection_t *conn, uint16_t port)
STATIC int begin_cell_parse(const relay_msg_t *msg, begin_cell_t *bcell, uint8_t *end_reason_out)
void connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply, size_t replylen, int endreason)
static smartlist_t * pending_entry_connections
int connection_half_edge_is_valid_end(smartlist_t *half_conns, streamid_t stream_id)
void connection_exit_connect(edge_connection_t *edge_conn)
uint32_t clip_dns_ttl(uint32_t ttl)
static bool network_reentry_is_allowed(void)
bool connection_half_edges_waiting(const origin_circuit_t *circ)
int connection_ap_process_transparent(entry_connection_t *conn)
void connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn, const char *fname, int lineno)
#define TRACKHOSTEXITS_RETRIES
static mainloop_event_t * attach_pending_entry_connections_ev
void connection_edge_end_close(edge_connection_t *conn, uint8_t reason)
int connection_edge_finished_connecting(edge_connection_t *edge_conn)
int connection_edge_destroy(circid_t circ_id, edge_connection_t *conn)
static int connection_exit_connect_dir(edge_connection_t *exitconn)
int connection_edge_finished_flushing(edge_connection_t *conn)
static int my_exit_policy_rejects(const tor_addr_t *addr, uint16_t port, const char **why_rejected)
void circuit_clear_isolation(origin_circuit_t *circ)
void connection_exit_about_to_close(edge_connection_t *edge_conn)
static int connection_ap_get_original_destination(entry_connection_t *conn, socks_request_t *req)
STATIC bool parse_extended_hostname(char *address, hostname_type_t *type_out)
int connection_half_edge_is_valid_connected(const smartlist_t *half_conns, streamid_t stream_id)
int connection_exit_begin_conn(const relay_msg_t *msg, circuit_t *circ)
int connection_edge_flushed_some(edge_connection_t *conn)
entry_connection_t * EDGE_TO_ENTRY_CONN(edge_connection_t *c)
int connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
void connection_ap_handshake_socks_resolved_addr(entry_connection_t *conn, const tor_addr_t *answer, int ttl, time_t expires)
int connection_edge_update_circuit_isolation(const entry_connection_t *conn, origin_circuit_t *circ, int dry_run)
int connection_edge_reached_eof(edge_connection_t *conn)
const entry_connection_t * CONST_TO_ENTRY_CONN(const connection_t *c)
static void tell_controller_about_resolved_result(entry_connection_t *conn, int answer_type, size_t answer_len, const char *answer, int ttl, time_t expires)
int connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit_node)
int connection_half_edge_is_valid_resolved(smartlist_t *half_conns, streamid_t stream_id)
int connection_edge_end_errno(edge_connection_t *conn)
int connection_edge_end(edge_connection_t *conn, uint8_t reason)
void connection_ap_attach_pending(int retry)
size_t half_streams_get_total_allocation(void)
int connection_half_edge_is_valid_sendme(const smartlist_t *half_conns, streamid_t stream_id)
int connection_edge_is_rendezvous_stream(const edge_connection_t *conn)
static int connection_ap_handle_onion(entry_connection_t *conn, socks_request_t *socks, origin_circuit_t *circ)
void connection_ap_about_to_close(entry_connection_t *entry_conn)
static int relay_send_end_cell_from_edge(streamid_t stream_id, circuit_t *circ, uint8_t reason, crypt_path_t *cpath_layer)
const entry_connection_t * CONST_EDGE_TO_ENTRY_CONN(const edge_connection_t *c)
entry_connection_t * TO_ENTRY_CONN(connection_t *c)
STATIC void connection_half_edge_add(const edge_connection_t *conn, origin_circuit_t *circ)
static int handle_hs_exit_conn(circuit_t *circ, edge_connection_t *conn)
void connection_ap_handshake_socks_resolved(entry_connection_t *conn, int answer_type, size_t answer_len, const uint8_t *answer, int ttl, time_t expires)
static int memeq_opt(const char *a, size_t alen, const char *b, size_t blen)
void connection_entry_set_controller_wait(entry_connection_t *conn)
streamid_t get_unique_stream_id_by_circ(origin_circuit_t *circ)
void half_edge_free_(half_edge_t *he)
void circuit_discard_optional_exit_enclaves(extend_info_t *info)
static int connection_ap_handshake_process_socks(entry_connection_t *conn)
edge_connection_t * TO_EDGE_CONN(connection_t *c)
int connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
STATIC half_edge_t * connection_half_edge_find_stream_id(const smartlist_t *half_conns, streamid_t stream_id)
static int compute_retry_timeout(entry_connection_t *conn)
Header file for connection_edge.c.
#define AP_CONN_STATE_HTTP_CONNECT_WAIT
#define EXIT_CONN_STATE_CONNECTING
#define AP_CONN_STATE_CONTROLLER_WAIT
#define EXIT_CONN_STATE_OPEN
#define AP_CONN_STATE_SOCKS_WAIT
int address_is_invalid_destination(const char *address, int client)
#define BEGIN_FLAG_IPV6_PREFERRED
#define EXIT_CONN_STATE_RESOLVEFAILED
#define AP_CONN_STATE_IS_UNATTACHED(s)
#define AP_CONN_STATE_CONNECT_WAIT
#define AP_CONN_STATE_OPEN
#define EXIT_PURPOSE_CONNECT
#define AP_CONN_STATE_RESOLVE_WAIT
#define BEGIN_FLAG_IPV4_NOT_OK
#define AP_CONN_STATE_CIRCUIT_WAIT
#define EXIT_CONN_STATE_RESOLVING
#define AP_CONN_STATE_NATD_WAIT
#define AP_CONN_STATE_RENDDESC_WAIT
#define BEGIN_FLAG_IPV6_OK
#define EXIT_PURPOSE_RESOLVE
int connection_or_digest_is_known_relay(const char *id_digest)
Header file for connection_or.c.
int control_event_stream_bandwidth(edge_connection_t *edge_conn)
int control_event_client_status(int severity, const char *format,...)
int control_event_stream_status(entry_connection_t *conn, stream_status_event_t tp, int reason_code)
int control_event_address_mapped(const char *from, const char *to, time_t expires, const char *error, const int cached, uint64_t stream_id)
Header file for control_events.c.
#define REMAP_STREAM_SOURCE_CACHE
Circuit-build-stse structure.
Common functions for using (pseudo-)random number generators.
unsigned crypto_rand_uint(unsigned limit)
void memwipe(void *mem, uint8_t byte, size_t sz)
Common functions for cryptographic routines.
const char * extend_info_describe(const extend_info_t *ei)
const char * node_describe(const node_t *node)
Header file for describe.c.
int tor_memeq(const void *a, const void *b, size_t sz)
#define tor_memneq(a, b, sz)
Client/server directory connection structure.
int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose, const char *resource)
dir_connection_t * TO_DIR_CONN(connection_t *c)
char * http_get_header(const char *headers, const char *which)
int parse_http_command(const char *headers, char **command_out, char **url_out)
Header file for directory.c.
#define DIR_CONN_STATE_SERVER_COMMAND_WAIT
#define DIR_PURPOSE_SERVER
int directory_permits_begindir_requests(const or_options_t *options)
Header file for dirserv.c.
void connection_dns_remove(edge_connection_t *conn)
int dns_resolve(edge_connection_t *exitconn)
void dnsserv_reject_request(entry_connection_t *conn)
void dnsserv_resolved(entry_connection_t *conn, int answer_type, size_t answer_len, const char *answer, int ttl)
Header file for dnsserv.c.
Entry connection structure.
#define ENTRY_TO_EDGE_CONN(c)
const char * escaped(const char *s)
bool extend_info_has_orport(const extend_info_t *ei, const tor_addr_t *addr, uint16_t port)
Header for core/or/extendinfo.c.
int tor_open_cloexec(const char *path, int flags, unsigned mode)
Half-open connection structure.
int we_are_hibernating(void)
Header file for hibernate.c.
const hs_descriptor_t * hs_cache_lookup_as_client(const ed25519_public_key_t *key)
Header file for hs_cache.c.
Header file containing circuit data for the whole HS subsystem.
int hs_client_any_intro_points_usable(const ed25519_public_key_t *service_pk, const hs_descriptor_t *desc)
int hs_client_refetch_hsdesc(const ed25519_public_key_t *identity_pk)
Header file containing client data for the HS subsystem.
@ HS_CLIENT_FETCH_PENDING
@ HS_CLIENT_FETCH_MISSING_INFO
@ HS_CLIENT_FETCH_NO_HSDIRS
@ HS_CLIENT_FETCH_HAVE_DESC
@ HS_CLIENT_FETCH_NOT_ALLOWED
@ HS_CLIENT_FETCH_LAUNCHED
int hs_parse_address(const char *address, ed25519_public_key_t *key_out, uint8_t *checksum_out, uint8_t *version_out)
int hs_address_is_valid(const char *address)
void hs_inc_rdv_stream_counter(origin_circuit_t *circ)
Header file containing common data for the whole HS subsystem.
#define HS_SERVICE_ADDR_LEN_BASE32
hs_ident_edge_conn_t * hs_ident_edge_conn_new(const ed25519_public_key_t *identity_pk)
hs_circuit_id_protocol_t hs_service_exports_circuit_id(const ed25519_public_key_t *pk)
int hs_service_set_conn_addr_port(const origin_circuit_t *circ, edge_connection_t *conn)
@ HS_CIRCUIT_ID_PROTOCOL_HAPROXY
#define log_fn(severity, domain, args,...)
#define log_fn_ratelim(ratelim, severity, domain, args,...)
void connection_watch_events(connection_t *conn, watchable_events_t events)
void connection_start_reading(connection_t *conn)
void connection_start_writing(connection_t *conn)
smartlist_t * get_connection_array(void)
Header file for mainloop.c.
void note_user_activity(time_t now)
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
Header file for networkstatus.c.
Node information structure.
const node_t * router_find_exact_exit_enclave(const char *address, uint16_t port)
const node_t * node_get_by_id(const char *identity_digest)
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
void node_get_address_string(const node_t *node, char *buf, size_t len)
bool nodelist_reentry_contains(const tor_addr_t *addr, uint16_t port)
int node_exit_policy_rejects_all(const node_t *node)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
addressmap_entry_source_t
#define STREAMWINDOW_INCREMENT
#define STREAMWINDOW_START
#define END_STREAM_REASON_SOCKSPROTOCOL
#define END_STREAM_REASON_INVALID_NATD_DEST
#define END_STREAM_REASON_HTTPPROTOCOL
#define END_STREAM_REASON_CANT_ATTACH
#define END_STREAM_REASON_PRIVATE_ADDR
#define END_STREAM_REASON_CANT_FETCH_ORIG_DEST
#define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED
#define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED
#define DOWNCAST(to, ptr)
#define END_STREAM_REASON_MASK
#define RELAY_PAYLOAD_SIZE_MAX
#define SOCKS4_NETWORK_LEN
#define END_CIRC_AT_ORIGIN
Origin circuit structure.
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
int policies_parse_exit_policy_from_options(const or_options_t *or_options, const tor_addr_t *ipv4_local_address, const tor_addr_t *ipv6_local_address, smartlist_t **result)
addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr, uint16_t port, const smartlist_t *policy)
addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr, uint16_t port, const node_t *node)
Header file for policies.c.
@ ADDR_POLICY_PROBABLY_REJECTED
void rep_hist_note_used_port(time_t now, uint16_t port)
void rep_hist_note_used_internal(time_t now, int need_uptime, int need_capacity)
void rep_hist_note_used_resolve(time_t now)
Header file for predict_ports.c.
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
int fetch_from_buf_http(buf_t *buf, char **headers_out, size_t max_headerlen, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete)
int fetch_from_buf_socks(buf_t *buf, socks_request_t *req, int log_sockstype, int safe_socks)
Header for proto_socks.c.
char * rate_limit_log(ratelim_t *lim, time_t now)
const char * end_reason_to_http_connect_response_line(int endreason)
const char * stream_end_reason_to_string(int reason)
socks5_reply_status_t stream_end_reason_to_socks5_response(int reason)
uint8_t errno_to_stream_end_reason(int e)
Header file for reasons.c.
size_t circuit_max_relay_payload(const circuit_t *circ, const crypt_path_t *cpath, uint8_t relay_command)
int connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial, int *max_cells)
int connection_edge_send_command(edge_connection_t *fromconn, uint8_t relay_command, const char *payload, size_t payload_len)
Header file for rendcommon.c.
void rep_hist_note_exit_stream(unsigned int cmd)
void rep_hist_note_exit_stream_opened(uint16_t port)
void rep_hist_note_conn_rejected(unsigned int type, int af)
Header file for rephist.c.
int router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
int should_refuse_unknown_exits(const or_options_t *options)
Header file for router.c.
int hexdigest_to_digest(const char *hexdigest, char *digest)
Header file for routerlist.c.
int server_mode(const or_options_t *options)
Header file for routermode.c.
int routerset_contains_node(const routerset_t *set, const node_t *node)
Header file for routerset.c.
void sendme_connection_edge_consider_sending(edge_connection_t *conn)
Header file for sendme.c.
void * smartlist_bsearch(const smartlist_t *sl, const void *key, int(*compare)(const void *key, const void **member))
int smartlist_contains_int_as_string(const smartlist_t *sl, int num)
int smartlist_bsearch_idx(const smartlist_t *sl, const void *key, int(*compare)(const void *key, const void **member), int *found_out)
void smartlist_insert(smartlist_t *sl, int idx, void *val)
int smartlist_contains(const smartlist_t *sl, const void *element)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_remove(smartlist_t *sl, const void *element)
void smartlist_del_keeporder(smartlist_t *sl, int idx)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
Client request structure.
#define SOCKS_COMMAND_RESOLVE_PTR
#define SOCKS_COMMAND_CONNECT
#define SOCKS_COMMAND_RESOLVE
char identity_digest[DIGEST_LEN]
uint16_t marked_for_close
time_t timestamp_last_read_allowed
struct connection_t * linked_conn
uint16_t marked_for_close
const char * marked_for_close_file
extend_info_t * chosen_exit
struct crypt_path_t * prev
extend_info_t * extend_info
struct crypt_path_t * cpath_layer
struct edge_connection_t * next_stream
unsigned int edge_has_sent_end
struct circuit_t * on_circuit
unsigned int is_transparent_ap
socks_request_t * socks_request
struct evdns_server_request * dns_server_request
unsigned int chosen_exit_optional
char * original_dest_address
unsigned int chosen_exit_retries
unsigned int may_use_optimistic_data
unsigned int hs_with_pow_conn
struct buf_t * pending_optimistic_data
uint8_t num_socks_retries
unsigned int use_begindir
unsigned int use_cached_ipv4_answers
unsigned int prefer_ipv6_virtaddr
char identity_digest[DIGEST_LEN]
uint64_t end_ack_expected_usec
unsigned int connected_pending
unsigned int used_ccontrol
hs_pow_desc_params_t * pow_params
hs_desc_encrypted_data_t encrypted_data
ed25519_public_key_t identity_pk
ed25519_public_key_t identity_pk
uint16_t orig_virtual_port
char identity[DIGEST_LEN]
edge_connection_t * n_streams
struct routerset_t * ExcludeExitNodes
struct smartlist_t * RejectPlaintextPorts
struct routerset_t * ExcludeExitNodesUnion_
struct smartlist_t * WarnPlaintextPorts
int LeaveStreamsUnattached
int ClientRejectInternalAddresses
enum or_options_t::@2 TransProxyType_parsed
int AutomapHostsOnResolve
int ClientDNSRejectInternalAddresses
uint64_t associated_isolated_stream_global_id
uint32_t global_identifier
struct hs_ident_circuit_t * hs_ident
edge_connection_t * p_streams
unsigned int isolation_values_set
uint8_t isolation_flags_mixed
unsigned int isolation_any_streams_attached
streamid_t next_stream_id
smartlist_t * half_streams
unsigned int has_finished
unsigned int socks_use_extended_errors
uint8_t reply[MAX_SOCKS_REPLY_LEN]
socks5_reply_status_t socks_extended_error_code
char address[MAX_SOCKS_ADDR_LEN]
#define MOCK_IMPL(rv, funcname, arglist)
#define tor_assert_nonfatal_unreached()
#define tor_fragile_assert()
void tor_strlower(char *s)
int strcmpstart(const char *s1, const char *s2)
int strcmpend(const char *s1, const char *s2)
int tor_digest_is_zero(const char *digest)