]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_key.c
Merge branch 'master' into 1.1
[meshlink] / src / protocol_key.c
index 52666d998698d2d1f6d89f01f67836bf067aa51a..3cf4ab11a0bd121fb976e2e25dfade630e966f40 100644 (file)
@@ -1,7 +1,7 @@
 /*
     protocol_key.c -- handle the meta-protocol, key exchange
     Copyright (C) 1999-2005 Ivo Timmermans,
-                  2000-2006 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2009 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -122,12 +122,18 @@ bool req_key_h(connection_t *c, char *request) {
        if(to == myself) {                      /* Yes, send our own key back */
                mykeyused = true;
                from->received_seqno = 0;
-               memset(from->late, 0, sizeof(from->late));
+               memset(from->late, 0, sizeof from->late);
                send_ans_key(c, myself, from);
        } else {
                if(tunnelserver)
                        return false;
 
+               if(!to->status.reachable) {
+                       logger(LOG_WARNING, _("Got %s from %s (%s) destination %s which is not reachable"),
+                               "REQ_KEY", c->name, c->hostname, to_name);
+                       return true;
+               }
+
                send_req_key(to->nexthop->connection, from, to);
        }
 
@@ -190,6 +196,12 @@ bool ans_key_h(connection_t *c, char *request) {
                if(tunnelserver)
                        return false;
 
+               if(!to->status.reachable) {
+                       logger(LOG_WARNING, _("Got %s from %s (%s) destination %s which is not reachable"),
+                                  "ANS_KEY", c->name, c->hostname, to_name);
+                       return true;
+               }
+
                return send_request(to->nexthop->connection, "%s", request);
        }
 
@@ -236,7 +248,5 @@ bool ans_key_h(connection_t *c, char *request) {
        if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuprobes)
                send_mtu_probe(from);
 
-       flush_queue(from);
-
        return true;
 }