X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprotocol_auth.c;h=7aaef17fd84d89a5658a295adbba739231bf1271;hb=9708bbfa8e3094de8932a30b1d24c661558d8a03;hp=cf6b26f2d4ad3f915c6532c93cf421769309281e;hpb=103543aa2c15d9f1e2aa313a2e593a7524cce484;p=tinc diff --git a/src/protocol_auth.c b/src/protocol_auth.c index cf6b26f2..7aaef17f 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -40,14 +40,14 @@ bool send_id(connection_t *c) { gettimeofday(&c->start, NULL); - return send_request(c, "%d %s %d", ID, myself->connection->name, - myself->connection->protocol_version); + return send_request(c, "%d %s %d.%d", ID, myself->connection->name, + myself->connection->protocol_major, myself->connection->protocol_minor); } bool id_h(connection_t *c, char *request) { char name[MAX_STRING_SIZE]; - if(sscanf(request, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) { + if(sscanf(request, "%*d " MAX_STRING " %d.%d", name, &c->protocol_major, &c->protocol_minor) < 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name, c->hostname); return false; @@ -86,9 +86,9 @@ bool id_h(connection_t *c, char *request) { /* Check if version matches */ - if(c->protocol_version != myself->connection->protocol_version) { - logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d", - c->name, c->hostname, c->protocol_version); + if(c->protocol_major != myself->connection->protocol_major) { + logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d.%d", + c->name, c->hostname, c->protocol_major, c->protocol_minor); return false; } @@ -261,7 +261,7 @@ bool send_challenge(connection_t *c) { bool challenge_h(connection_t *c, char *request) { char buffer[MAX_STRING_SIZE]; size_t len = rsa_size(&myself->connection->rsa); - size_t digestlen = digest_length(&c->outdigest); + size_t digestlen = digest_length(&c->indigest); char digest[digestlen]; if(sscanf(request, "%*d " MAX_STRING, buffer) != 1) { @@ -401,7 +401,7 @@ static void send_everything(connection_t *c) { bool ack_h(connection_t *c, char *request) { char hisport[MAX_STRING_SIZE]; - char *hisaddress, *dummy; + char *hisaddress; int weight, mtu; uint32_t options; node_t *n; @@ -452,7 +452,7 @@ bool ack_h(connection_t *c, char *request) { if(get_config_int(lookup_config(c->config_tree, "PMTU"), &mtu) && mtu < n->mtu) n->mtu = mtu; - if(get_config_int(lookup_config(myself->connection->config_tree, "PMTU"), &mtu) && mtu < n->mtu) + if(get_config_int(lookup_config(config_tree, "PMTU"), &mtu) && mtu < n->mtu) n->mtu = mtu; if(get_config_bool(lookup_config(c->config_tree, "ClampMSS"), &choice)) { @@ -479,10 +479,9 @@ bool ack_h(connection_t *c, char *request) { c->edge = new_edge(); c->edge->from = myself; c->edge->to = n; - sockaddr2str(&c->address, &hisaddress, &dummy); + sockaddr2str(&c->address, &hisaddress, NULL); c->edge->address = str2sockaddr(hisaddress, hisport); free(hisaddress); - free(dummy); c->edge->weight = (weight + c->estimated_weight) / 2; c->edge->connection = c; c->edge->options = c->options;