Skip to content

Commit

Permalink
Better logic for port resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Mar 18, 2015
1 parent bcdcbf2 commit 409c12a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -5149,11 +5149,18 @@ const char *mg_set_option(struct mg_server *server, const char *name,
error_msg = "Cannot bind to port";
break;
} else {
char buf2[50];
char buf2[50], cert[100], ca[100];
union socket_address sa;
int proto, use_ssl;

ns_parse_address(vec.ptr, &sa, &proto, &use_ssl, cert, ca);
ns_sock_to_str(c->sock, buf2, sizeof(buf2),
memchr(vec.ptr, ':', vec.len) == NULL ? 2 : 3);
n += snprintf(buf + n, sizeof(buf) - n, "%s%s",
n > 0 ? "," : "", buf2);

n += snprintf(buf + n, sizeof(buf) - n, "%s%s%s%s%s%s%s",
n > 0 ? "," : "",
use_ssl ? "ssl://" : "",
buf2, cert[0] ? ":" : "", cert, ca[0] ? ":" : "", ca);
}
}
buf[sizeof(buf) - 1] = '\0';
Expand Down

0 comments on commit 409c12a

Please sign in to comment.