X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fmeshlink.c;h=ab3ab7ff9be3d4a2352760d9c56bbc5908f45443;hp=789121d13afbec89a2d56bdf4737cadc19ee2cac;hb=0d79f476e0311fb36f41c9c6d86744f9d5386fba;hpb=fbcf08931e531fc2bd4a7e42d0ab03fed26fb9fc diff --git a/src/meshlink.c b/src/meshlink.c index 789121d1..ab3ab7ff 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -442,11 +442,11 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { if(mesh->invitation_addresses) { for list_each(char, combo, mesh->invitation_addresses) { hostname[n] = xstrdup(combo); - char *colon = strchr(hostname[n], ':'); + char *slash = strrchr(hostname[n], '/'); - if(colon) { - *colon = 0; - port[n] = xstrdup(colon + 1); + if(slash) { + *slash = 0; + port[n] = xstrdup(slash + 1); } n++; @@ -489,7 +489,7 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { } } - remove_duplicate_hostnames(hostname, port, 4); + remove_duplicate_hostnames(hostname, port, n); // Resolve the hostnames for(int i = 0; i < n; i++) { @@ -2469,11 +2469,7 @@ bool meshlink_add_invitation_address(struct meshlink_handle *mesh, const char *a char *combo; if(port) { - if(strchr(address, ':')) { - xasprintf(&combo, "[%s]:%s", address, port); - } else { - xasprintf(&combo, "%s:%s", address, port); - } + xasprintf(&combo, "%s/%s", address, port); } else { combo = xstrdup(address); }