mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-25 12:04:47 +00:00
set is_tls at mg_listen and mg_connect level
This commit is contained in:
1 parent
29594283c1
commit
b740c80855
25 files changed
+69
-49
No files matched your search
@@ -53,7 +53,7 @@ static void http_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||
}
|
||||
}
|
||||
// Initialise TLS if we're a TLS listener
|
||||
if (ev == MG_EV_ACCEPT && c->fn_data != NULL) {
|
||||
if (c->is_tls && ev == MG_EV_ACCEPT) {
|
||||
struct mg_tls_opts opts;
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
|
||||
@@ -102,7 +102,7 @@ void setup() {
|
||||
|
||||
// Setup HTTP & HTTPS listeners. Respond "ok" on any HTTP request
|
||||
mg_http_listen(&mgr, "http://0.0.0.0:80", http_ev_handler, NULL);
|
||||
mg_http_listen(&mgr, "https://0.0.0.0:443", http_ev_handler, (void *) 1);
|
||||
mg_http_listen(&mgr, "https://0.0.0.0:443", http_ev_handler, NULL);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
@@ -52,7 +52,7 @@ static void signal_handler(int signo) {
|
||||
// Event handler for the listening connection.
|
||||
// Simply serve static files from `s_root_dir`
|
||||
static void cb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
if (ev == MG_EV_ACCEPT && c->fn_data != NULL) {
|
||||
if (ev == MG_EV_ACCEPT && c->is_tls) {
|
||||
struct mg_tls_opts opts;
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
#ifdef TLS_TWOWAY
|
||||
@@ -164,8 +164,8 @@ int main(int argc, char *argv[]) {
|
||||
s_addr1));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((c = mg_http_listen(&mgr, s_addr2, cb, (void *) 1)) == NULL) {
|
||||
MG_ERROR(("Cannot listen on %s. Use http://ADDR:PORT or :PORT",
|
||||
if ((c = mg_http_listen(&mgr, s_addr2, cb, NULL)) == NULL) {
|
||||
MG_ERROR(("Cannot listen on %s. Use https://ADDR:PORT",
|
||||
s_addr2));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user