+ bool direct = false;
+ if(len >= sizeof pkt.dstid + sizeof pkt.srcid) {
+ n = lookup_node_id(&pkt.srcid);
+ if(n) {
+ node_id_t nullid = {0};
+ if(memcmp(&pkt.dstid, &nullid, sizeof nullid) == 0) {
+ /* A zero dstid is used to indicate a direct, non-relayed packet. */
+ direct = true;
+ } else {
+ to = lookup_node_id(&pkt.dstid);
+ if(!to) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet presumably sent by %s (%s) but with unknown destination ID", n->name, n->hostname);
+ return;
+ }
+ }
+ pkt.len -= sizeof pkt.dstid + sizeof pkt.srcid;
+ }
+ }
+
+ if(to != myself) {
+ /* We are being asked to relay this packet. */
+
+ /* Don't allow random strangers to relay through us. Note that we check for *any* known address since we are not necessarily the first relay. */
+ if (!lookup_node_udp(&from)) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Refusing to relay packet from (presumably) %s (%s) to (presumably) %s (%s) because the packet comes from an unknown address", n->name, n->hostname, to->name, to->hostname);
+ return;
+ }
+
+ send_sptps_data_priv(to, n, 0, pkt.seqno, pkt.len);
+ return;
+ }