Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Gus
Tor
Commits
c8639b2b
Commit
c8639b2b
authored
21 years ago
by
Roger Dingledine
Browse files
Options
Downloads
Patches
Plain Diff
bump default pathlen to 3; clean up surrounding code
svn:r810
parent
56cd147e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/config.c
+6
-7
6 additions, 7 deletions
src/or/config.c
src/or/onion.c
+5
-24
5 additions, 24 deletions
src/or/onion.c
src/or/or.h
+1
-1
1 addition, 1 deletion
src/or/or.h
with
12 additions
and
32 deletions
src/or/config.c
+
6
−
7
View file @
c8639b2b
...
...
@@ -153,8 +153,6 @@ static void config_assign(or_options_t *options, struct config_line *list) {
/* string options */
config_compare
(
list
,
"Address"
,
CONFIG_TYPE_STRING
,
&
options
->
Address
)
||
config_compare
(
list
,
"CoinWeight"
,
CONFIG_TYPE_DOUBLE
,
&
options
->
CoinWeight
)
||
config_compare
(
list
,
"DebugLogFile"
,
CONFIG_TYPE_STRING
,
&
options
->
DebugLogFile
)
||
config_compare
(
list
,
"DataDirectory"
,
CONFIG_TYPE_STRING
,
&
options
->
DataDirectory
)
||
config_compare
(
list
,
"DirPort"
,
CONFIG_TYPE_INT
,
&
options
->
DirPort
)
||
...
...
@@ -187,10 +185,11 @@ static void config_assign(or_options_t *options, struct config_line *list) {
config_compare
(
list
,
"OnionRouter"
,
CONFIG_TYPE_BOOL
,
&
options
->
OnionRouter
)
||
config_compare
(
list
,
"PidFile"
,
CONFIG_TYPE_STRING
,
&
options
->
PidFile
)
||
config_compare
(
list
,
"PathlenCoinWeight"
,
CONFIG_TYPE_DOUBLE
,
&
options
->
PathlenCoinWeight
)
||
config_compare
(
list
,
"RouterFile"
,
CONFIG_TYPE_STRING
,
&
options
->
RouterFile
)
||
config_compare
(
list
,
"RunAsDaemon"
,
CONFIG_TYPE_BOOL
,
&
options
->
RunAsDaemon
)
||
config_compare
(
list
,
"RecommendedVersions"
,
CONFIG_TYPE_STRING
,
&
options
->
RecommendedVersions
)
||
config_compare
(
list
,
"RecommendedVersions"
,
CONFIG_TYPE_STRING
,
&
options
->
RecommendedVersions
)
||
config_compare
(
list
,
"SocksPort"
,
CONFIG_TYPE_INT
,
&
options
->
SocksPort
)
||
config_compare
(
list
,
"SocksBindAddress"
,
CONFIG_TYPE_STRING
,
&
options
->
SocksBindAddress
)
||
...
...
@@ -262,7 +261,7 @@ void init_options(or_options_t *options) {
options
->
loglevel
=
LOG_INFO
;
options
->
PidFile
=
tor_strdup
(
"tor.pid"
);
options
->
DataDirectory
=
NULL
;
options
->
CoinWeight
=
0
.
1
;
options
->
Pathlen
CoinWeight
=
0
.
3
;
options
->
MaxConn
=
900
;
options
->
DirFetchPostPeriod
=
600
;
options
->
KeepalivePeriod
=
300
;
...
...
@@ -338,7 +337,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
/* Validate options */
/* first check if
some
of the previous options have changed but aren't allowed to */
/* first check if
any
of the previous options have changed but aren't allowed to */
if
(
previous_pidfile
&&
strcmp
(
previous_pidfile
,
options
->
PidFile
))
{
log_fn
(
LOG_WARN
,
"During reload, PidFile changed from %s to %s. Failing."
,
previous_pidfile
,
options
->
PidFile
);
...
...
@@ -412,8 +411,8 @@ int getconfig(int argc, char **argv, or_options_t *options) {
}
if
(
options
->
SocksPort
>
1
&&
(
options
->
CoinWeight
<
0
.
0
||
options
->
CoinWeight
>=
1
.
0
))
{
log
(
LOG_WARN
,
"CoinWeight option must be >=0.0 and <1.0."
);
(
options
->
Pathlen
CoinWeight
<
0
.
0
||
options
->
Pathlen
CoinWeight
>=
1
.
0
))
{
log
(
LOG_WARN
,
"
Pathlen
CoinWeight option must be >=0.0 and <1.0."
);
result
=
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
src/or/onion.c
+
5
−
24
View file @
c8639b2b
...
...
@@ -187,34 +187,15 @@ char **parse_nickname_list(char *list, int *num) {
return
out
;
}
/* uses a weighted coin with weight cw to choose a route length */
static
int
chooselen
(
double
cw
)
{
int
len
=
2
;
if
((
cw
<
0
)
||
(
cw
>=
1
))
/* invalid parameter */
return
-
1
;
while
(
1
)
{
if
(
crypto_pseudo_rand_int
(
255
)
>
cw
*
255
)
/* don't extend */
break
;
else
len
++
;
}
return
len
;
}
static
int
new_route_len
(
double
cw
,
routerinfo_t
**
rarray
,
int
rarray_len
)
{
int
num_acceptable_routers
;
int
routelen
;
assert
((
cw
>=
0
)
&&
(
cw
<
1
)
&&
(
rarray
)
)
;
/* valid parameters */
assert
((
cw
>=
0
)
&&
(
cw
<
1
)
&&
rarray
);
/* valid parameters */
routelen
=
chooselen
(
cw
);
if
(
routelen
==
-
1
)
{
log_fn
(
LOG_WARN
,
"Choosing route length failed."
);
return
-
1
;
for
(
routelen
=
3
;
;
routelen
++
)
{
/* 3, increment until coinflip says we're done */
if
(
crypto_pseudo_rand_int
(
255
)
>=
cw
*
255
)
/* don't extend */
break
;
}
log_fn
(
LOG_DEBUG
,
"Chosen route length %d (%d routers available)."
,
routelen
,
rarray_len
);
...
...
@@ -242,7 +223,7 @@ int onion_new_route_len(void) {
directory_t
*
dir
;
router_get_directory
(
&
dir
);
return
new_route_len
(
options
.
CoinWeight
,
dir
->
routers
,
dir
->
n_routers
);
return
new_route_len
(
options
.
Pathlen
CoinWeight
,
dir
->
routers
,
dir
->
n_routers
);
}
static
int
count_acceptable_routers
(
routerinfo_t
**
rarray
,
int
rarray_len
)
{
...
...
This diff is collapsed.
Click to expand it.
src/or/or.h
+
1
−
1
View file @
c8639b2b
...
...
@@ -439,7 +439,7 @@ typedef struct {
char
*
RecommendedVersions
;
char
*
User
;
char
*
Group
;
double
CoinWeight
;
double
Pathlen
CoinWeight
;
int
ORPort
;
int
SocksPort
;
int
DirPort
;
...
...
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