summaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-09-30 18:37:53 -0400
committerNick Mathewson <nickm@torproject.org>2010-10-01 18:14:27 -0400
commitb5341314c17573db15a7cc5999f36569c764c462 (patch)
tree94da14bd12577e5751391084e93e597ecc29df62 /src/or/nodelist.c
parentf9ea242acabcaec0ab0fbd0de5e9999dfcdb0193 (diff)
downloadtor-b5341314c17573db15a7cc5999f36569c764c462.tar.gz
tor-b5341314c17573db15a7cc5999f36569c764c462.zip
Implement a few more node-based functions
Some of these functions only work for routerinfo-based nodes, and as such are only usable for advisory purposes. Fortunately, our uses of them are compatible with this limitation.
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 7c036982d5..9518114479 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -656,9 +656,10 @@ node_get_address_string(const node_t *node, char *buf, size_t len)
long
node_get_declared_uptime(const node_t *node)
{
- (void)node;
- UNIMPLEMENTED_NODELIST();
- return 0;
+ if (node->ri)
+ return node->ri->uptime;
+ else
+ return -1;
}
/** Return <b>node</b>'s declared or_port */
@@ -673,22 +674,27 @@ node_get_orport(const node_t *node)
return 0;
}
-/** Return <b>node</b>'s platform string */
+/** Return <b>node</b>'s platform string, or NULL if we don't know it. */
const char *
node_get_platform(const node_t *node)
{
- (void)node;
- UNIMPLEMENTED_NODELIST();
- return NULL;
+ /* If we wanted, we could record the version in the routerstatus_t, since
+ * the consensus lists it. We don't, though, so this function just won't
+ * work with microdescriptors. */
+ if (node->ri)
+ return node->ri->platform;
+ else
+ return NULL;
}
-/** Return <b>node</b>'s time of publication. */
+/** Return <b>node</b>'s time of publication, or 0 if we don't have one. */
time_t
node_get_published_on(const node_t *node)
{
- (void)node;
- UNIMPLEMENTED_NODELIST();
- return 0;
+ if (node->ri)
+ return node->ri->cache_info.published_on;
+ else
+ return 0;
}
/** Return true iff <b>node</b> is one representing this router. */