Explorar o código

Support multiple domains (Step 10/?)

bel2125 %!s(int64=7) %!d(string=hai) anos
pai
achega
4378fdc73b
Modificáronse 2 ficheiros con 16 adicións e 1 borrados
  1. 1 1
      examples/multidomain/base_domain.conf
  2. 15 0
      src/civetweb.c

+ 1 - 1
examples/multidomain/base_domain.conf

@@ -1,4 +1,4 @@
-listening_ports 80r,443s
+listening_ports 80r,443s,8080
 ssl_certificate resources/cert/server.pem
 authentication_domain default
 add_domain examples/multidomain/add_domain.conf

+ 15 - 0
src/civetweb.c

@@ -12192,6 +12192,21 @@ alloc_get_host(struct mg_connection *conn)
 			DEBUG_TRACE("HTTPS Host: %s", host);
 
 		} else {
+			struct mg_domain_context *dom = &(conn->phys_ctx->dd);
+			while (dom) {
+				if (!mg_strcasecmp(host, dom->config[AUTHENTICATION_DOMAIN])) {
+
+					/* Found matching domain */
+					DEBUG_TRACE("HTTP domain %s found",
+					            dom->config[AUTHENTICATION_DOMAIN]);
+
+					/* TODO: Check if this is a HTTP or HTTPS domain */
+					conn->dom_ctx = dom;
+					break;
+				}
+				dom = dom->next;
+			}
+
 			DEBUG_TRACE("HTTP Host: %s", host);
 		}