aboutsummaryrefslogtreecommitdiff
path: root/src/or/routers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-09-26 18:27:35 +0000
committerNick Mathewson <nickm@torproject.org>2003-09-26 18:27:35 +0000
commit92acbe12bc9512100b9282d7e9d61fe86b5a60bb (patch)
tree80cd3c92c91f30818c60a97842a1f106a8cb27ac /src/or/routers.c
parent9e5cafc395397426030e8098d64b8e25625863c5 (diff)
downloadtor-92acbe12bc9512100b9282d7e9d61fe86b5a60bb.tar
tor-92acbe12bc9512100b9282d7e9d61fe86b5a60bb.tar.gz
Refactor common file code into util.c; add published to descriptors
svn:r487
Diffstat (limited to 'src/or/routers.c')
-rw-r--r--src/or/routers.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/or/routers.c b/src/or/routers.c
index eb8c6163a..687277153 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -318,6 +318,7 @@ typedef enum {
K_ONION_KEY,
K_LINK_KEY,
K_ROUTER_SIGNATURE,
+ K_PUBLISHED,
_SIGNATURE,
_PUBLIC_KEY,
_ERR,
@@ -337,6 +338,7 @@ static struct token_table_ent token_table[] = {
{ "onion-key", K_ONION_KEY },
{ "link-key", K_LINK_KEY },
{ "router-signature", K_ROUTER_SIGNATURE },
+ { "published", K_PUBLISHED },
{ NULL, -1 }
};
@@ -492,6 +494,7 @@ router_dump_token(directory_token_t *tok) {
case K_ONION_KEY: printf("Onion-key"); break;
case K_LINK_KEY: printf("Link-key"); break;
case K_ROUTER_SIGNATURE: printf("Router-signature"); break;
+ case K_PUBLISHED: printf("Published"); break;
default:
printf("?????? %d\n", tok->tp); return;
}
@@ -513,7 +516,6 @@ router_get_next_token(char **s, directory_token_t *tok) {
#endif
-
/* return the first char of s that is not whitespace and not a comment */
static char *eat_whitespace(char *s) {
assert(s);
@@ -817,6 +819,7 @@ routerinfo_t *router_get_entry_from_string(char**s) {
char digest[128];
directory_token_t _tok;
directory_token_t *tok = &_tok;
+ struct tm published;
#define NEXT_TOKEN() \
do { if (router_get_next_token(s, tok)) { \
@@ -876,6 +879,19 @@ routerinfo_t *router_get_entry_from_string(char**s) {
router->or_port, router->ap_port, router->dir_port, router->bandwidth);
NEXT_TOKEN();
+ if (tok->tp != K_PUBLISHED) {
+ log_fn(LOG_WARNING, "Missing published time"); goto err;
+ }
+ if (tok->val.cmd.n_args != 2) {
+ log_fn(LOG_WARNING, "Wrong number of arguments to published"); goto err;
+ }
+ tok->val.cmd.args[1][-1] = ' '; /* Re-insert space. */
+ if (!strptime(tok->val.cmd.args[0], "%Y-%m-%d %H:%M:%S", &published)) {
+ log_fn(LOG_WARNING, "Published time was unparseable"); goto err;
+ }
+ router->published_on = timegm(&published);
+
+ NEXT_TOKEN();
if (tok->tp != K_ONION_KEY) {
log_fn(LOG_WARNING, "Missing onion-key"); goto err;
}