Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mike Perry
Tor
Commits
6a19e640
Commit
6a19e640
authored
Dec 17, 2003
by
Roger Dingledine
Browse files
remove trailing whitespace
svn:r951
parent
5ecd6b6b
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/or/buffers.c
View file @
6a19e640
...
...
@@ -71,7 +71,7 @@ static INLINE void buf_shrink_if_underfull(buf_t *buf) {
* MIN_BUF_SHRINK_SIZE.
*/
new_len
=
buf
->
len
/
2
;
while
(
buf
->
datalen
<
new_len
/
4
&&
new_len
/
2
>
MIN_BUF_SHRINK_SIZE
)
while
(
buf
->
datalen
<
new_len
/
4
&&
new_len
/
2
>
MIN_BUF_SHRINK_SIZE
)
new_len
/=
2
;
log_fn
(
LOG_DEBUG
,
"Shrinking buffer from %d to %d bytes."
,
(
int
)
buf
->
len
,
(
int
)
new_len
);
...
...
@@ -91,7 +91,7 @@ static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
* Otherwise, return index of the first character in buf _after_ the
* first instance of str.
*/
static
int
find_str_in_str
(
const
char
*
str
,
int
str_len
,
static
int
find_str_in_str
(
const
char
*
str
,
int
str_len
,
const
char
*
buf
,
int
buf_len
)
{
const
char
*
location
;
...
...
@@ -216,14 +216,14 @@ int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf) {
return
0
;
r
=
tor_tls_read
(
tls
,
buf
->
mem
+
buf
->
datalen
,
at_most
);
if
(
r
<
0
)
if
(
r
<
0
)
return
r
;
buf
->
datalen
+=
r
;
log_fn
(
LOG_DEBUG
,
"Read %d bytes. %d on inbuf."
,
r
,
(
int
)
buf
->
datalen
);
return
r
;
}
}
int
flush_buf
(
int
s
,
buf_t
*
buf
,
int
*
buf_flushlen
)
int
flush_buf
(
int
s
,
buf_t
*
buf
,
int
*
buf_flushlen
)
{
/* push from buf onto s
...
...
@@ -264,7 +264,7 @@ int flush_buf(int s, buf_t *buf, int *buf_flushlen)
}
}
int
flush_buf_tls
(
tor_tls
*
tls
,
buf_t
*
buf
,
int
*
buf_flushlen
)
int
flush_buf_tls
(
tor_tls
*
tls
,
buf_t
*
buf
,
int
*
buf_flushlen
)
{
int
r
;
assert
(
tls
&&
BUF_OK
(
buf
)
&&
buf_flushlen
);
...
...
@@ -325,7 +325,7 @@ int fetch_from_buf(char *string, int string_len, buf_t *buf) {
* them), remove them from buf, and return 1.
* (If headers or body is NULL, discard that part of the buf.)
* If a headers or body doesn't fit in the arg, return -1.
*
*
* Else, change nothing and return 0.
*/
int
fetch_from_buf_http
(
buf_t
*
buf
,
...
...
@@ -358,7 +358,7 @@ int fetch_from_buf_http(buf_t *buf,
}
#define CONTENT_LENGTH "\r\nContent-Length: "
i
=
find_str_in_str
(
CONTENT_LENGTH
,
strlen
(
CONTENT_LENGTH
),
i
=
find_str_in_str
(
CONTENT_LENGTH
,
strlen
(
CONTENT_LENGTH
),
headers
,
headerlen
);
if
(
i
>
0
)
{
contentlen
=
atoi
(
headers
+
i
);
...
...
src/or/circuit.c
View file @
6a19e640
...
...
@@ -7,7 +7,7 @@
extern
or_options_t
options
;
/* command-line and config-file options */
static
void
circuit_free_cpath_node
(
crypt_path_t
*
victim
);
static
circ_id_t
get_unique_circ_id_by_conn
(
connection_t
*
conn
,
int
circ_id_type
);
static
circ_id_t
get_unique_circ_id_by_conn
(
connection_t
*
conn
,
int
circ_id_type
);
unsigned
long
stats_n_relay_cells_relayed
=
0
;
unsigned
long
stats_n_relay_cells_delivered
=
0
;
...
...
@@ -54,7 +54,7 @@ void circuit_remove(circuit_t *circ) {
}
circuit_t
*
circuit_new
(
circ_id_t
p_circ_id
,
connection_t
*
p_conn
)
{
circuit_t
*
circ
;
circuit_t
*
circ
;
circ
=
tor_malloc_zero
(
sizeof
(
circuit_t
));
...
...
@@ -344,7 +344,7 @@ int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ,
char
recognized
=
0
;
assert
(
cell
&&
circ
);
assert
(
cell_direction
==
CELL_DIRECTION_OUT
||
cell_direction
==
CELL_DIRECTION_IN
);
assert
(
cell_direction
==
CELL_DIRECTION_OUT
||
cell_direction
==
CELL_DIRECTION_IN
);
log_fn
(
LOG_DEBUG
,
"direction %d, streamid %d before crypt."
,
cell_direction
,
*
(
int
*
)(
cell
->
payload
+
1
));
...
...
@@ -409,7 +409,7 @@ int relay_crypt(circuit_t *circ, char *in, int inlen, char cell_direction,
assert
(
inlen
<
CELL_NETWORK_SIZE
);
if
(
cell_direction
==
CELL_DIRECTION_IN
)
{
if
(
cell_direction
==
CELL_DIRECTION_IN
)
{
if
(
circ
->
cpath
)
{
/* we're at the beginning of the circuit.
We'll want to do layered crypts. */
thishop
=
circ
->
cpath
;
...
...
@@ -453,7 +453,7 @@ int relay_crypt(circuit_t *circ, char *in, int inlen, char cell_direction,
/* don't check for recognized. only the OP can recognize a stream on the way back. */
}
}
else
if
(
cell_direction
==
CELL_DIRECTION_OUT
)
{
}
else
if
(
cell_direction
==
CELL_DIRECTION_OUT
)
{
if
(
circ
->
cpath
)
{
/* we're at the beginning of the circuit. We'll want to do layered crypts. */
thishop
=
*
layer_hint
;
/* we already know which layer, from when we package_raw_inbuf'ed */
...
...
@@ -604,12 +604,12 @@ void circuit_close(circuit_t *circ) {
if
(
circ
->
n_conn
)
connection_send_destroy
(
circ
->
n_circ_id
,
circ
->
n_conn
);
for
(
conn
=
circ
->
n_streams
;
conn
;
conn
=
conn
->
next_stream
)
{
connection_send_destroy
(
circ
->
n_circ_id
,
conn
);
connection_send_destroy
(
circ
->
n_circ_id
,
conn
);
}
if
(
circ
->
p_conn
)
connection_send_destroy
(
circ
->
n_circ_id
,
circ
->
p_conn
);
for
(
conn
=
circ
->
p_streams
;
conn
;
conn
=
conn
->
next_stream
)
{
connection_send_destroy
(
circ
->
p_circ_id
,
conn
);
connection_send_destroy
(
circ
->
p_circ_id
,
conn
);
}
if
(
circ
->
state
==
CIRCUIT_STATE_BUILDING
||
circ
->
state
==
CIRCUIT_STATE_OR_WAIT
)
{
...
...
@@ -638,7 +638,7 @@ void circuit_about_to_close_connection(connection_t *conn) {
if
(
circ
->
p_conn
==
conn
)
/* it's closing behind us */
circ
->
p_conn
=
NULL
;
circuit_close
(
circ
);
}
}
return
;
case
CONN_TYPE_AP
:
case
CONN_TYPE_EXIT
:
...
...
@@ -692,8 +692,8 @@ void circuit_dump_details(int severity, circuit_t *circ, int poll_index,
log
(
severity
,
"Building: desired len %d, planned exit node %s."
,
circ
->
build_state
->
desired_path_len
,
circ
->
build_state
->
chosen_exit
);
for
(
hop
=
circ
->
cpath
;
hop
->
next
!=
circ
->
cpath
;
hop
=
hop
->
next
)
log
(
severity
,
"hop: state %d, addr %x, port %d"
,
hop
->
state
,
(
unsigned
int
)
hop
->
addr
,
log
(
severity
,
"hop: state %d, addr %x, port %d"
,
hop
->
state
,
(
unsigned
int
)
hop
->
addr
,
(
int
)
hop
->
port
);
}
}
...
...
@@ -744,7 +744,7 @@ void circuit_expire_unused_circuits(void) {
/* Number of consecutive failures so far; should only be touched by
* circuit_launch_new and circuit_*_failure_count.
*/
static
int
n_circuit_failures
=
0
;
static
int
n_circuit_failures
=
0
;
/* Return -1 if you aren't going to try to make a circuit, 0 if you did try. */
int
circuit_launch_new
(
void
)
{
...
...
@@ -820,7 +820,7 @@ int circuit_establish_circuit(void) {
log_fn
(
LOG_DEBUG
,
"connecting in progress (or finished). Good."
);
return
0
;
/* return success. The onion/circuit/etc will be taken care of automatically
* (may already have been) whenever n_conn reaches OR_CONN_STATE_OPEN.
*/
*/
}
else
{
/* it (or a twin) is already open. use it. */
circ
->
n_addr
=
n_conn
->
addr
;
circ
->
n_port
=
n_conn
->
port
;
...
...
@@ -1084,7 +1084,7 @@ void assert_cpath_layer_ok(const crypt_path_t *cp)
assert
(
cp
->
b_crypto
);
assert
(
cp
->
addr
);
assert
(
cp
->
port
);
switch
(
cp
->
state
)
switch
(
cp
->
state
)
{
case
CPATH_STATE_CLOSED
:
case
CPATH_STATE_OPEN
:
...
...
@@ -1120,7 +1120,7 @@ void assert_cpath_ok(const crypt_path_t *cp)
}
}
void
assert_circuit_ok
(
const
circuit_t
*
c
)
void
assert_circuit_ok
(
const
circuit_t
*
c
)
{
connection_t
*
conn
;
...
...
src/or/command.c
View file @
6a19e640
...
...
@@ -21,7 +21,7 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn,
int
*
num
,
int
*
time
,
void
(
*
func
)(
cell_t
*
,
connection_t
*
))
{
struct
timeval
start
,
end
;
long
time_passed
;
long
time_passed
;
*
num
+=
1
;
...
...
@@ -46,7 +46,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) {
if
(
now
>
current_second
)
{
/* the second has rolled over */
/* print stats */
log
(
LOG_INFO
,
"At end of second:"
);
log
(
LOG_INFO
,
"At end of second:"
);
log
(
LOG_INFO
,
"Create: %d (%d ms)"
,
num_create
,
create_time
/
1000
);
log
(
LOG_INFO
,
"Created: %d (%d ms)"
,
num_created
,
created_time
/
1000
);
log
(
LOG_INFO
,
"Relay: %d (%d ms)"
,
num_relay
,
relay_time
/
1000
);
...
...
src/or/config.c
View file @
6a19e640
...
...
@@ -50,7 +50,7 @@ static struct config_line *config_get_commandlines(int argc, char **argv) {
char
*
s
;
int
i
=
1
;
while
(
i
<
argc
-
1
)
{
while
(
i
<
argc
-
1
)
{
if
(
!
strcmp
(
argv
[
i
],
"-f"
))
{
// log(LOG_DEBUG,"Commandline: skipping over -f.");
i
+=
2
;
/* this is the config file option. ignore it. */
...
...
@@ -119,7 +119,7 @@ static int config_compare(struct config_line *c, char *key, int type, void *arg)
log_fn
(
LOG_DEBUG
,
"Recognized keyword '%s' as %s, using value '%s'."
,
c
->
key
,
key
,
c
->
value
);
switch
(
type
)
{
case
CONFIG_TYPE_INT
:
case
CONFIG_TYPE_INT
:
*
(
int
*
)
arg
=
atoi
(
c
->
value
);
break
;
case
CONFIG_TYPE_BOOL
:
...
...
@@ -205,7 +205,7 @@ static void config_assign(or_options_t *options, struct config_line *list) {
}
list
=
list
->
next
;
}
}
}
/* prints the usage of tor. */
...
...
@@ -300,7 +300,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
previous_runasdaemon
=
options
->
RunAsDaemon
;
free_options
(
options
);
}
init_options
(
options
);
init_options
(
options
);
if
(
argc
>
1
&&
(
!
strcmp
(
argv
[
1
],
"-h"
)
||
!
strcmp
(
argv
[
1
],
"--help"
)))
{
print_usage
();
...
...
@@ -330,7 +330,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
config_assign
(
options
,
cl
);
config_free_lines
(
cl
);
config_close
(
cf
);
/* go through command-line variables too */
cl
=
config_get_commandlines
(
argc
,
argv
);
config_assign
(
options
,
cl
);
...
...
@@ -394,7 +394,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
if
(
options
->
SocksPort
==
0
&&
options
->
ORPort
==
0
)
{
log
(
LOG_WARN
,
"SocksPort and ORPort are both undefined? Quitting."
);
result
=
-
1
;
}
}
if
(
options
->
DirPort
<
0
)
{
log
(
LOG_WARN
,
"DirPort option can't be negative."
);
...
...
src/or/connection.c
View file @
6a19e640
...
...
@@ -146,7 +146,7 @@ int connection_create_listener(char *bindaddress, uint16_t bindport, int type) {
memcpy
(
&
(
bindaddr
.
sin_addr
.
s_addr
),
rent
->
h_addr
,
rent
->
h_length
);
s
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
s
<
0
)
{
if
(
s
<
0
)
{
log_fn
(
LOG_WARN
,
"Socket creation failed."
);
return
-
1
;
}
...
...
@@ -246,7 +246,7 @@ static int connection_init_accepted_conn(connection_t *conn) {
return
0
;
}
/* take conn, make a nonblocking socket; try to connect to
/* take conn, make a nonblocking socket; try to connect to
* addr:port (they arrive in *host order*). If fail, return -1. Else
* assign s to conn->s: if connected return 1, if eagain return 0.
* address is used to make the logs useful.
...
...
@@ -343,7 +343,7 @@ int connection_handle_read(connection_t *conn) {
}
if
(
connection_read_to_buf
(
conn
)
<
0
)
{
if
(
conn
->
type
==
CONN_TYPE_DIR
&&
if
(
conn
->
type
==
CONN_TYPE_DIR
&&
(
conn
->
state
==
DIR_CONN_STATE_CONNECTING_FETCH
||
conn
->
state
==
DIR_CONN_STATE_CONNECTING_UPLOAD
))
{
/* it's a directory server and connecting failed: forget about this router */
...
...
@@ -485,7 +485,7 @@ int connection_handle_write(connection_t *conn) {
/* case TOR_TLS_DONE:
* for TOR_TLS_DONE, fall through to check if the flushlen
* is empty, so we can stop writing.
*/
*/
}
}
else
{
if
(
flush_buf
(
conn
->
s
,
conn
->
outbuf
,
&
conn
->
outbuf_flushlen
)
<
0
)
...
...
@@ -520,7 +520,7 @@ connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
int
i
,
n
;
connection_t
*
conn
;
connection_t
**
carray
;
get_connection_array
(
&
carray
,
&
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
conn
=
carray
[
i
];
...
...
@@ -547,13 +547,13 @@ connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port) {
log
(
LOG_INFO
,
"connection_twin_get_by_addr_port(): Found exact match."
);
return
conn
;
}
/* now check if any of the other open connections are a twin for this one */
router
=
router_get_by_addr_port
(
addr
,
port
);
if
(
!
router
)
return
NULL
;
get_connection_array
(
&
carray
,
&
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
conn
=
carray
[
i
];
...
...
@@ -571,7 +571,7 @@ connection_t *connection_get_by_type(int type) {
int
i
,
n
;
connection_t
*
conn
;
connection_t
**
carray
;
get_connection_array
(
&
carray
,
&
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
conn
=
carray
[
i
];
...
...
@@ -585,7 +585,7 @@ connection_t *connection_get_by_type_state(int type, int state) {
int
i
,
n
;
connection_t
*
conn
;
connection_t
**
carray
;
get_connection_array
(
&
carray
,
&
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
conn
=
carray
[
i
];
...
...
@@ -599,7 +599,7 @@ connection_t *connection_get_by_type_state_lastwritten(int type, int state) {
int
i
,
n
;
connection_t
*
conn
,
*
best
=
NULL
;
connection_t
**
carray
;
get_connection_array
(
&
carray
,
&
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
conn
=
carray
[
i
];
...
...
@@ -616,7 +616,7 @@ int connection_receiver_bucket_should_increase(connection_t *conn) {
if
(
!
connection_speaks_cells
(
conn
))
return
0
;
/* edge connections don't use receiver_buckets */
if
(
conn
->
state
!=
OR_CONN_STATE_OPEN
)
return
0
;
/* only open connections play the rate limiting game */
return
0
;
/* only open connections play the rate limiting game */
assert
(
conn
->
bandwidth
>
0
);
if
(
conn
->
receiver_bucket
>
9
*
conn
->
bandwidth
)
...
...
@@ -653,7 +653,7 @@ int connection_send_destroy(circ_id_t circ_id, connection_t *conn) {
assert
(
conn
);
if
(
!
connection_speaks_cells
(
conn
))
{
log_fn
(
LOG_INFO
,
"CircID %d: At an edge. Marking connection for close."
,
log_fn
(
LOG_INFO
,
"CircID %d: At an edge. Marking connection for close."
,
circ_id
);
if
(
connection_edge_end
(
conn
,
END_STREAM_REASON_DESTROY
,
conn
->
cpath_layer
)
<
0
)
log_fn
(
LOG_WARN
,
"1: I called connection_edge_end redundantly."
);
...
...
@@ -682,9 +682,9 @@ int connection_process_inbuf(connection_t *conn) {
case
CONN_TYPE_DIR
:
return
connection_dir_process_inbuf
(
conn
);
case
CONN_TYPE_DNSWORKER
:
return
connection_dns_process_inbuf
(
conn
);
return
connection_dns_process_inbuf
(
conn
);
case
CONN_TYPE_CPUWORKER
:
return
connection_cpu_process_inbuf
(
conn
);
return
connection_cpu_process_inbuf
(
conn
);
default:
log_fn
(
LOG_WARN
,
"got unexpected conn->type %d."
,
conn
->
type
);
return
-
1
;
...
...
@@ -724,7 +724,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
/* XXX check: wants_to_read, wants_to_write, s, poll_index,
* marked_for_close. */
/* buffers */
if
(
!
connection_is_listener
(
conn
))
{
assert
(
conn
->
inbuf
);
...
...
@@ -735,7 +735,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
assert
(
!
now
||
conn
->
timestamp_lastwritten
<=
now
);
assert
(
conn
->
timestamp_created
<=
conn
->
timestamp_lastread
);
assert
(
conn
->
timestamp_created
<=
conn
->
timestamp_lastwritten
);
/* XXX Fix this; no longer so.*/
#if 0
if(conn->type != CONN_TYPE_OR && conn->type != CONN_TYPE_DIR)
...
...
@@ -758,7 +758,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
if
(
conn
->
state
!=
OR_CONN_STATE_CONNECTING
)
assert
(
conn
->
tls
);
}
if
(
conn
->
type
!=
CONN_TYPE_EXIT
&&
conn
->
type
!=
CONN_TYPE_AP
)
{
assert
(
!
conn
->
stream_id
[
0
]);
assert
(
!
conn
->
next_stream
);
...
...
@@ -768,7 +768,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
assert
(
!
conn
->
done_sending
);
assert
(
!
conn
->
done_receiving
);
}
else
{
assert
(
!
conn
->
next_stream
||
assert
(
!
conn
->
next_stream
||
conn
->
next_stream
->
type
==
CONN_TYPE_EXIT
||
conn
->
next_stream
->
type
==
CONN_TYPE_AP
);
if
(
conn
->
type
==
CONN_TYPE_AP
&&
conn
->
state
==
AP_CONN_STATE_OPEN
)
...
...
@@ -781,7 +781,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
assert
(
!
conn
->
socks_request
);
}
switch
(
conn
->
type
)
switch
(
conn
->
type
)
{
case
CONN_TYPE_OR_LISTENER
:
case
CONN_TYPE_AP_LISTENER
:
...
...
src/or/connection_edge.c
View file @
6a19e640
...
...
@@ -27,7 +27,7 @@ int connection_edge_process_inbuf(connection_t *conn) {
if
(
conn
->
inbuf_reached_eof
)
{
#ifdef HALF_OPEN
/* eof reached; we're done reading, but we might want to write more. */
/* eof reached; we're done reading, but we might want to write more. */
conn
->
done_receiving
=
1
;
shutdown
(
conn
->
s
,
0
);
/* XXX check return, refactor NM */
if
(
conn
->
done_sending
)
{
...
...
@@ -38,7 +38,7 @@ int connection_edge_process_inbuf(connection_t *conn) {
NULL
,
0
,
conn
->
cpath_layer
);
}
return
0
;
#else
#else
/* eof reached, kill it. */
log_fn
(
LOG_INFO
,
"conn (fd %d) reached eof. Closing."
,
conn
->
s
);
if
(
connection_edge_end
(
conn
,
END_STREAM_REASON_DONE
,
conn
->
cpath_layer
)
<
0
)
...
...
@@ -676,7 +676,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t
memcpy
(
payload
,
ap_conn
->
stream_id
,
STREAM_ID_SIZE
);
payload_len
=
STREAM_ID_SIZE
+
1
+
snprintf
(
payload
+
STREAM_ID_SIZE
,
CELL_PAYLOAD_SIZE
-
RELAY_HEADER_SIZE
-
STREAM_ID_SIZE
,
"%s:%d"
,
"%s:%d"
,
string_addr
?
string_addr
:
ap_conn
->
socks_request
->
address
,
ap_conn
->
socks_request
->
port
);
...
...
@@ -692,7 +692,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t
/* XXX Right now, we rely on the socks client not to send us any data
* XXX until we've sent back a socks reply. (If it does, we could wind
* XXX up packaging that data and sending it to the exit, then later having
* XXX the exit refuse us.)
* XXX the exit refuse us.)
* XXX Perhaps we should grow an AP_CONN_STATE_CONNECTING state.
*/
log_fn
(
LOG_INFO
,
"Address/port sent, ap socket %d, n_circ_id %d"
,
ap_conn
->
s
,
circ
->
n_circ_id
);
...
...
@@ -865,7 +865,7 @@ static int client_dns_size = 0;
static
SPLAY_HEAD
(
client_dns_tree
,
client_dns_entry
)
client_dns_root
;
static
int
compare_client_dns_entries
(
struct
client_dns_entry
*
a
,
struct
client_dns_entry
*
b
)
struct
client_dns_entry
*
b
)
{
return
strcasecmp
(
a
->
address
,
b
->
address
);
}
...
...
@@ -962,7 +962,7 @@ void client_dns_clean(void)
if
(
!
client_dns_size
)
return
;
expired_entries
=
tor_malloc
(
client_dns_size
*
expired_entries
=
tor_malloc
(
client_dns_size
*
sizeof
(
struct
client_dns_entry
*
));
now
=
time
(
NULL
);
...
...
src/or/connection_or.c
View file @
6a19e640
...
...
@@ -118,7 +118,7 @@ connection_t *connection_or_connect(routerinfo_t *router) {
return
NULL
;
case
0
:
connection_set_poll_socket
(
conn
);
connection_watch_events
(
conn
,
POLLIN
|
POLLOUT
|
POLLERR
);
connection_watch_events
(
conn
,
POLLIN
|
POLLOUT
|
POLLERR
);
/* writable indicates finish, readable indicates broken link,
error indicates broken link on windows */
conn
->
state
=
OR_CONN_STATE_CONNECTING
;
...
...
@@ -248,7 +248,7 @@ void connection_or_write_cell_to_buf(const cell_t *cellp, connection_t *conn) {
assert
(
connection_speaks_cells
(
conn
));
cell_pack
(
n
,
cellp
);
connection_write_to_buf
(
n
,
CELL_NETWORK_SIZE
,
conn
);
}
...
...
@@ -262,13 +262,13 @@ loop:
conn
->
s
,(
int
)
buf_datalen
(
conn
->
inbuf
),
tor_tls_get_pending_bytes
(
conn
->
tls
));
if
(
buf_datalen
(
conn
->
inbuf
)
<
CELL_NETWORK_SIZE
)
/* entire response available? */
return
0
;
/* not yet */
connection_fetch_from_buf
(
buf
,
CELL_NETWORK_SIZE
,
conn
);
/* retrieve cell info from buf (create the host-order struct from the
* network-order string) */
cell_unpack
(
&
cell
,
buf
);
command_process_cell
(
&
cell
,
conn
);
goto
loop
;
/* process the remainder of the buffer */
...
...
src/or/directory.c
View file @
6a19e640
...
...
@@ -165,7 +165,7 @@ static int directory_handle_command_get(connection_t *conn,
return
-
1
;
/* XXX send some helpful http error code */
}
log_fn
(
LOG_DEBUG
,
"Dumping directory to client."
);
log_fn
(
LOG_DEBUG
,
"Dumping directory to client."
);
connection_write_to_buf
(
answerstring
,
strlen
(
answerstring
),
conn
);
connection_write_to_buf
(
cp
,
dlen
,
conn
);
conn
->
state
=
DIR_CONN_STATE_SERVER_WRITING
;
...
...
src/or/dirserv.c
View file @
6a19e640
...
...
@@ -141,7 +141,7 @@ dirserv_router_fingerprint_is_known(const routerinfo_t *router)
}
}
void
void
dirserv_free_fingerprint_list
()
{
int
i
;
...
...
@@ -285,17 +285,17 @@ dirserv_add_descriptor(const char **desc)
tor_free
(
desc_tmp
);
if
(
ri
)
routerinfo_free
(
ri
);
return
-
1
;
}
void
void
directory_set_dirty
()
{
the_directory_is_dirty
=
1
;
}
int
int
dirserv_init_from_directory_string
(
const
char
*
dir
)
{
const
char
*
cp
=
dir
;
...
...
@@ -343,7 +343,7 @@ list_running_servers(char **nicknames_out)
if
(
i
)
strcat
(
cp
,
" "
);
strcat
(
cp
,
nickname_lst
[
i
]);
while
(
*
cp
)
while
(
*
cp
)
++
cp
;
}
return
0
;
...
...
src/or/onion.c
View file @
6a19e640
...
...
@@ -111,7 +111,7 @@ void onion_pending_remove(circuit_t *circ) {
/* now victim points to the element that needs to be removed */
free
(
victim
);
free
(
victim
);
}
/* given a response payload and keys, initialize, then send a created cell back */
...
...
@@ -266,7 +266,7 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
carray
[
j
]
->
marked_for_close
||
circuit_stream_is_being_handled
(
carray
[
j
]))
continue
;
/* Skip everything but APs in CIRCUIT_WAIT */
switch
(
connection_ap_can_use_exit
(
carray
[
j
],
dir
->
routers
[
i
]))
switch
(
connection_ap_can_use_exit
(
carray
[
j
],
dir
->
routers
[
i
]))
{
case
-
1
:
log_fn
(
LOG_DEBUG
,
"%s (index %d) would reject this stream."
,
...
...
@@ -283,7 +283,7 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
dir
->
routers
[
i
]
->
nickname
,
i
,
n_maybe_supported
[
i
]);
}
}
/* End looping over connections. */
if
(
n_supported
[
i
]
>
best_support
)
{
if
(
n_supported
[
i
]
>
best_support
)
{
/* If this router is better than previous ones, remember its index
* and goodness, and start counting how many routers are this good. */
best_support
=
n_supported
[
i
];
best_support_idx
=
i
;
n_best_support
=
1
;
...
...
@@ -372,7 +372,7 @@ cpath_build_state_t *onion_new_cpath_build_state(void) {
router_get_routerlist
(
&
rl
);
r
=
new_route_len
(
options
.
PathlenCoinWeight
,
rl
->
routers
,
rl
->
n_routers
);
if
(
r
<
0
)
if
(
r
<
0
)
return
NULL
;
exit
=
choose_good_exit_server
(
rl
);
if
(
!
exit
)
...
...
@@ -459,10 +459,10 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
++
cur_len
;
}
}
if
(
cur_len
>=
state
->
desired_path_len
)
{
log_fn
(
LOG_DEBUG
,
"Path is complete: %d steps long"
,
if
(
cur_len
>=
state
->
desired_path_len
)
{
log_fn
(
LOG_DEBUG
,
"Path is complete: %d steps long"
,
state
->
desired_path_len
);
return
1
;
return
1
;
}
log_fn
(
LOG_DEBUG
,
"Path is %d long; we want %d"
,
cur_len
,
state
->
desired_path_len
);
...
...
@@ -544,7 +544,7 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
hop
->
package_window
=
CIRCWINDOW_START
;
hop
->
deliver_window
=
CIRCWINDOW_START
;
log_fn
(
LOG_DEBUG
,
"Extended circuit path with %s for hop %d"
,
log_fn
(
LOG_DEBUG
,
"Extended circuit path with %s for hop %d"
,
choice
->
nickname
,
cur_len
);
*
router_out
=
choice
;
...
...
@@ -600,7 +600,7 @@ onion_skin_create(crypto_pk_env_t *dest_router_key,
* of 'challenge' to 0. This means that our symmetric key is really
* only 127 bits.
*/
challenge
[
0
]
&=
0x7f
;
challenge
[
0
]
&=
0x7f
;
if
(
crypto_dh_get_public
(
dh
,
challenge
+
16
,
dhbytes
))
goto
err
;
...
...
src/or/or.h
View file @
6a19e640
...
...
@@ -317,7 +317,7 @@ struct connection_t {
/* Used only by OR connections: */
tor_tls
*
tls
;
circ_id_t
next_circ_id
;
/* Which circ_id do we try to use next on this connection?
circ_id_t
next_circ_id
;
/* Which circ_id do we try to use next on this connection?
* This is always in the range 0..1<<15-1.*/
/* bandwidth and receiver_bucket only used by ORs in OPEN state: */
...
...
@@ -337,7 +337,7 @@ struct connection_t {
int
done_receiving
;
char
has_sent_end
;
/* for debugging: set once we've set the stream end,
and check in circuit_about_to_close_connection() */
/* Used only by AP connections */
socks_request_t
*
socks_request
;
};
...
...
@@ -362,18 +362,18 @@ struct exit_policy_t {
typedef
struct
{
char
*
address
;
char
*
nickname
;
uint32_t
addr
;
/* all host order */
uint16_t
or_port
;
uint16_t
socks_port
;
uint16_t
dir_port
;
time_t
published_on
;
crypto_pk_env_t
*
onion_pkey
;
/* public RSA key for onions */
crypto_pk_env_t
*
link_pkey
;
/* public RSA key for TLS */
crypto_pk_env_t
*
identity_pkey
;
/* public RSA key for signing */