[tor-commits] [tor/master] Never emit the "opt" prefix in any directory stuff

nickm at torproject.org nickm at torproject.org
Fri Aug 17 20:05:51 UTC 2012


commit e13e9c40c829d15fb71310b0638fff859b85580a
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jun 28 15:47:07 2012 -0400

    Never emit the "opt" prefix in any directory stuff
    
    Fix for bug 5124.
---
 changes/bug5124     |    4 ++++
 src/or/dirserv.c    |    2 +-
 src/or/policies.c   |    3 +--
 src/or/rephist.c    |    2 +-
 src/or/router.c     |   14 +++++++-------
 src/test/test_dir.c |    6 +++---
 6 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/changes/bug5124 b/changes/bug5124
new file mode 100644
index 0000000..5999f7e
--- /dev/null
+++ b/changes/bug5124
@@ -0,0 +1,4 @@
+  o Removed code:
+    - No longer include the "opt" prefix when generating routerinfos
+      or v2 directories: it has been needless since Tor 0.1.2. Closes
+      ticket 5124.
\ No newline at end of file
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index bfebbcd..d29c11d 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2114,7 +2114,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
   /* length of "opt v \n" */
 #define V_LINE_OVERHEAD 7
   if (version && strlen(version) < MAX_V_LINE_LEN - V_LINE_OVERHEAD) {
-    if (tor_snprintf(cp, buf_len - (cp-buf), "opt v %s\n", version)<0) {
+    if (tor_snprintf(cp, buf_len - (cp-buf), "v %s\n", version)<0) {
       log_warn(LD_BUG, "Unable to print router version.");
       return -1;
     }
diff --git a/src/or/policies.c b/src/or/policies.c
index b2b962d..201ed04 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1006,8 +1006,7 @@ policy_write_item(char *buf, size_t buflen, addr_policy_t *policy,
   else
     addrpart = addrbuf;
 
-  result = tor_snprintf(buf, buflen, "%s%s%s %s",
-                        (is_ip6&&format_for_desc)?"opt ":"",
+  result = tor_snprintf(buf, buflen, "%s%s %s",
                         is_accept ? "accept" : "reject",
                         (is_ip6&&format_for_desc)?"6":"",
                         addrpart);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index fa02f98..1c5b511 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1531,7 +1531,7 @@ rep_hist_get_bandwidth_lines(void)
   const char *desc = NULL;
   size_t len;
 
-  /* opt [dirreq-](read|write)-history yyyy-mm-dd HH:MM:SS (n s) n,n,n... */
+  /* [dirreq-](read|write)-history yyyy-mm-dd HH:MM:SS (n s) n,n,n... */
 /* The n,n,n part above. Largest representation of a uint64_t is 20 chars
  * long, plus the comma. */
 #define MAX_HIST_VALUE_LEN 21*NUM_TOTALS
diff --git a/src/or/router.c b/src/or/router.c
index 352c456..a766dfb 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2053,9 +2053,9 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
                     "router %s %s %d 0 %d\n"
                     "%s"
                     "platform %s\n"
-                    "opt protocols Link 1 2 Circuit 1\n"
+                    "protocols Link 1 2 Circuit 1\n"
                     "published %s\n"
-                    "opt fingerprint %s\n"
+                    "fingerprint %s\n"
                     "uptime %ld\n"
                     "bandwidth %d %d %d\n"
                     "%s%s%s%s"
@@ -2074,15 +2074,15 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
     (int) router->bandwidthrate,
     (int) router->bandwidthburst,
     (int) router->bandwidthcapacity,
-    has_extra_info_digest ? "opt extra-info-digest " : "",
+    has_extra_info_digest ? "extra-info-digest " : "",
     has_extra_info_digest ? extra_info_digest : "",
     has_extra_info_digest ? "\n" : "",
-    options->DownloadExtraInfo ? "opt caches-extra-info\n" : "",
+    options->DownloadExtraInfo ? "caches-extra-info\n" : "",
     onion_pkey, identity_pkey,
     family_line,
-    we_are_hibernating() ? "opt hibernating 1\n" : "",
-    options->HidServDirectoryV2 ? "opt hidden-service-dir\n" : "",
-    options->AllowSingleHopExits ? "opt allow-single-hop-exits\n" : "");
+    we_are_hibernating() ? "hibernating 1\n" : "",
+    options->HidServDirectoryV2 ? "hidden-service-dir\n" : "",
+    options->AllowSingleHopExits ? "allow-single-hop-exits\n" : "");
 
   tor_free(family_line);
   tor_free(onion_pkey);
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 83c6120..84705d0 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -147,9 +147,9 @@ test_dir_formats(void)
           "platform Tor "VERSION" on ", sizeof(buf2));
   strlcat(buf2, get_uname(), sizeof(buf2));
   strlcat(buf2, "\n"
-          "opt protocols Link 1 2 Circuit 1\n"
+          "protocols Link 1 2 Circuit 1\n"
           "published 1970-01-01 00:00:00\n"
-          "opt fingerprint ", sizeof(buf2));
+          "fingerprint ", sizeof(buf2));
   test_assert(!crypto_pk_get_fingerprint(pk2, fingerprint, 1));
   strlcat(buf2, fingerprint, sizeof(buf2));
   strlcat(buf2, "\nuptime 0\n"
@@ -161,7 +161,7 @@ test_dir_formats(void)
   strlcat(buf2, pk1_str, sizeof(buf2));
   strlcat(buf2, "signing-key\n", sizeof(buf2));
   strlcat(buf2, pk2_str, sizeof(buf2));
-  strlcat(buf2, "opt hidden-service-dir\n", sizeof(buf2));
+  strlcat(buf2, "hidden-service-dir\n", sizeof(buf2));
   strlcat(buf2, "reject *:*\nrouter-signature\n", sizeof(buf2));
   buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
                              * twice */





More information about the tor-commits mailing list