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
Container Registry
Model registry
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
The Tor Project
Core
Tor
Commits
06b72cc8
Commit
06b72cc8
authored
20 years ago
by
Roger Dingledine
Browse files
Options
Downloads
Patches
Plain Diff
publish advertised_bandwidth in descriptor
svn:r2095
parent
eb0a19c4
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/main.c
+14
-7
14 additions, 7 deletions
src/or/main.c
src/or/or.h
+2
-0
2 additions, 0 deletions
src/or/or.h
src/or/router.c
+16
-0
16 additions, 0 deletions
src/or/router.c
with
32 additions
and
7 deletions
src/or/main.c
+
14
−
7
View file @
06b72cc8
...
...
@@ -416,7 +416,10 @@ static void run_connection_housekeeping(int i, time_t now) {
* - We believe we are reachable from the outside.
*/
static
int
decide_if_publishable_server
(
time_t
now
)
{
int
r
;
int
bw
;
bw
=
rep_hist_bandwidth_assess
(
now
);
router_set_advertised_bandwidth
(
bw
);
if
(
options
.
ClientOnly
)
return
0
;
...
...
@@ -433,12 +436,10 @@ static int decide_if_publishable_server(time_t now) {
return
0
;
}
r
=
rep_hist_bandwidth_assess
(
now
);
// set_advertised_bandwidth(r);
if
(
r
<
MIN_BW_TO_PUBLISH_DESC
)
if
(
bw
<
MIN_BW_TO_PUBLISH_DESC
)
return
0
;
if
(
options
.
AuthoritativeDir
)
return
1
;
...
...
@@ -467,10 +468,13 @@ int server_mode(void) {
return
(
options
.
ORPort
!=
0
);
}
/** Remember if we've advertised ourselves to the dirservers. */
static
int
server_is_advertised
=
0
;
/** Return true iff we have published our descriptor lately.
*/
int
advertised_server_mode
(
void
)
{
return
(
options
.
ORPort
!=
0
)
;
return
server_is_advertised
;
}
/** Return true iff we are trying to be a socks proxy. */
...
...
@@ -506,8 +510,8 @@ static void run_scheduled_events(time_t now) {
if
(
router_rebuild_descriptor
()
<
0
)
{
log_fn
(
LOG_WARN
,
"Couldn't rebuild router descriptor"
);
}
/* XXX008 only
if
advertised_server_mode
*/
router_upload_dir_desc_to_dirservers
();
if
(
advertised_server_mode
())
router_upload_dir_desc_to_dirservers
();
}
/** 1b. Every MAX_SSL_KEY_LIFETIME seconds, we change our TLS context. */
...
...
@@ -532,8 +536,11 @@ static void run_scheduled_events(time_t now) {
if
(
time_to_fetch_directory
<
now
)
{
if
(
decide_if_publishable_server
(
now
))
{
server_is_advertised
=
1
;
router_rebuild_descriptor
();
router_upload_dir_desc_to_dirservers
();
}
else
{
server_is_advertised
=
0
;
}
routerlist_remove_old_routers
();
/* purge obsolete entries */
...
...
This diff is collapsed.
Click to expand it.
src/or/or.h
+
2
−
0
View file @
06b72cc8
...
...
@@ -1346,6 +1346,8 @@ void dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last);
int
init_keys
(
void
);
crypto_pk_env_t
*
init_key_from_file
(
const
char
*
fname
);
void
rotate_onion_key
(
void
);
void
router_set_advertised_bandwidth
(
int
bw
);
int
router_get_advertised_bandwidth
(
void
);
void
router_retry_connections
(
void
);
int
router_is_clique_mode
(
routerinfo_t
*
router
);
...
...
This diff is collapsed.
Click to expand it.
src/or/router.c
+
16
−
0
View file @
06b72cc8
...
...
@@ -124,6 +124,21 @@ void rotate_onion_key(void)
log_fn
(
LOG_WARN
,
"Couldn't rotate onion key."
);
}
/** The last calculated bandwidth usage for our node. */
static
int
advertised_bw
=
0
;
/** Tuck <b>bw</b> away so we can produce it when somebody
* calls router_get_advertised_bandwidth() below.
*/
void
router_set_advertised_bandwidth
(
int
bw
)
{
advertised_bw
=
bw
;
}
/** Return the value we tucked away above, or zero by default. */
int
router_get_advertised_bandwidth
(
void
)
{
return
advertised_bw
;
}
/* Read an RSA secret key key from a file that was once named fname_old,
* but is now named fname_new. Rename the file from old to new as needed.
*/
...
...
@@ -513,6 +528,7 @@ int router_rebuild_descriptor(void) {
ri
->
platform
=
tor_strdup
(
platform
);
ri
->
bandwidthrate
=
options
.
BandwidthRate
;
ri
->
bandwidthburst
=
options
.
BandwidthBurst
;
ri
->
advertisedbandwidth
=
router_get_advertised_bandwidth
();
ri
->
exit_policy
=
NULL
;
/* zero it out first */
router_add_exit_policy_from_config
(
ri
);
ri
->
is_trusted_dir
=
authdir_mode
();
...
...
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