[tor-commits] [tor/master] Use fmt_and_decorate_addr in log messages.

nickm at torproject.org nickm at torproject.org
Thu Oct 11 02:32:44 UTC 2012


commit 34c6ee7e9b62ffb4ef62c7195f6e69db084172df
Author: David Fifield <david at bamsoftware.com>
Date:   Sat Oct 6 20:30:58 2012 -0700

    Use fmt_and_decorate_addr in log messages.
---
 src/or/circuitbuild.c    |   25 ++++++++++++++-----------
 src/or/config.c          |   10 +++++-----
 src/or/connection.c      |   14 ++++++++------
 src/or/connection_edge.c |    2 +-
 src/or/connection_or.c   |    6 ++++--
 src/or/rendservice.c     |    3 ++-
 src/or/transports.c      |   14 +++++++-------
 7 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 56c2c22..740efdb 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1956,7 +1956,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
 
   /* now see if we're already connected to the first OR in 'route' */
   log_debug(LD_CIRC,"Looking for firsthop '%s:%u'",
-            fmt_addr(&firsthop->extend_info->addr),
+            fmt_and_decorate_addr(&firsthop->extend_info->addr),
             firsthop->extend_info->port);
 
   n_conn = connection_or_get_for_extend(firsthop->extend_info->identity_digest,
@@ -2471,7 +2471,7 @@ circuit_extend(cell_t *cell, circuit_t *circ)
 
   if (!n_conn) {
     log_debug(LD_CIRC|LD_OR,"Next router (%s:%d): %s",
-              fmt_addr(&n_addr), (int)n_port, msg?msg:"????");
+              fmt_and_decorate_addr(&n_addr), (int)n_port, msg?msg:"????");
 
     circ->n_hop = extend_info_new(NULL /*nickname*/,
                                     id_digest,
@@ -5319,7 +5319,7 @@ learned_router_identity(const tor_addr_t *addr, uint16_t port,
   if (bridge && tor_digest_is_zero(bridge->identity)) {
     memcpy(bridge->identity, digest, DIGEST_LEN);
     log_notice(LD_DIR, "Learned fingerprint %s for bridge %s:%d",
-               hex_str(digest, DIGEST_LEN), fmt_addr(addr), port);
+               hex_str(digest, DIGEST_LEN), fmt_and_decorate_addr(addr), port);
   }
 }
 
@@ -5365,11 +5365,11 @@ bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
         /* warn the user */
         char *bridge_description_new, *bridge_description_old;
         tor_asprintf(&bridge_description_new, "%s:%u:%s:%s",
-                     fmt_addr(addr), port,
+                     fmt_and_decorate_addr(addr), port,
                      digest ? hex_str(digest, DIGEST_LEN) : "",
                      transport_name ? transport_name : "");
         tor_asprintf(&bridge_description_old, "%s:%u:%s:%s",
-                     fmt_addr(&bridge->addr), bridge->port,
+                     fmt_and_decorate_addr(&bridge->addr), bridge->port,
                      tor_digest_is_zero(bridge->identity) ?
                      "" : hex_str(bridge->identity,DIGEST_LEN),
                      bridge->transport_name ? bridge->transport_name : "");
@@ -5512,7 +5512,7 @@ launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
   if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
     download_status_mark_impossible(&bridge->fetch_status);
     log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
-             safe_str_client(fmt_addr(&bridge->addr)));
+             safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
     return;
   }
 
@@ -5565,7 +5565,7 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
       if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
         download_status_mark_impossible(&bridge->fetch_status);
         log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
-                 safe_str_client(fmt_addr(&bridge->addr)));
+                 safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
         continue;
       }
 
@@ -5583,7 +5583,8 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
       if (ask_bridge_directly &&
           !fascist_firewall_allows_address_or(&bridge->addr, bridge->port)) {
         log_notice(LD_DIR, "Bridge at '%s:%d' isn't reachable by our "
-                   "firewall policy. %s.", fmt_addr(&bridge->addr),
+                   "firewall policy. %s.",
+                   fmt_and_decorate_addr(&bridge->addr),
                    bridge->port,
                    can_use_bridge_authority ?
                      "Asking bridge authority instead" : "Skipping");
@@ -5655,7 +5656,8 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
         log_info(LD_DIR,
                  "Adjusted bridge routerinfo for '%s' to match configured "
                  "address %s:%d.",
-                 ri->nickname, fmt_addr(&ri->ipv6_addr), ri->ipv6_orport);
+                 ri->nickname, fmt_and_decorate_addr(&ri->ipv6_addr),
+                 ri->ipv6_orport);
       } else {
         log_err(LD_BUG, "Address family not supported: %d.",
                 tor_addr_family(&bridge->addr));
@@ -5677,7 +5679,7 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
                  "Will prefer using its %s address (%s:%d).",
                  ri->nickname,
                  tor_addr_family(&ap.addr) == AF_INET6 ? "IPv6" : "IPv4",
-                 fmt_addr(&ap.addr), ap.port);
+                 fmt_and_decorate_addr(&ap.addr), ap.port);
     }
   }
   if (node->rs) {
@@ -5693,7 +5695,8 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
       log_info(LD_DIR,
                "Adjusted bridge routerstatus for '%s' to match "
                "configured address %s:%d.",
-               rs->nickname, fmt_addr(&bridge->addr), rs->or_port);
+               rs->nickname, fmt_and_decorate_addr(&bridge->addr),
+               rs->or_port);
     }
   }
 }
