mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +00:00
Sync main
This commit is contained in:
1 parent
c8e8f94ffe
commit
faeedb2930
1 file changed
+18
-7
+18
-7
@@ -699,8 +699,8 @@ static int ns_parse_address(const char *str, union socket_address *sa,
|
|||||||
sa->sin.sin_port = htons((uint16_t) port);
|
sa->sin.sin_port = htons((uint16_t) port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*use_ssl && (sscanf(str + len, ":%99[^:]:%99[^:]%n", cert, ca, &n) == 2 ||
|
if (*use_ssl && (sscanf(str + len, ":%99[^:,]:%99[^:,]%n", cert, ca, &n) == 2 ||
|
||||||
sscanf(str + len, ":%99[^:]%n", cert, &n) == 1)) {
|
sscanf(str + len, ":%99[^:,]%n", cert, &n) == 1)) {
|
||||||
len += n;
|
len += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5134,20 +5134,31 @@ const char *mg_set_option(struct mg_server *server, const char *name,
|
|||||||
DBG(("%s [%s]", name, *v));
|
DBG(("%s [%s]", name, *v));
|
||||||
|
|
||||||
if (ind == LISTENING_PORT) {
|
if (ind == LISTENING_PORT) {
|
||||||
|
char buf[500] = "";
|
||||||
|
size_t n = 0;
|
||||||
struct vec vec;
|
struct vec vec;
|
||||||
|
/*
|
||||||
|
* Ports can be specified as 0, meaning that OS has to choose any
|
||||||
|
* free port that is available. In order to pass chosen port number to
|
||||||
|
* the user, we rewrite all 0 port to chosen values.
|
||||||
|
*/
|
||||||
while ((value = next_option(value, &vec, NULL)) != NULL) {
|
while ((value = next_option(value, &vec, NULL)) != NULL) {
|
||||||
struct ns_connection *c = ns_bind(&server->ns_mgr, vec.ptr,
|
struct ns_connection *c = ns_bind(&server->ns_mgr, vec.ptr,
|
||||||
mg_ev_handler, NULL);
|
mg_ev_handler, NULL);
|
||||||
if (c== NULL) {
|
if (c == NULL) {
|
||||||
error_msg = "Cannot bind to port";
|
error_msg = "Cannot bind to port";
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
char buf[100];
|
char buf2[50];
|
||||||
ns_sock_to_str(c->sock, buf, sizeof(buf), 2);
|
ns_sock_to_str(c->sock, buf2, sizeof(buf2),
|
||||||
NS_FREE(*v);
|
memchr(vec.ptr, ':', vec.len) == NULL ? 2 : 3);
|
||||||
*v = mg_strdup(buf);
|
n += snprintf(buf + n, sizeof(buf) - n, "%s%s",
|
||||||
|
n > 0 ? "," : "", buf2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
NS_FREE(*v);
|
||||||
|
*v = mg_strdup(buf);
|
||||||
#ifndef MONGOOSE_NO_FILESYSTEM
|
#ifndef MONGOOSE_NO_FILESYSTEM
|
||||||
} else if (ind == HEXDUMP_FILE) {
|
} else if (ind == HEXDUMP_FILE) {
|
||||||
server->ns_mgr.hexdump_file = *v;
|
server->ns_mgr.hexdump_file = *v;
|
||||||
|
|||||||
Reference in new issue
Block a user