}
if(!is_valid_hostname(address)) {
- logger(mesh, MESHLINK_DEBUG, "Invalid character in address: %s\n", address);
+ logger(mesh, MESHLINK_DEBUG, "Invalid character in address: %s", address);
+ meshlink_errno = MESHLINK_EINVAL;
+ return false;
+ }
+
+ if((node_t *)node != mesh->self && !port) {
+ logger(mesh, MESHLINK_DEBUG, "Missing port number!");
meshlink_errno = MESHLINK_EINVAL;
return false;
+
}
if(port && !is_valid_port(port)) {
- logger(mesh, MESHLINK_DEBUG, "Invalid character in port: %s\n", address);
+ logger(mesh, MESHLINK_DEBUG, "Invalid character in port: %s", address);
meshlink_errno = MESHLINK_EINVAL;
return false;
}
packmsg_add_int32(&out, mesh->self->devclass);
packmsg_add_bool(&out, mesh->self->status.blacklisted);
packmsg_add_bin(&out, ecdsa_get_public_key(mesh->private_key), 32);
- packmsg_add_str(&out, mesh->self->canonical_address ? mesh->self->canonical_address : "");
+
+ if(mesh->self->canonical_address && !strchr(mesh->self->canonical_address, ' ')) {
+ char *canonical_address = NULL;
+ xasprintf(&canonical_address, "%s %s", mesh->self->canonical_address, mesh->myport);
+ packmsg_add_str(&out, canonical_address);
+ free(canonical_address);
+ } else {
+ packmsg_add_str(&out, mesh->self->canonical_address ? mesh->self->canonical_address : "");
+ }
uint32_t count = 0;
if(port) {
*port++ = 0;
port = xstrdup(port);
+ adns_queue(mesh, address, port, canonical_resolve_cb, outgoing->node, 2);
+ return false;
} else {
- port = xstrdup(mesh->myport);
+ logger(mesh, MESHLINK_ERROR, "Canonical address for %s is missing port number", n->name);
+ free(address);
+ outgoing->state = OUTGOING_RECENT;
}
- adns_queue(mesh, address, port, canonical_resolve_cb, outgoing->node, 2);
- return false;
} else {
outgoing->state = OUTGOING_RECENT;
}