diff --git a/src/or/config.c b/src/or/config.c
index bac2b2e..dc43dec 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3946,7 +3946,7 @@ parse_bridge_line(const char *line, int validate_only)
 
   if (!validate_only) {
     log_debug(LD_DIR, "Bridge at %s:%d (transport: %s) (%s)",
-              fmt_addr(&addr), (int)port,
+              fmt_and_decorate_addr(&addr), (int)port,
               transport_name ? transport_name : "no transport",
               fingerprint ? fingerprint : "no key listed");
     bridge_add_from_config(&addr, port,
@@ -4080,7 +4080,7 @@ parse_client_transport_line(const char *line, int validate_only)
                                 socks_ver);
 
       log_info(LD_DIR, "Transport '%s' found at %s:%d",
-               transports, fmt_addr(&addr), (int)port);
+               transports, fmt_and_decorate_addr(&addr), (int)port);
     }
   }
 
@@ -4200,7 +4200,7 @@ parse_server_transport_line(const char *line, int validate_only)
 
     if (!validate_only) {
       log_info(LD_DIR, "Server transport '%s' at %s:%d.",
-               transports, fmt_addr(&addr), (int)port);
+               transports, fmt_and_decorate_addr(&addr), (int)port);
     }
   }
 
@@ -4376,13 +4376,13 @@ warn_nonlocal_client_ports(const smartlist_t *ports, const char *portname)
                "Other people on the Internet might find your computer and "
                "use it as an open proxy. Please don't allow this unless you "
                "have a good reason.",
-               fmt_addr(&port->addr), port->port, portname);
+               fmt_and_decorate_addr(&port->addr), port->port, portname);
     } else if (!tor_addr_is_loopback(&port->addr)) {
       log_notice(LD_CONFIG, "You configured a non-loopback address '%s:%d' "
                  "for %sPort. This allows everybody on your local network to "
                  "use your machine as a proxy. Make sure this is what you "
                  "wanted.",
-                 fmt_addr(&port->addr), port->port, portname);
+                 fmt_and_decorate_addr(&port->addr), port->port, portname);
     }
   } SMARTLIST_FOREACH_END(port);
 }
diff --git a/src/or/connection.c b/src/or/connection.c
index d64c676..0cf375b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -905,7 +905,8 @@ connection_listener_new(const struct sockaddr *listensockaddr,
     tor_addr_from_sockaddr(&addr, listensockaddr, &usePort);
 
     log_notice(LD_NET, "Opening %s on %s:%d",
-               conn_type_to_string(type), fmt_addr(&addr), usePort);
+               conn_type_to_string(type), fmt_and_decorate_addr(&addr),
+               usePort);
 
     s = tor_open_socket(tor_addr_family(&addr),
                         is_tcp ? SOCK_STREAM : SOCK_DGRAM,
@@ -1220,7 +1221,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
       if (socks_policy_permits_address(&addr) == 0) {
         log_notice(LD_APP,
                    "Denying socks connection from untrusted address %s.",
-                   fmt_addr(&addr));
+                   fmt_and_decorate_addr(&addr));
         tor_close_socket(news);
         return 0;
       }
@@ -1229,7 +1230,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
       /* check dirpolicy to see if we should accept it */
       if (dir_policy_permits_address(&addr) == 0) {
         log_notice(LD_DIRSERV,"Denying dir connection from address %s.",
-                   fmt_addr(&addr));
+                   fmt_and_decorate_addr(&addr));
         tor_close_socket(news);
         return 0;
       }
