]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Use slashes internally to separate hostnames and ports in invitation addresses.
[meshlink] / src / meshlink.c
index 789121d13afbec89a2d56bdf4737cadc19ee2cac..ab3ab7ff9be3d4a2352760d9c56bbc5908f45443 100644 (file)
@@ -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);
        }