Fix the previous commit.
[tinc] / src / protocol_auth.c
index 0882ddf..31b1f1e 100644 (file)
@@ -117,7 +117,7 @@ static bool send_proxyrequest(connection_t *c) {
                                i += 2;
                                c->tcplen += 22;
                        } else {
-                               logger(DEBUG_ALWAYS, LOG_ERR, "Address family %hx not supported for SOCKS 5 proxies!", c->address.sa.sa_family);
+                               logger(DEBUG_ALWAYS, LOG_ERR, "Address family %x not supported for SOCKS 5 proxies!", c->address.sa.sa_family);
                                return false;
                        }
                        if(i > len)
@@ -386,7 +386,7 @@ bool id_h(connection_t *c, const char *request) {
 
        /* Forbid version rollback for nodes whose Ed25519 key we know */
 
-       if(ecdsa_active(c->ecdsa) && c->protocol_minor < 2) {
+       if(ecdsa_active(c->ecdsa) && c->protocol_minor < 1) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s (%s) tries to roll back protocol version to %d.%d",
                        c->name, c->hostname, c->protocol_major, c->protocol_minor);
                return false;
@@ -780,6 +780,8 @@ static bool upgrade_h(connection_t *c, const char *request) {
        logger(DEBUG_ALWAYS, LOG_INFO, "Got Ed25519 public key from %s (%s), upgrading!", c->name, c->hostname);
        append_config_file(c->name, "Ed25519PublicKey", pubkey);
        c->allow_request = TERMREQ;
+       if(c->outgoing)
+               c->outgoing->timeout = 0;
        return send_termreq(c);
 }
 
@@ -788,7 +790,6 @@ bool ack_h(connection_t *c, const char *request) {
                return upgrade_h(c, request);
 
        char hisport[MAX_STRING_SIZE];
-       char *hisaddress;
        int weight, mtu;
        uint32_t options;
        node_t *n;
@@ -865,19 +866,14 @@ bool ack_h(connection_t *c, const char *request) {
        c->edge = new_edge();
        c->edge->from = myself;
        c->edge->to = n;
-       sockaddr2str(&c->address, &hisaddress, NULL);
-       c->edge->address = str2sockaddr(hisaddress, hisport);
-       free(hisaddress);
+       sockaddrcpy(&c->edge->address, &c->address);
+       sockaddr_setport(&c->edge->address, hisport);
        sockaddr_t local_sa;
        socklen_t local_salen = sizeof local_sa;
        if (getsockname(c->socket, &local_sa.sa, &local_salen) < 0)
                logger(DEBUG_ALWAYS, LOG_WARNING, "Could not get local socket address for connection with %s", c->name);
-       else {
-               char *local_address;
-               sockaddr2str(&local_sa, &local_address, NULL);
-               c->edge->local_address = str2sockaddr(local_address, myport);
-               free(local_address);
-       }
+       else
+               sockaddr_setport(&local_sa, myport);
        c->edge->weight = (weight + c->estimated_weight) / 2;
        c->edge->connection = c;
        c->edge->options = c->options;