@@ -1395,12 +1396,12 @@ connection_connect(connection_t *conn, const char *address,
       if (ext_addr_len == 0) {
         log_warn(LD_NET,
                  "Error converting OutboundBindAddress %s into sockaddr. "
-                 "Ignoring.", fmt_addr(ext_addr));
+                 "Ignoring.", fmt_and_decorate_addr(ext_addr));
       } else {
         if (bind(s, (struct sockaddr *) &ext_addr_sa, ext_addr_len) < 0) {
           *socket_error = tor_socket_errno(s);
           log_warn(LD_NET,"Error binding network socket to %s: %s",
-                   fmt_addr(ext_addr),
+                   fmt_and_decorate_addr(ext_addr),
                    tor_socket_strerror(*socket_error));
           tor_close_socket(s);
           return -1;
@@ -4236,7 +4237,8 @@ log_failed_proxy_connection(connection_t *conn)
   log_warn(LD_NET,
            "The connection to the %s proxy server at %s:%u just failed. "
            "Make sure that the proxy server is up and running.",
-           proxy_type_to_string(get_proxy_type()), fmt_addr(&proxy_addr),
+           proxy_type_to_string(get_proxy_type()),
+           fmt_and_decorate_addr(&proxy_addr),
            proxy_port);
 }
 
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index ade3b48..2cdb3fb 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -406,7 +406,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
 
   log_info(LD_EXIT,"Exit connection to %s:%u (%s) established.",
            escaped_safe_str(conn->address), conn->port,
-           safe_str(fmt_addr(&conn->addr)));
+           safe_str(fmt_and_decorate_addr(&conn->addr)));
 
   rep_hist_note_exit_stream_opened(conn->port);
 
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index dbd8757..04cbf40 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1089,12 +1089,14 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
                "transport proxy supporting '%s'. This can happen if you "
                "haven't provided a ClientTransportPlugin line, or if "
                "your pluggable transport proxy stopped running.",
-               fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port,
+               fmt_and_decorate_addr(&TO_CONN(conn)->addr),
+               TO_CONN(conn)->port,
                transport_name, transport_name);
     } else {
       log_warn(LD_GENERAL, "Tried to connect to '%s:%u' through a proxy, but "
                "the proxy address could not be found.",
-               fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port);
+               fmt_and_decorate_addr(&TO_CONN(conn)->addr),
+               TO_CONN(conn)->port);
     }
 
     connection_free(TO_CONN(conn));
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 0fa04b6..6cae4bc 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -273,7 +273,8 @@ rend_add_service(rend_service_t *service)
     for (i = 0; i < smartlist_len(service->ports); ++i) {
       p = smartlist_get(service->ports, i);
       log_debug(LD_REND,"Service maps port %d to %s:%d",
-                p->virtual_port, fmt_addr(&p->real_addr), p->real_port);
+                p->virtual_port, fmt_and_decorate_addr(&p->real_addr),
+                p->real_port);
     }
   }
 }
diff --git a/src/or/transports.c b/src/or/transports.c
index f9cd125..cf3ef39 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -270,13 +270,13 @@ transport_resolve_conflicts(const transport_t *t)
       t_tmp->marked_for_removal = 0;
       return 1;
     } else { /* same name but different addrport */
-      char *new_transport_addr = tor_strdup(fmt_addr(&t->addr));
+      char *new_transport_addr = tor_strdup(fmt_and_decorate_addr(&t->addr));
       if (t_tmp->marked_for_removal) { /* marked for removal */
         log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
                    "but there was already a transport marked for deletion at "
                    "'%s:%u'. We deleted the old transport and registered the "
                    "new one.", t->name, new_transport_addr, t->port,
-                   fmt_addr(&t_tmp->addr), t_tmp->port);
+                   fmt_and_decorate_addr(&t_tmp->addr), t_tmp->port);
         smartlist_remove(transport_list, t_tmp);
         transport_free(t_tmp);
         tor_free(new_transport_addr);
@@ -284,7 +284,7 @@ transport_resolve_conflicts(const transport_t *t)
         log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
                    "but the same transport already exists at '%s:%u'. "
                    "Skipping.", t->name, new_transport_addr, t->port,
-                   fmt_addr(&t_tmp->addr), t_tmp->port);
+                   fmt_and_decorate_addr(&t_tmp->addr), t_tmp->port);
         tor_free(new_transport_addr);
         return -1;
       }
@@ -333,17 +333,17 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
   case -1:
   default:
     log_notice(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
-               t->name, fmt_addr(&t->addr), t->port);
+               t->name, fmt_and_decorate_addr(&t->addr), t->port);
     transport_free(t);
     return -1;
   case 1:
     log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
-             t->name, fmt_addr(&t->addr), t->port);
+             t->name, fmt_and_decorate_addr(&t->addr), t->port);
      transport_free(t); /* falling */
      return 0;
   case 0:
     log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
-             t->name, fmt_addr(&t->addr), t->port);
+             t->name, fmt_and_decorate_addr(&t->addr), t->port);
     return 0;
   }
 }
@@ -645,7 +645,7 @@ register_server_proxy(const managed_proxy_t *mp)
   SMARTLIST_FOREACH_BEGIN(mp->transports, transport_t *, t) {
     save_transport_to_state(t->name, &t->addr, t->port);
     log_notice(LD_GENERAL, "Registered server transport '%s' at '%s:%d'",
-               t->name, fmt_addr(&t->addr), (int)t->port);
+               t->name, fmt_and_decorate_addr(&t->addr), (int)t->port);
   } SMARTLIST_FOREACH_END(t);
 }
 





More information about the tor-commits mailing list