Proactively send our own key when we request another node's key.
[tinc] / src / net_packet.c
index 8bf399f..456b43d 100644 (file)
@@ -110,7 +110,7 @@ static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
                        gettimeofday(&now, NULL);
                        uint32_t sec = htonl(now.tv_sec); memcpy(data, &sec, 4); data += 4;
                        uint32_t usec = htonl(now.tv_usec); memcpy(data, &usec, 4); data += 4;
-                       packet->len -= 10;
+                       packet->len = 14; // Minimum size for any probe packet.
                } else {
                        /* Legacy protocol: n won't understand type 2 probe replies. */
                        DATA(packet)[0] = 1;
@@ -1111,6 +1111,11 @@ static void try_tx_sptps(node_t *n) {
 }
 
 static void try_tx_legacy(node_t *n) {
+       /* Does he have our key? If not, send one. */
+
+       if(!n->status.validkey_in)
+               send_ans_key(n);
+
        /* Check if we already have a key, or request one. */
 
        if(!n->status.validkey) {