]> git.meshlink.io Git - meshlink/blobdiff - src/connection.c
Clear connection options and status fields in free_connection_partially().
[meshlink] / src / connection.c
index dd5244860bfea4df1ff31d0f8cb9711b8409f027..0293100e709400b39afae9d79724db76ec0e5c43 100644 (file)
@@ -64,8 +64,10 @@ void free_connection_partially(connection_t *c) {
        ecdsa_free(&c->ecdsa);
        rsa_free(&c->rsa);
 
-       if(c->hischallenge)
+       if(c->hischallenge) {
                free(c->hischallenge);
+               c->hischallenge = NULL;
+       }
 
        buffer_clear(&c->inbuf);
        buffer_clear(&c->outbuf);
@@ -80,6 +82,22 @@ void free_connection_partially(connection_t *c) {
                closesocket(c->socket);
 
        c->socket = -1;
+
+       c->options = 0;
+       c->status.pinged = false;
+       c->status.connecting = false;
+       c->status.encryptout = false;
+       c->status.decryptin = false;
+       c->status.mst = false;
+       c->status.control = false;
+       c->status.pcap = false;
+       c->status.log = false;
+
+       c->protocol_major = 0;
+       c->protocol_minor = 0;
+       c->allow_request = 0;
+       c->tcplen = 0;
+       c->last_ping_time = 0;
 }
 
 void free_connection(connection_t *c) {
@@ -111,7 +129,7 @@ bool dump_connections(connection_t *cdump) {
 
        for(node = connection_tree->head; node; node = node->next) {
                c = node->data;
-               send_request(cdump, "%d %d %s at %s options %x socket %d status %04x",
+               send_request(cdump, "%d %d %s %s %x %d %x",
                                CONTROL, REQ_DUMP_CONNECTIONS,
                                c->name, c->hostname, c->options, c->socket,
                                bitfield_to_int(&c->status, sizeof c->status));