diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-25 20:46:13 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-25 20:46:13 +0000 |
commit | bbaa3c7792792d9899ed36d9b0db4703c617a7a3 (patch) | |
tree | f0d37ff02bafecbad300710532f6e847cb3d8756 /src/common | |
parent | d21f007a8465b7c04d4ea8084501a588af4874a6 (diff) | |
download | tor-bbaa3c7792792d9899ed36d9b0db4703c617a7a3.tar tor-bbaa3c7792792d9899ed36d9b0db4703c617a7a3.tar.gz |
Implement more control spec functionality
- Mapaddress
- Postdescriptor
- GetInfo on descriptors
Required changes elsewhere:
- Keep the most recent running_routers_t in the routerlist_t. That way we
can learn about new routers and remember whether we were last told that
they were up or down. Also enables more simplifications.
- Keep the signed descriptor inside routerinfo_t. This makes
descriptor_entry_t in dirservers.c unneeded.
- Rename AddressMap (the verb) to MapAddress. Keep AddressMap as a noun.
- Check addresses for plausibility before mapping them.
svn:r3696
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.h | 2 | ||||
-rw-r--r-- | src/common/util.c | 15 | ||||
-rw-r--r-- | src/common/util.h | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h index f813becbc..801f1893f 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -86,6 +86,8 @@ int tor_snprintf(char *str, size_t size, const char *format, ...) CHECK_PRINTF(3,4); int tor_vsnprintf(char *str, size_t size, const char *format, va_list args); +#define TOR_ISAPLHA(c) isalpha((int)(unsigned char)(c)) +#define TOR_ISALNUM(c) isalnum((int)(unsigned char)(c)) #define TOR_ISSPACE(c) isspace((int)(unsigned char)(c)) #define TOR_ISXDIGIT(c) isxdigit((int)(unsigned char)(c)) #define TOR_ISDIGIT(c) isdigit((int)(unsigned char)(c)) diff --git a/src/common/util.c b/src/common/util.c index 339572e44..50e81603d 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1266,6 +1266,21 @@ tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len) (int)(uint8_t)((a )&0xff)); } +/* DOCDOC */ +int +is_plausible_address(const char *name) +{ + const char *cp; + tor_assert(name); + /* We could check better here. */ + for (cp=name; *cp; cp++) { + if (*cp != '.' && *cp != '-' && !TOR_ISALNUM(*cp)) + return 0; + } + + return 1; +} + /* ===== * Process helpers * ===== */ diff --git a/src/common/util.h b/src/common/util.h index fde2557f5..65c0f105a 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -128,6 +128,7 @@ int parse_addr_and_port_range(const char *s, uint32_t *addr_out, uint16_t *port_max_out); #define INET_NTOA_BUF_LEN 16 int tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len); +int is_plausible_address(const char *name); /* Process helpers */ void start_daemon(const char *desired_cwd); |