From 92acbe12bc9512100b9282d7e9d61fe86b5a60bb Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Sep 2003 18:27:35 +0000 Subject: Refactor common file code into util.c; add published to descriptors svn:r487 --- src/or/routers.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/or/routers.c') 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)) { \ @@ -875,6 +878,19 @@ routerinfo_t *router_get_entry_from_string(char**s) { log_fn(LOG_DEBUG,"or_port %d, ap_port %d, dir_port %d, bandwidth %d.", 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; -- cgit v1.2.3