[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Implement more control spec functionality
Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv13952/src/common
Modified Files:
compat.h util.c util.h
Log Message:
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.
Index: compat.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- compat.h 22 Feb 2005 23:52:42 -0000 1.23
+++ compat.h 25 Feb 2005 20:46:12 -0000 1.24
@@ -86,6 +86,8 @@
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))
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- util.c 22 Feb 2005 08:18:34 -0000 1.203
+++ util.c 25 Feb 2005 20:46:12 -0000 1.204
@@ -1266,6 +1266,21 @@
(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
* ===== */
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- util.h 22 Feb 2005 08:18:34 -0000 1.129
+++ util.h 25 Feb 2005 20:46:13 -0000 1.130
@@ -128,6 +128,7 @@
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);