X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;h=c34b24c9643f4bde69e2904877502e78c01f2b86;hb=HEAD;hp=a5bf2c90ac3f6f33916d8eafceadb98a24f56ebd;hpb=1bd5703bb40828fd6a4dc76eeeccd2884de8decb;p=meshlink diff --git a/src/meshlink.c b/src/meshlink.c index a5bf2c90..d6349890 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -651,7 +651,7 @@ static bool try_bind(meshlink_handle_t *mesh, int port) { int check_port(meshlink_handle_t *mesh) { for(int i = 0; i < 1000; i++) { - int port = 0x1000 + prng(mesh, 0x8000); + int port = 0x1000 + prng(mesh, 0x7000); if(try_bind(mesh, port)) { free(mesh->myport); @@ -1656,6 +1656,19 @@ meshlink_handle_t *meshlink_open_ex(const meshlink_open_params_t *params) { return NULL; } + if(mesh->devclass == DEV_CLASS_BACKBONE) { + logger(NULL, MESHLINK_DEBUG, "Resolving external IP address as we are a backbone node\n"); + + mesh->self->external_ip_address = meshlink_get_external_address(mesh); + + // if(meshlink_errno == MESHLINK_ERESOLV) { + if(!mesh->self->external_ip_address) { + logger(NULL, MESHLINK_WARNING, "Couldn't resolve external IP address, continuing without it...\n"); + } else { + logger(NULL, MESHLINK_INFO, "Found external IP address: %s\n", mesh->self->external_ip_address); + } + } + add_local_addresses(mesh); if(!node_write_config(mesh, mesh->self, new_configuration)) { @@ -4515,7 +4528,7 @@ bool meshlink_channel_aio_send(meshlink_handle_t *mesh, meshlink_channel_t *chan /* Ensure the poll callback is set, and call it right now to push data if possible */ utcp_set_poll_cb(channel->c, channel_poll); - size_t todo = MIN(len, utcp_get_rcvbuf_free(channel->c)); + size_t todo = MIN(len, utcp_get_sndbuf_free(channel->c)); if(todo) { channel_poll(channel->c, todo); @@ -4560,7 +4573,7 @@ bool meshlink_channel_aio_fd_send(meshlink_handle_t *mesh, meshlink_channel_t *c /* Ensure the poll callback is set, and call it right now to push data if possible */ utcp_set_poll_cb(channel->c, channel_poll); - size_t left = utcp_get_rcvbuf_free(channel->c); + size_t left = utcp_get_sndbuf_free(channel->c); if(left) { channel_poll(channel->c, left);