X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprotocol_key.c;h=3cf4ab11a0bd121fb976e2e25dfade630e966f40;hb=08aabbf9317806bc50a9a6693ca866c8936ce26b;hp=66ffb115f1e7f207aeef8032fd164092f7ca27a5;hpb=1b8f8918360b40a2749d40355266ed7dedbe41b5;p=tinc diff --git a/src/protocol_key.c b/src/protocol_key.c index 66ffb115..3cf4ab11 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -1,7 +1,7 @@ /* protocol_key.c -- handle the meta-protocol, key exchange Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2006 Guus Sliepen + 2000-2009 Guus Sliepen 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); } @@ -136,7 +142,7 @@ bool req_key_h(connection_t *c, char *request) { bool send_ans_key(connection_t *c, const node_t *from, const node_t *to) { size_t keylen = cipher_keylength(&from->cipher); - char key[keylen]; + char key[keylen * 2 + 1]; cp(); @@ -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; }