+/* Transmitting UDP information */
+
+bool send_udp_info(node_t *from, node_t *to) {
+ /* If there's a static relay in the path, there's no point in sending the message
+ farther than the static relay. */
+ to = (to->via == myself) ? to->nexthop : to->via;
+
+ if(to == NULL) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Something went wrong when selecting relay - possible fake UDP_INFO");
+ return false;
+ }
+
+ /* Skip cases where sending UDP info messages doesn't make sense.
+ This is done here in order to avoid repeating the same logic in multiple callsites. */
+
+ if(to == myself) {
+ return true;
+ }
+
+ if(!to->status.reachable) {
+ return true;
+ }
+
+ if(from == myself) {
+ if(to->connection) {
+ return true;
+ }
+
+ struct timeval elapsed;
+
+ timersub(&now, &to->udp_info_sent, &elapsed);
+
+ if(elapsed.tv_sec < udp_info_interval) {
+ return true;
+ }
+ }
+
+ if((myself->options | from->options | to->options) & OPTION_TCPONLY) {
+ return true;
+ }
+
+ if((to->nexthop->options >> 24) < 5) {
+ return true;
+ }
+
+ char *from_address, *from_port;
+ /* If we're the originator, the address we use is irrelevant
+ because the first intermediate node will ignore it.
+ We use our local address as it somewhat makes sense
+ and it's simpler than introducing an encoding for "null" addresses anyway. */
+ sockaddr2str((from != myself) ? &from->address : &to->nexthop->connection->edge->local_address, &from_address, &from_port);
+
+ bool x = send_request(to->nexthop->connection, "%d %s %s %s %s", UDP_INFO, from->name, to->name, from_address, from_port);
+
+ free(from_address);
+ free(from_port);
+
+ if(from == myself) {
+ to->udp_info_sent = now;
+ }
+
+ return x;