mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-05 22:08:23 +00:00
Better logic for port resolving
This commit is contained in:
1 parent
bcdcbf20ee
commit
409c12a851
1 file changed
+10
-3
+10
-3
@@ -5149,11 +5149,18 @@ const char *mg_set_option(struct mg_server *server, const char *name,
|
|||||||
error_msg = "Cannot bind to port";
|
error_msg = "Cannot bind to port";
|
||||||
break;
|
break;
|
||||||
} else {
|
} 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),
|
ns_sock_to_str(c->sock, buf2, sizeof(buf2),
|
||||||
memchr(vec.ptr, ':', vec.len) == NULL ? 2 : 3);
|
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';
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
|||||||
Reference in new issue
Block a user