From: Guus Sliepen Date: Mon, 14 Aug 2017 20:29:06 +0000 (+0200) Subject: Get rid of ->hostname. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=ea294dac41365a08a77b64c62c0ba630292d7a07;p=meshlink Get rid of ->hostname. This takes up memory and is only used for logging. --- diff --git a/src/connection.c b/src/connection.c index cbe7a9d6..dc4dad2d 100644 --- a/src/connection.c +++ b/src/connection.c @@ -32,7 +32,6 @@ void init_connections(meshlink_handle_t *mesh) { mesh->connections = list_alloc((list_action_t) free_connection); mesh->everyone = new_connection(); mesh->everyone->name = xstrdup("mesh->everyone"); - mesh->everyone->hostname = xstrdup("BROADCAST"); } void exit_connections(meshlink_handle_t *mesh) { @@ -66,7 +65,6 @@ void free_connection(connection_t *c) { closesocket(c->socket); free(c->name); - free(c->hostname); if(c->config_tree) exit_configuration(&c->config_tree); diff --git a/src/graph.c b/src/graph.c index caf33f5e..2b76194f 100644 --- a/src/graph.c +++ b/src/graph.c @@ -201,13 +201,10 @@ static void check_reachability(meshlink_handle_t *mesh) { n->status.reachable = !n->status.reachable; n->last_state_change = mesh->loop.now.tv_sec; - if(n->status.reachable) { - logger(mesh, MESHLINK_DEBUG, "Node %s (%s) became reachable", - n->name, n->hostname); - } else { - logger(mesh, MESHLINK_DEBUG, "Node %s (%s) became unreachable", - n->name, n->hostname); - } + if(n->status.reachable) + logger(mesh, MESHLINK_DEBUG, "Node %s became reachable", n->name); + else + logger(mesh, MESHLINK_DEBUG, "Node %s became unreachable", n->name); /* TODO: only clear status.validkey if node is unreachable? */ diff --git a/src/meta.c b/src/meta.c index 3ae0d697..2d308403 100644 --- a/src/meta.c +++ b/src/meta.c @@ -49,8 +49,7 @@ bool send_meta(meshlink_handle_t *mesh, connection_t *c, const char *buffer, int abort(); } - logger(mesh, MESHLINK_DEBUG, "Sending %d bytes of metadata to %s (%s)", length, - c->name, c->hostname); + logger(mesh, MESHLINK_DEBUG, "Sending %d bytes of metadata to %s", length, c->name); if(c->allow_request == ID) { buffer_add(&c->outbuf, buffer, length); @@ -115,13 +114,11 @@ bool receive_meta(meshlink_handle_t *mesh, connection_t *c) { if(inlen <= 0) { if(!inlen || !errno) { - logger(mesh, MESHLINK_INFO, "Connection closed by %s (%s)", - c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Connection closed by %s", c->name); } else if(sockwouldblock(sockerrno)) return true; else - logger(mesh, MESHLINK_ERROR, "Metadata socket read error for %s (%s): %s", - c->name, c->hostname, sockstrerror(sockerrno)); + logger(mesh, MESHLINK_ERROR, "Metadata socket read error for %s: %s", c->name, sockstrerror(sockerrno)); return false; } @@ -143,7 +140,7 @@ bool receive_meta(meshlink_handle_t *mesh, connection_t *c) { } if(c->inbuf.len >= sizeof(inbuf)) { - logger(mesh, MESHLINK_ERROR, "Input buffer full for %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Input buffer full for %s", c->name); return false; } else return true; diff --git a/src/net.c b/src/net.c index 45a9abbf..8e5c2c18 100644 --- a/src/net.c +++ b/src/net.c @@ -47,7 +47,7 @@ static const int min(int a, int b) { - Check if we need to retry making an outgoing connection */ void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report) { - logger(mesh, MESHLINK_INFO, "Closing connection with %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Closing connection with %s", c->name); c->status.active = false; @@ -113,7 +113,7 @@ static void timeout_handler(event_loop_t *loop, void *data) { if(c->last_ping_time + mesh->pingtimeout <= mesh->loop.now.tv_sec) { if(c->status.active) { if(c->status.pinged) - logger(mesh, MESHLINK_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)mesh->loop.now.tv_sec - c->last_ping_time); + logger(mesh, MESHLINK_INFO, "%s didn't respond to PING in %ld seconds", c->name, (long)mesh->loop.now.tv_sec - c->last_ping_time); else if(c->last_ping_time + mesh->pinginterval <= mesh->loop.now.tv_sec) { send_ping(mesh, c); continue; @@ -121,9 +121,9 @@ static void timeout_handler(event_loop_t *loop, void *data) { continue; } else { if(c->status.connecting) - logger(mesh, MESHLINK_WARNING, "Timeout while connecting to %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Timeout while connecting to %s", c->name); else - logger(mesh, MESHLINK_WARNING, "Timeout from %s (%s) during authentication", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Timeout from %s during authentication", c->name); } terminate_connection(mesh, c, c->status.active); } diff --git a/src/net_packet.c b/src/net_packet.c index 3eea0517..0ab5b7fa 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -66,7 +66,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { n->mtuprobes++; if(!n->status.reachable || !n->status.validkey) { - logger(mesh, MESHLINK_INFO, "Trying to send MTU probe to unreachable or rekeying node %s (%s)", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "Trying to send MTU probe to unreachable or rekeying node %s", n->name); n->mtuprobes = 0; return; } @@ -78,7 +78,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { goto end; } - logger(mesh, MESHLINK_INFO, "%s (%s) did not respond to UDP ping, restarting PMTU discovery", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "%s did not respond to UDP ping, restarting PMTU discovery", n->name); n->status.udp_confirmed = false; n->mtuprobes = 1; n->minmtu = 0; @@ -86,7 +86,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { } if(n->mtuprobes >= 10 && n->mtuprobes < 32 && !n->minmtu) { - logger(mesh, MESHLINK_INFO, "No response to MTU probes from %s (%s)", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "No response to MTU probes from %s", n->name); n->mtuprobes = 31; } @@ -96,7 +96,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { else n->maxmtu = n->minmtu; n->mtu = n->minmtu; - logger(mesh, MESHLINK_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes); + logger(mesh, MESHLINK_INFO, "Fixing MTU of %s to %d after %d probes", n->name, n->mtu, n->mtuprobes); n->mtuprobes = 31; } @@ -128,7 +128,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { packet.len = len; n->status.broadcast = i >= 4 && n->mtuprobes <= 10 && n->prevedge; - logger(mesh, MESHLINK_DEBUG, "Sending MTU probe length %d to %s (%s)", len, n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Sending MTU probe length %d to %s", len, n->name); send_udppacket(mesh, n, &packet); } @@ -149,7 +149,7 @@ void send_mtu_probe(meshlink_handle_t *mesh, node_t *n) { } static void mtu_probe_h(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *packet, uint16_t len) { - logger(mesh, MESHLINK_DEBUG, "Got MTU probe length %d from %s (%s)", packet->len, n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Got MTU probe length %d from %s", packet->len, n->name); if(!packet->data[0]) { /* It's a probe request, send back a reply */ @@ -174,7 +174,7 @@ static void mtu_probe_h(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *packet if(n->mtuprobes > 30) { if(len == n->maxmtu + 8) { - logger(mesh, MESHLINK_INFO, "Increase in PMTU to %s (%s) detected, restarting PMTU discovery", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "Increase in PMTU to %s detected, restarting PMTU discovery", n->name); n->maxmtu = MTU; n->mtuprobes = 10; return; @@ -206,8 +206,7 @@ static uint16_t uncompress_packet(uint8_t *dest, const uint8_t *source, uint16_t /* VPN packet I/O */ static void receive_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *packet) { - logger(mesh, MESHLINK_DEBUG, "Received packet of %d bytes from %s (%s)", - packet->len, n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Received packet of %d bytes from %s", packet->len, n->name); if(n->status.blacklisted) logger(mesh, MESHLINK_WARNING, "Dropping packet from blacklisted node %s", n->name); @@ -226,10 +225,10 @@ static bool try_mac(meshlink_handle_t *mesh, node_t *n, const vpn_packet_t *inpk static void receive_udppacket(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *inpkt) { if(!n->sptps.state) { if(!n->status.waitingforkey) { - logger(mesh, MESHLINK_DEBUG, "Got packet from %s (%s) but we haven't exchanged keys yet", n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Got packet from %s but we haven't exchanged keys yet", n->name); send_req_key(mesh, n); } else - logger(mesh, MESHLINK_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Got packet from %s but he hasn't got our key yet", n->name); return; } sptps_receive_data(&n->sptps, inpkt->data, inpkt->len); @@ -250,7 +249,7 @@ void receive_tcppacket(meshlink_handle_t *mesh, connection_t *c, const char *buf static void send_sptps_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *origpkt) { if(!n->status.validkey) { - logger(mesh, MESHLINK_INFO, "No valid key known yet for %s (%s)", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "No valid key known yet for %s", n->name); if(!n->status.waitingforkey) send_req_key(mesh, n); else if(n->last_req_key + 10 < mesh->loop.now.tv_sec) { @@ -275,7 +274,7 @@ static void send_sptps_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t * if(n->outcompression) { int len = compress_packet(outpkt.data, origpkt->data, origpkt->len, n->outcompression); if(len < 0) - logger(mesh, MESHLINK_ERROR, "Error while compressing packet to %s (%s)", n->name, n->hostname); + logger(mesh, MESHLINK_ERROR, "Error while compressing packet to %s", n->name); else if(len < origpkt->len) { outpkt.len = len; origpkt = &outpkt; @@ -377,7 +376,7 @@ static void choose_broadcast_address(meshlink_handle_t *mesh, const node_t *n, c static void send_udppacket(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *origpkt) { if(!n->status.reachable) { - logger(mesh, MESHLINK_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname); + logger(mesh, MESHLINK_INFO, "Trying to send UDP packet to unreachable node %s", n->name); return; } @@ -419,7 +418,7 @@ bool send_sptps_data(void *handle, uint8_t type, const void *data, size_t len) { if(to->mtu >= len) to->mtu = len - 1; } else { - logger(mesh, MESHLINK_WARNING, "Error sending UDP SPTPS packet to %s (%s): %s", to->name, to->hostname, sockstrerror(sockerrno)); + logger(mesh, MESHLINK_WARNING, "Error sending UDP SPTPS packet to %s: %s", to->name, sockstrerror(sockerrno)); return false; } } @@ -433,7 +432,7 @@ bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t if(type == SPTPS_HANDSHAKE) { if(!from->status.validkey) { - logger(mesh, MESHLINK_INFO, "SPTPS key exchange with %s (%s) succesful", from->name, from->hostname); + logger(mesh, MESHLINK_INFO, "SPTPS key exchange with %s succesful", from->name); from->status.validkey = true; from->status.waitingforkey = false; if(from->utcp) @@ -443,7 +442,7 @@ bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t } if(len > MTU) { - logger(mesh, MESHLINK_ERROR, "Packet from %s (%s) larger than maximum supported size (%d > %d)", from->name, from->hostname, len, MTU); + logger(mesh, MESHLINK_ERROR, "Packet from %s larger than maximum supported size (%d > %d)", from->name, len, MTU); return false; } @@ -459,7 +458,7 @@ bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t inpkt.probe = false; if(type & ~(PKT_COMPRESSED)) { - logger(mesh, MESHLINK_ERROR, "Unexpected SPTPS record type %d len %d from %s (%s)", type, len, from->name, from->hostname); + logger(mesh, MESHLINK_ERROR, "Unexpected SPTPS record type %d len %d from %s", type, len, from->name); return false; } @@ -491,12 +490,10 @@ void send_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *packet) { return; } - logger(mesh, MESHLINK_DEBUG, "Sending packet of %d bytes to %s (%s)", - packet->len, n->name, n->hostname); + logger(mesh, MESHLINK_DEBUG, "Sending packet of %d bytes to %s", packet->len, n->name); if(!n->status.reachable) { - logger(mesh, MESHLINK_WARNING, "Node %s (%s) is not reachable", - n->name, n->hostname); + logger(mesh, MESHLINK_WARNING, "Node %s is not reachable", n->name); return; } @@ -514,8 +511,7 @@ void broadcast_packet(meshlink_handle_t *mesh, const node_t *from, vpn_packet_t if(from != mesh->self) send_packet(mesh, mesh->self, packet); - logger(mesh, MESHLINK_INFO, "Broadcasting packet of %d bytes from %s (%s)", - packet->len, from->name, from->hostname); + logger(mesh, MESHLINK_INFO, "Broadcasting packet of %d bytes from %s", packet->len, from->name); for list_each(connection_t, c, mesh->connections) if(c->status.active && c->status.mst && c != from->nexthop->connection) diff --git a/src/net_setup.c b/src/net_setup.c index acdea368..45e20d00 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -406,9 +406,6 @@ bool setup_myself(meshlink_handle_t *mesh) { return false; } - xasprintf(&mesh->self->hostname, "MYSELF port %s", mesh->myport); - mesh->self->connection->hostname = xstrdup(mesh->self->hostname); - /* Done. */ mesh->last_config_check = mesh->loop.now.tv_sec; diff --git a/src/net_socket.c b/src/net_socket.c index dddd866a..a74db196 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -51,12 +51,12 @@ static void configure_tcp(connection_t *c) { int flags = fcntl(c->socket, F_GETFL); if(fcntl(c->socket, F_SETFL, flags | O_NONBLOCK) < 0) - logger(c->mesh, MESHLINK_ERROR, "fcntl for %s: %s", c->hostname, strerror(errno)); + logger(c->mesh, MESHLINK_ERROR, "System call `%s' failed: %s", "fcntl", strerror(errno)); #elif defined(WIN32) unsigned long arg = 1; if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) - logger(c->mesh, MESHLINK_ERROR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno)); + logger(c->mesh, MESHLINK_ERROR, "System call `%s' failed: %s", "ioctlsocket", sockstrerror(sockerrno)); #endif #if defined(SOL_TCP) && defined(TCP_NODELAY) @@ -251,7 +251,7 @@ void retry_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) { } void finish_connecting(meshlink_handle_t *mesh, connection_t *c) { - logger(mesh, MESHLINK_INFO, "Connected to %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Connected to %s", c->name); c->last_ping_time = mesh->loop.now.tv_sec; c->status.connecting = false; @@ -312,12 +312,12 @@ static void handle_meta_write(meshlink_handle_t *mesh, connection_t *c) { ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, MSG_NOSIGNAL); if(outlen <= 0) { if(!errno || errno == EPIPE) - logger(mesh, MESHLINK_INFO, "Connection closed by %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Connection closed by %s", c->name); else if(sockwouldblock(sockerrno)) { - logger(mesh, MESHLINK_DEBUG, "Sending %d bytes to %s (%s) would block", c->outbuf.len - c->outbuf.offset, c->name, c->hostname); + logger(mesh, MESHLINK_DEBUG, "Sending %d bytes to %s would block", c->outbuf.len - c->outbuf.offset, c->name); return; } else - logger(mesh, MESHLINK_ERROR, "Could not send %d bytes of data to %s (%s): %s", c->outbuf.len - c->outbuf.offset, c->name, c->hostname, strerror(errno)); + logger(mesh, MESHLINK_ERROR, "Could not send %d bytes of data to %s: %s", c->outbuf.len - c->outbuf.offset, c->name, strerror(errno)); terminate_connection(mesh, c, c->status.active); return; @@ -342,7 +342,7 @@ static void handle_meta_io(event_loop_t *loop, void *data, int flags) { if(!result) finish_connecting(mesh, c); else { - logger(mesh, MESHLINK_DEBUG, "Error while connecting to %s (%s): %s", c->name, c->hostname, sockstrerror(result)); + logger(mesh, MESHLINK_DEBUG, "Error while connecting to %s: %s", c->name, sockstrerror(result)); terminate_connection(mesh, c, false); return; } @@ -450,9 +450,9 @@ begin: memcpy(&c->address, outgoing->aip->ai_addr, outgoing->aip->ai_addrlen); outgoing->aip = outgoing->aip->ai_next; - c->hostname = sockaddr2hostname(&c->address); + char *hostname = sockaddr2hostname(&c->address); - logger(mesh, MESHLINK_INFO, "Trying to connect to %s (%s)", outgoing->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Trying to connect to %s at %s", outgoing->name, hostname); if(!mesh->proxytype) { c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); @@ -463,6 +463,7 @@ begin: proxyai = str2addrinfo(mesh->proxyhost, mesh->proxyport, SOCK_STREAM); if(!proxyai) { free_connection(c); + free(hostname); goto begin; } logger(mesh, MESHLINK_INFO, "Using proxy at %s port %s", mesh->proxyhost, mesh->proxyport); @@ -471,11 +472,14 @@ begin: } if(c->socket == -1) { - logger(mesh, MESHLINK_ERROR, "Creating socket for %s failed: %s", c->hostname, sockstrerror(sockerrno)); + logger(mesh, MESHLINK_ERROR, "Creating socket for %s at %s failed: %s", c->name, c->hostname, sockstrerror(sockerrno)); free_connection(c); + free(hostname); goto begin; } + free(hostname); + #ifdef FD_CLOEXEC fcntl(c->socket, F_SETFD, FD_CLOEXEC); #endif @@ -502,7 +506,7 @@ begin: } if(result == -1 && !sockinprogress(sockerrno)) { - logger(mesh, MESHLINK_ERROR, "Could not connect to %s (%s): %s", outgoing->name, c->hostname, sockstrerror(sockerrno)); + logger(mesh, MESHLINK_ERROR, "Could not connect to %s: %s", outgoing->name, sockstrerror(sockerrno)); free_connection(c); goto begin; @@ -637,11 +641,12 @@ void handle_new_meta_connection(event_loop_t *loop, void *data, int flags) { c->outcompression = mesh->self->connection->outcompression; c->address = sa; - c->hostname = sockaddr2hostname(&sa); c->socket = fd; c->last_ping_time = mesh->loop.now.tv_sec; + char *hostname = sockaddr2hostname(&sa); logger(mesh, MESHLINK_INFO, "Connection from %s", c->hostname); + free(hostname); io_add(&mesh->loop, &c->io, handle_meta_io, c, c->socket, IO_READ); diff --git a/src/node.c b/src/node.c index af02fe27..164fdb15 100644 --- a/src/node.c +++ b/src/node.c @@ -72,7 +72,6 @@ void free_node(node_t *n) { if(n->mtutimeout.cb) abort(); - free(n->hostname); free(n->name); utcp_exit(n->utcp); @@ -124,11 +123,15 @@ void update_node_udp(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) { break; } } + hash_insert(mesh->node_udp_cache, sa, n); - free(n->hostname); - n->hostname = sockaddr2hostname(&n->address); meshlink_hint_address(mesh, (meshlink_node_t *)n, &sa->sa); - logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, n->hostname); + + if(mesh->log_level >= MESHLINK_DEBUG) { + char *hostname = sockaddr2hostname(&n->address); + logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, hostname); + free(hostname); + } } } diff --git a/src/node.h b/src/node.h index 4e865dfb..ba5b1d48 100644 --- a/src/node.h +++ b/src/node.h @@ -51,7 +51,6 @@ typedef struct node_t { int sock; /* Socket to use for outgoing UDP packets */ sockaddr_t address; /* his real (internet) ip to send UDP packets to */ - char *hostname; /* the hostname of its real ip */ node_status_t status; time_t last_state_change; diff --git a/src/protocol.c b/src/protocol.c index 61a01b57..fb0aa9ca 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -77,12 +77,11 @@ bool send_request(meshlink_handle_t *mesh, connection_t *c, const char *format, va_end(args); if(len < 0 || len > MAXBUFSIZE - 1) { - logger(mesh, MESHLINK_ERROR, "Output buffer overflow while sending request to %s (%s)", - c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Output buffer overflow while sending request to %s", c->name); return false; } - logger(mesh, MESHLINK_DEBUG, "Sending %s to %s (%s): %s", request_name[atoi(request)], c->name, c->hostname, request); + logger(mesh, MESHLINK_DEBUG, "Sending %s to %s: %s", request_name[atoi(request)], c->name, request); request[len++] = '\n'; @@ -94,7 +93,7 @@ bool send_request(meshlink_handle_t *mesh, connection_t *c, const char *format, } void forward_request(meshlink_handle_t *mesh, connection_t *from, const char *request) { - logger(mesh, MESHLINK_DEBUG, "Forwarding %s from %s (%s): %s", request_name[atoi(request)], from->name, from->hostname, request); + logger(mesh, MESHLINK_DEBUG, "Forwarding %s from %s: %s", request_name[atoi(request)], from->name, request); // Create a temporary newline-terminated copy of the request int len = strlen(request); @@ -123,24 +122,24 @@ bool receive_request(meshlink_handle_t *mesh, connection_t *c, const char *reque if(reqno || *request == '0') { if((reqno < 0) || (reqno >= LAST) || !request_handlers[reqno]) { - logger(mesh, MESHLINK_DEBUG, "Unknown request from %s (%s): %s", c->name, c->hostname, request); + logger(mesh, MESHLINK_DEBUG, "Unknown request from %s: %s", c->name, request); return false; } else - logger(mesh, MESHLINK_DEBUG, "Got %s from %s (%s): %s", request_name[reqno], c->name, c->hostname, request); + logger(mesh, MESHLINK_DEBUG, "Got %s from %s: %s", request_name[reqno], c->name, request); if((c->allow_request != ALL) && (c->allow_request != reqno)) { - logger(mesh, MESHLINK_ERROR, "Unauthorized request from %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Unauthorized request from %s", c->name); return false; } if(!request_handlers[reqno](mesh, c, request)) { /* Something went wrong. Probably scriptkiddies. Terminate. */ - logger(mesh, MESHLINK_ERROR, "Error while processing %s from %s (%s)", request_name[reqno], c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Error while processing %s from %s", request_name[reqno], c->name); return false; } } else { - logger(mesh, MESHLINK_ERROR, "Bogus data received from %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Bogus data received from %s", c->name); return false; } diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 829e9b31..ca042e12 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -139,7 +139,7 @@ bool send_id(meshlink_handle_t *mesh, connection_t *c) { static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const void *data, uint16_t len) { if(strchr(data, '\n')) { - logger(mesh, MESHLINK_ERROR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Received invalid key from invited node %s!\n", c->name); return false; } @@ -147,7 +147,7 @@ static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const char filename[PATH_MAX]; snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, c->name); if(!access(filename, F_OK)) { - logger(mesh, MESHLINK_ERROR, "Host config file for %s (%s) already exists!\n", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Host config file for %s already exists!\n", c->name); return false; } @@ -160,7 +160,7 @@ static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const fprintf(f, "ECDSAPublicKey = %s\n", (const char *)data); fclose(f); - logger(mesh, MESHLINK_INFO, "Key succesfully received from %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Key succesfully received from %s", c->name); //TODO: callback to application to inform of an accepted invitation @@ -202,7 +202,7 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat // Atomically rename the invitation file if(rename(filename, usedname)) { if(errno == ENOENT) - logger(mesh, MESHLINK_ERROR, "Peer %s tried to use non-existing invitation %s\n", c->hostname, cookie); + logger(mesh, MESHLINK_ERROR, "Peer %s tried to use non-existing invitation %s\n", c->name, cookie); else logger(mesh, MESHLINK_ERROR, "Error trying to rename invitation %s\n", cookie); return false; @@ -250,7 +250,7 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat c->status.invitation_used = true; - logger(mesh, MESHLINK_INFO, "Invitation %s succesfully sent to %s (%s)", cookie, c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Invitation %s succesfully sent to %s", cookie, c->name); return true; } @@ -258,8 +258,7 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { char name[MAX_STRING_SIZE]; if(sscanf(request, "%*d " MAX_STRING " %d.%d", name, &c->protocol_major, &c->protocol_minor) < 2) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ID", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ID", c->name); return false; } @@ -267,13 +266,13 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(name[0] == '?') { if(!mesh->invitation_key) { - logger(mesh, MESHLINK_ERROR, "Got invitation from %s but we don't have an invitation key", c->hostname); + logger(mesh, MESHLINK_ERROR, "Got invitation from %s but we don't have an invitation key", c->name); return false; } c->ecdsa = ecdsa_set_base64_public_key(name + 1); if(!c->ecdsa) { - logger(mesh, MESHLINK_ERROR, "Got bad invitation from %s", c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad invitation from %s", c->name); return false; } @@ -294,8 +293,7 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Check if identity is a valid name */ if(!check_id(name)) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ID", c->name, - c->hostname, "invalid name"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ID", c->name, "invalid name"); return false; } @@ -303,8 +301,7 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(c->outgoing) { if(strcmp(c->name, name)) { - logger(mesh, MESHLINK_ERROR, "Peer %s is %s instead of %s", c->hostname, name, - c->name); + logger(mesh, MESHLINK_ERROR, "Peer is %s instead of %s", name, c->name); return false; } } else { @@ -316,8 +313,8 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Check if version matches */ if(c->protocol_major != mesh->self->connection->protocol_major) { - logger(mesh, MESHLINK_ERROR, "Peer %s (%s) uses incompatible version %d.%d", - c->name, c->hostname, c->protocol_major, c->protocol_minor); + logger(mesh, MESHLINK_ERROR, "Peer %s uses incompatible version %d.%d", + c->name, c->protocol_major, c->protocol_minor); return false; } @@ -325,7 +322,7 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { init_configuration(&c->config_tree); if(!read_host_config(mesh, c->config_tree, c->name)) { - logger(mesh, MESHLINK_ERROR, "Peer %s had unknown identity (%s)", c->hostname, c->name); + logger(mesh, MESHLINK_ERROR, "Peer %s has unknown identity", c->name); return false; } } @@ -333,11 +330,11 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { read_ecdsa_public_key(mesh, c); if(!ecdsa_active(c->ecdsa)) { - logger(mesh, MESHLINK_ERROR, "No key known for peer %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "No key known for peer %s", c->name); node_t *n = lookup_node(mesh, c->name); if(n && !n->status.waitingforkey) { - logger(mesh, MESHLINK_INFO, "Requesting key from peer %s (%s)", c->name, c->hostname); + logger(mesh, MESHLINK_INFO, "Requesting key from peer %s", c->name); send_req_key(mesh, n); } @@ -347,8 +344,8 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Forbid version rollback for nodes whose ECDSA key we know */ if(ecdsa_active(c->ecdsa) && c->protocol_minor < 2) { - logger(mesh, MESHLINK_ERROR, "Peer %s (%s) tries to roll back protocol version to %d.%d", - c->name, c->hostname, c->protocol_major, c->protocol_minor); + logger(mesh, MESHLINK_ERROR, "Peer %s tries to roll back protocol version to %d.%d", + c->name, c->protocol_major, c->protocol_minor); return false; } @@ -390,14 +387,12 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { node_t *n; if(sscanf(request, "%*d " MAX_STRING " %d %x", hisport, &devclass, &options) != 3) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ACK", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ACK", c->name); return false; } if(devclass < 0 || devclass > _DEV_CLASS_MAX) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ACK", c->name, - c->hostname, "devclass invalid"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ACK", c->name, "devclass invalid"); return false; } @@ -412,7 +407,7 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { } else { if(n->connection) { /* Oh dear, we already have a connection to this node. */ - logger(mesh, MESHLINK_DEBUG, "Established a second connection with %s (%s), closing old connection", n->connection->name, n->connection->hostname); + logger(mesh, MESHLINK_DEBUG, "Established a second connection with %s, closing old connection", n->connection->name); if(n->connection->outgoing) { if(c->outgoing) @@ -447,8 +442,7 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { c->allow_request = ALL; c->status.active = true; - logger(mesh, MESHLINK_INFO, "Connection with %s (%s) activated", c->name, - c->hostname); + logger(mesh, MESHLINK_INFO, "Connection with %s activated", c->name); /* Send him everything we know */ diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 8272caa4..c18319e0 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -65,30 +65,26 @@ bool add_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(sscanf(request, "%*d %*x "MAX_STRING" %d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %x %d", from_name, &from_devclass, to_name, to_address, to_port, &to_devclass, &options, &weight) != 8) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ADD_EDGE", c->name); return false; } /* Check if names are valid */ if(!check_id(from_name) || !check_id(to_name)) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, - c->hostname, "invalid name"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ADD_EDGE", c->name, "invalid name"); return false; } // Check if devclasses are valid if(from_devclass < 0 || from_devclass > _DEV_CLASS_MAX) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, - c->hostname, "from devclass invalid"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ADD_EDGE", c->name, "from devclass invalid"); return false; } if(to_devclass < 0 || to_devclass > _DEV_CLASS_MAX) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, - c->hostname, "to devclass invalid"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ADD_EDGE", c->name, "to devclass invalid"); return false; } @@ -131,21 +127,21 @@ bool add_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(e) { if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) { if(from == mesh->self) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Got %s from %s for ourself which does not match existing entry", + "ADD_EDGE", c->name); send_add_edge(mesh, c, e); return true; } else { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Got %s from %s which does not match existing entry", + "ADD_EDGE", c->name); edge_del(mesh, e); graph(mesh); } } else return true; } else if(from == mesh->self) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) for ourself which does not exist", - "ADD_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Got %s from %s for ourself which does not exist", + "ADD_EDGE", c->name); mesh->contradicting_add_edge++; e = new_edge(); e->from = from; @@ -186,16 +182,14 @@ bool del_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { node_t *from, *to; if(sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "DEL_EDGE", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "DEL_EDGE", c->name); return false; } /* Check if names are valid */ if(!check_id(from_name) || !check_id(to_name)) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, - c->hostname, "invalid name"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "DEL_EDGE", c->name, "invalid name"); return false; } @@ -208,14 +202,14 @@ bool del_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { to = lookup_node(mesh, to_name); if(!from) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Got %s from %s which does not appear in the edge tree", + "DEL_EDGE", c->name); return true; } if(!to) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Got %s from %s which does not appear in the edge tree", + "DEL_EDGE", c->name); return true; } @@ -224,14 +218,14 @@ bool del_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { e = lookup_edge(from, to); if(!e) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Got %s from %s which does not appear in the edge tree", + "DEL_EDGE", c->name); return true; } if(e->from == mesh->self) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) for ourself", - "DEL_EDGE", c->name, c->hostname); + logger(mesh, MESHLINK_WARNING, "Got %s from %s for ourself", + "DEL_EDGE", c->name); mesh->contradicting_del_edge++; send_add_edge(mesh, c, e); /* Send back a correction */ return true; diff --git a/src/protocol_key.c b/src/protocol_key.c index 6d1e8ffe..6384eb39 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -46,8 +46,7 @@ bool key_changed_h(meshlink_handle_t *mesh, connection_t *c, const char *request node_t *n; if(sscanf(request, "%*d %*x " MAX_STRING, name) != 1) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "KEY_CHANGED", - c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "KEY_CHANGED", c->name); return false; } @@ -57,8 +56,7 @@ bool key_changed_h(meshlink_handle_t *mesh, connection_t *c, const char *request n = lookup_node(mesh, name); if(!n) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) origin %s which does not exist", - "KEY_CHANGED", c->name, c->hostname, name); + logger(mesh, MESHLINK_ERROR, "Got %s from %s origin %s which does not exist", "KEY_CHANGED", c->name, name); return true; } @@ -80,7 +78,7 @@ static bool send_initial_sptps_data(void *handle, uint8_t type, const void *data bool send_req_key(meshlink_handle_t *mesh, node_t *to) { if(!node_read_ecdsa_public_key(mesh, to)) { - logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s (%s)", to->name, to->hostname); + logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s", to->name); send_request(mesh, to->nexthop->connection, "%d %s %s %d", REQ_KEY, mesh->self->name, to->name, REQ_PUBKEY); return true; } @@ -111,24 +109,24 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char * case ANS_PUBKEY: { if(node_read_ecdsa_public_key(mesh, from)) { - logger(mesh, MESHLINK_WARNING, "Got ANS_PUBKEY from %s (%s) even though we already have his pubkey", from->name, from->hostname); + logger(mesh, MESHLINK_WARNING, "Got ANS_PUBKEY from %s even though we already have his pubkey", from->name); return true; } char pubkey[MAX_STRING_SIZE]; if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, pubkey) != 1 || !(from->ecdsa = ecdsa_set_base64_public_key(pubkey))) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ANS_PUBKEY", from->name, from->hostname, "invalid pubkey"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ANS_PUBKEY", from->name, "invalid pubkey"); return true; } - logger(mesh, MESHLINK_INFO, "Learned ECDSA public key from %s (%s)", from->name, from->hostname); + logger(mesh, MESHLINK_INFO, "Learned ECDSA public key from %s", from->name); append_config_file(mesh, from->name, "ECDSAPublicKey", pubkey); return true; } case REQ_KEY: { if(!node_read_ecdsa_public_key(mesh, from)) { - logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s (%s)", from->name, from->hostname); + logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s", from->name); send_request(mesh, from->nexthop->connection, "%d %s %s %d", REQ_KEY, mesh->self->name, from->name, REQ_PUBKEY); return true; } @@ -145,7 +143,7 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char * int len; if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "REQ_SPTPS_START", from->name, from->hostname, "invalid SPTPS data"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "REQ_SPTPS_START", from->name, "invalid SPTPS data"); return true; } @@ -162,14 +160,14 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char * case REQ_SPTPS: { if(!from->status.validkey) { - logger(mesh, MESHLINK_ERROR, "Got REQ_SPTPS from %s (%s) but we don't have a valid key yet", from->name, from->hostname); + logger(mesh, MESHLINK_ERROR, "Got REQ_SPTPS from %s but we don't have a valid key yet", from->name); return true; } char buf[MAX_STRING_SIZE]; int len; if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "REQ_SPTPS", from->name, from->hostname, "invalid SPTPS data"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "REQ_SPTPS", from->name, "invalid SPTPS data"); return true; } sptps_receive_data(&from->sptps, buf, len); @@ -177,7 +175,7 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char * } default: - logger(mesh, MESHLINK_ERROR, "Unknown extended REQ_KEY request from %s (%s): %s", from->name, from->hostname, request); + logger(mesh, MESHLINK_ERROR, "Unknown extended REQ_KEY request from %s: %s", from->name, request); return true; } } @@ -189,29 +187,28 @@ bool req_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { int reqno = 0; if(sscanf(request, "%*d " MAX_STRING " " MAX_STRING " %d", from_name, to_name, &reqno) < 2) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "REQ_KEY", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "REQ_KEY", c->name); return false; } if(!check_id(from_name) || !check_id(to_name)) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "REQ_KEY", c->name, c->hostname, "invalid name"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "REQ_KEY", c->name, "invalid name"); return false; } from = lookup_node(mesh, from_name); if(!from) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) origin %s which does not exist in our connection list", - "REQ_KEY", c->name, c->hostname, from_name); + logger(mesh, MESHLINK_ERROR, "Got %s from %s origin %s which does not exist in our connection list", + "REQ_KEY", c->name, from_name); return true; } to = lookup_node(mesh, to_name); if(!to) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) destination %s which does not exist in our connection list", - "REQ_KEY", c->name, c->hostname, to_name); + logger(mesh, MESHLINK_ERROR, "Got %s from %s destination %s which does not exist in our connection list", + "REQ_KEY", c->name, to_name); return true; } @@ -226,8 +223,8 @@ bool req_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { send_ans_key(mesh, from); } else { if(!to->status.reachable) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) destination %s which is not reachable", - "REQ_KEY", c->name, c->hostname, to_name); + logger(mesh, MESHLINK_WARNING, "Got %s from %s destination %s which is not reachable", + "REQ_KEY", c->name, to_name); return true; } @@ -253,29 +250,28 @@ bool ans_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, from_name, to_name, key, &cipher, &digest, &maclength, &compression, address, port) < 7) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ANS_KEY", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ANS_KEY", c->name); return false; } if(!check_id(from_name) || !check_id(to_name)) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s): %s", "ANS_KEY", c->name, c->hostname, "invalid name"); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ANS_KEY", c->name, "invalid name"); return false; } from = lookup_node(mesh, from_name); if(!from) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) origin %s which does not exist in our connection list", - "ANS_KEY", c->name, c->hostname, from_name); + logger(mesh, MESHLINK_ERROR, "Got %s from %s origin %s which does not exist in our connection list", + "ANS_KEY", c->name, from_name); return true; } to = lookup_node(mesh, to_name); if(!to) { - logger(mesh, MESHLINK_ERROR, "Got %s from %s (%s) destination %s which does not exist in our connection list", - "ANS_KEY", c->name, c->hostname, to_name); + logger(mesh, MESHLINK_ERROR, "Got %s from %s destination %s which does not exist in our connection list", + "ANS_KEY", c->name, to_name); return true; } @@ -283,8 +279,8 @@ bool ans_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { if(to != mesh->self) { if(!to->status.reachable) { - logger(mesh, MESHLINK_WARNING, "Got %s from %s (%s) destination %s which is not reachable", - "ANS_KEY", c->name, c->hostname, to_name); + logger(mesh, MESHLINK_WARNING, "Got %s from %s destination %s which is not reachable", + "ANS_KEY", c->name, to_name); return true; } @@ -306,7 +302,7 @@ bool ans_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Compression is not supported. */ if(compression != 0) { - logger(mesh, MESHLINK_ERROR, "Node %s (%s) uses bogus compression level!", from->name, from->hostname); + logger(mesh, MESHLINK_ERROR, "Node %s uses bogus compression level!", from->name); return true; } @@ -318,7 +314,7 @@ bool ans_key_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { int len = b64decode(key, buf, strlen(key)); if(!len || !sptps_receive_data(&from->sptps, buf, len)) - logger(mesh, MESHLINK_ERROR, "Error processing SPTPS data from %s (%s)", from->name, from->hostname); + logger(mesh, MESHLINK_ERROR, "Error processing SPTPS data from %s", from->name); if(from->status.validkey) { if(*address && *port) { diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 6b3c4ab8..8948bb2e 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -45,13 +45,11 @@ bool status_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { char statusstring[MAX_STRING_SIZE]; if(sscanf(request, "%*d %d " MAX_STRING, &statusno, statusstring) != 2) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "STATUS", - c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "STATUS", c->name); return false; } - logger(mesh, MESHLINK_INFO, "Status message from %s (%s): %d: %s", - c->name, c->hostname, statusno, statusstring); + logger(mesh, MESHLINK_INFO, "Status message from %s: %d: %s", c->name, statusno, statusstring); return true; } @@ -68,13 +66,11 @@ bool error_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { char errorstring[MAX_STRING_SIZE]; if(sscanf(request, "%*d %d " MAX_STRING, &err, errorstring) != 2) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ERROR", - c->name, c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ERROR", c->name); return false; } - logger(mesh, MESHLINK_INFO, "Error message from %s (%s): %d: %s", - c->name, c->hostname, err, errorstring); + logger(mesh, MESHLINK_INFO, "Error message from %s: %d: %s", c->name, err, errorstring); return false; } @@ -138,8 +134,7 @@ bool tcppacket_h(meshlink_handle_t *mesh, connection_t *c, const char *request) short int len; if(sscanf(request, "%*d %hd", &len) != 1) { - logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "PACKET", c->name, - c->hostname); + logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "PACKET", c->name); return false; } diff --git a/src/route.c b/src/route.c index 1c0048e2..00d3d142 100644 --- a/src/route.c +++ b/src/route.c @@ -29,7 +29,7 @@ bool decrement_ttl = false; static bool checklength(node_t *source, vpn_packet_t *packet, uint16_t length) { if(packet->len < length) { - logger(source->mesh, MESHLINK_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname); + logger(source->mesh, MESHLINK_WARNING, "Got too short packet from %s", source->name); return false; } else return true; @@ -77,7 +77,7 @@ void route(meshlink_handle_t *mesh, node_t *source, vpn_packet_t *packet) { via = (owner->via == mesh->self) ? owner->nexthop : owner->via; if(via == source) { - logger(mesh, MESHLINK_ERROR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); + logger(mesh, MESHLINK_ERROR, "Routing loop for packet from %s!", source->name); return; }