diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-05-01 20:13:49 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-05-01 20:13:49 +0000 |
commit | 89ab267cfbf1994b6b82a7de107fde5337aa485a (patch) | |
tree | aefd51d54d5eba93e269b066c65fc084f0de6969 /src/or/router.c | |
parent | 0faaa16b0cb876d01f9267b047a642da477a0c52 (diff) | |
download | tor-89ab267cfbf1994b6b82a7de107fde5337aa485a.tar.gz tor-89ab267cfbf1994b6b82a7de107fde5337aa485a.zip |
r12619@catbus: nickm | 2007-05-01 16:13:42 -0400
Add code to upload extrainfos to authorities running 0.2.0.0-alpha-dev (r10070) or later.
svn:r10086
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/or/router.c b/src/or/router.c index 1516bf374d..47a60b3226 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -726,19 +726,38 @@ static int desc_needs_upload = 0; void router_upload_dir_desc_to_dirservers(int force) { - const char *s; + routerinfo_t *ri; + extrainfo_t *ei; + char *msg; + size_t desc_len, extra_len = 0, total_len; + int post_extra; - s = router_get_my_descriptor(); - if (!s) { + ri = router_get_my_routerinfo(); + if (!ri) { log_info(LD_GENERAL, "No descriptor; skipping upload"); return; } + ei = router_get_my_extrainfo(); + post_extra = ei && get_options()->_UploadExtraInfo; if (!get_options()->PublishServerDescriptor) return; if (!force && !desc_needs_upload) return; desc_needs_upload = 0; - directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, s, strlen(s)); + + desc_len = ri->cache_info.signed_descriptor_len; + extra_len = (ei && post_extra) ? ei->cache_info.signed_descriptor_len : 0; + total_len = desc_len + extra_len + 1; + msg = tor_malloc(total_len); + memcpy(msg, ri->cache_info.signed_descriptor_body, desc_len); + if (ei && post_extra) { + memcpy(msg+desc_len, ei->cache_info.signed_descriptor_body, extra_len); + } + msg[desc_len+extra_len] = 0; + + directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, msg, desc_len, + extra_len); + tor_free(msg); } /** OR only: Check whether my exit policy says to allow connection to |