Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin J. Thompson
Tor
Commits
0c4baa01
Commit
0c4baa01
authored
11 years ago
by
George Kadianakis
Browse files
Options
Downloads
Patches
Plain Diff
Also test that server transports get written to Tor's state.
parent
00a7d1af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/statefile.c
+2
-1
2 additions, 1 deletion
src/or/statefile.c
src/or/statefile.h
+4
-0
4 additions, 0 deletions
src/or/statefile.h
src/test/test_pt.c
+25
-2
25 additions, 2 deletions
src/test/test_pt.c
with
31 additions
and
3 deletions
src/or/statefile.c
+
2
−
1
View file @
0c4baa01
...
...
@@ -4,6 +4,7 @@
* Copyright (c) 2007-2013, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define STATEFILE_PRIVATE
#include
"or.h"
#include
"circuitstats.h"
#include
"config.h"
...
...
@@ -449,7 +450,7 @@ or_state_save(time_t now)
/** Return the config line for transport <b>transport</b> in the current state.
* Return NULL if there is no config line for <b>transport</b>. */
static
config_line_t
*
STATIC
config_line_t
*
get_transport_in_state_by_name
(
const
char
*
transport
)
{
or_state_t
*
or_state
=
get_or_state
();
...
...
This diff is collapsed.
Click to expand it.
src/or/statefile.h
+
4
−
0
View file @
0c4baa01
...
...
@@ -18,5 +18,9 @@ int or_state_load(void);
int
or_state_loaded
(
void
);
void
or_state_free_all
(
void
);
#ifdef STATEFILE_PRIVATE
STATIC
config_line_t
*
get_transport_in_state_by_name
(
const
char
*
transport
);
#endif
#endif
This diff is collapsed.
Click to expand it.
src/test/test_pt.c
+
25
−
2
View file @
0c4baa01
...
...
@@ -6,6 +6,7 @@
#include
"orconfig.h"
#define PT_PRIVATE
#define UTIL_PRIVATE
#define STATEFILE_PRIVATE
#include
"or.h"
#include
"config.h"
#include
"confparse.h"
...
...
@@ -291,10 +292,10 @@ tor_get_lines_from_handle_replacement(STDIN_HANDLE *handle,
/* Generate some dummy CMETHOD lines the first 5 times. The 6th
time, send 'CMETHODS DONE' to finish configuring the proxy. */
if
(
times_called
++
!=
5
)
{
smartlist_add_asprintf
(
retval_sl
,
"
C
METHOD mock%d
socks5
127.0.0.1:555%d"
,
smartlist_add_asprintf
(
retval_sl
,
"
S
METHOD mock%d 127.0.0.1:555%d"
,
times_called
,
times_called
);
}
else
{
smartlist_add
(
retval_sl
,
tor_strdup
(
"
C
METHODS DONE"
));
smartlist_add
(
retval_sl
,
tor_strdup
(
"
S
METHODS DONE"
));
}
return
retval_sl
;
...
...
@@ -341,6 +342,7 @@ test_pt_configure_proxy(void *arg)
mp
->
process_handle
=
tor_malloc_zero
(
sizeof
(
process_handle_t
));
mp
->
argv
=
tor_malloc_zero
(
sizeof
(
char
*
)
*
2
);
mp
->
argv
[
0
]
=
tor_strdup
(
"<testcase>"
);
mp
->
is_server
=
1
;
/* Test the return value of configure_proxy() by calling it some
times while it is uninitialized and then finally finalizing its
...
...
@@ -362,6 +364,27 @@ test_pt_configure_proxy(void *arg)
/* check the mp state */
test_assert
(
mp
->
conf_state
==
PT_PROTO_COMPLETED
);
{
/* check that the transport info were saved properly in the tor state */
config_line_t
*
transport_in_state
=
NULL
;
smartlist_t
*
transport_info_sl
=
smartlist_new
();
char
*
name_of_transport
=
NULL
;
char
*
bindaddr
=
NULL
;
/* Get the bindaddr for "mock1" and check it against the bindaddr
that the mocked tor_get_lines_from_handle() generated. */
transport_in_state
=
get_transport_in_state_by_name
(
"mock1"
);
test_assert
(
transport_in_state
);
smartlist_split_string
(
transport_info_sl
,
transport_in_state
->
value
,
NULL
,
0
,
0
);
name_of_transport
=
smartlist_get
(
transport_info_sl
,
0
);
bindaddr
=
smartlist_get
(
transport_info_sl
,
1
);
tt_str_op
(
name_of_transport
,
==
,
"mock1"
);
tt_str_op
(
bindaddr
,
==
,
"127.0.0.1:5551"
);
SMARTLIST_FOREACH
(
transport_info_sl
,
char
*
,
cp
,
tor_free
(
cp
));
smartlist_free
(
transport_info_sl
);
}
done:
tor_free
(
dummy_state
);
UNMOCK
(
tor_get_lines_from_handle
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment