summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd/src/modules/proxy
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>1999-03-01 04:27:46 +0000
committerbeck <beck@openbsd.org>1999-03-01 04:27:46 +0000
commitda4e2a805b85b1e03ee77f85b14e50055c16e437 (patch)
tree1b45eae4a3a05003ba7cf157f7388b789dfae8bc /usr.sbin/httpd/src/modules/proxy
parenttweak for 2.5 (diff)
downloadwireguard-openbsd-da4e2a805b85b1e03ee77f85b14e50055c16e437.tar.xz
wireguard-openbsd-da4e2a805b85b1e03ee77f85b14e50055c16e437.zip
mod_ssl-2.2.3-1.3.4 (will require libssl-1.1 for https to work, but
mostly harmless otherwise).
Diffstat (limited to 'usr.sbin/httpd/src/modules/proxy')
-rw-r--r--usr.sbin/httpd/src/modules/proxy/mod_proxy.c67
-rw-r--r--usr.sbin/httpd/src/modules/proxy/proxy_http.c34
2 files changed, 101 insertions, 0 deletions
diff --git a/usr.sbin/httpd/src/modules/proxy/mod_proxy.c b/usr.sbin/httpd/src/modules/proxy/mod_proxy.c
index 0816f6640d2..f5fcf29af6b 100644
--- a/usr.sbin/httpd/src/modules/proxy/mod_proxy.c
+++ b/usr.sbin/httpd/src/modules/proxy/mod_proxy.c
@@ -214,6 +214,9 @@ static int proxy_trans(request_rec *r)
static int proxy_fixup(request_rec *r)
{
char *url, *p;
+#ifdef EAPI
+ int rc;
+#endif /* EAPI */
if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
return DECLINED;
@@ -221,6 +224,14 @@ static int proxy_fixup(request_rec *r)
url = &r->filename[6];
/* canonicalise each specific scheme */
+#ifdef EAPI
+ if (ap_hook_use("ap::mod_proxy::canon",
+ AP_HOOK_SIG3(int,ptr,ptr),
+ AP_HOOK_DECLINE(DECLINED),
+ &rc, r, url) && rc != DECLINED)
+ return rc;
+ else
+#endif /* EAPI */
if (strncasecmp(url, "http:", 5) == 0)
return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
else if (strncasecmp(url, "ftp:", 4) == 0)
@@ -238,7 +249,38 @@ static void proxy_init(server_rec *r, pool *p)
ap_proxy_garbage_init(r, p);
}
+#ifdef EAPI
+static void proxy_addmod(module *m)
+{
+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
+ ap_hook_configure("ap::mod_proxy::http::canon",
+ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
+ ap_hook_register("ap::mod_proxy::http::canon",
+ ap_proxy_http_canon, AP_HOOK_NOCTX);
+
+ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
+ ap_hook_configure("ap::mod_proxy::http::handler",
+ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
+ ap_hook_register("ap::mod_proxy::http::handler",
+ ap_proxy_http_handler, AP_HOOK_NOCTX);
+
+ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
+ ap_hook_configure("ap::mod_proxy::error",
+ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
+ ap_hook_register("ap::mod_proxy::error",
+ ap_proxyerror, AP_HOOK_NOCTX);
+ return;
+}
+static void proxy_remmod(module *m)
+{
+ /* remove the hook references */
+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
+ return;
+}
+#endif /* EAPI */
/* Send a redirection if the request contains a hostname which is not */
/* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
@@ -368,6 +410,14 @@ static int proxy_handler(request_rec *r)
/* CONNECT is a special method that bypasses the normal
* proxy code.
*/
+#ifdef EAPI
+ if (!ap_hook_use("ap::mod_proxy::handler",
+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
+ AP_HOOK_DECLINE(DECLINED),
+ &rc, r, cr, url,
+ ents[i].hostname, ents[i].port,
+ ents[i].protocol) || rc == DECLINED) {
+#endif /* EAPI */
if (r->method_number == M_CONNECT)
rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
ents[i].port);
@@ -377,6 +427,9 @@ static int proxy_handler(request_rec *r)
ents[i].port);
else
rc = DECLINED;
+#ifdef EAPI
+ }
+#endif /* EAPI */
/* an error or success */
if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
@@ -390,6 +443,14 @@ static int proxy_handler(request_rec *r)
* give up??
*/
/* handle the scheme */
+#ifdef EAPI
+ if (ap_hook_use("ap::mod_proxy::handler",
+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
+ AP_HOOK_DECLINE(DECLINED),
+ &rc, r, cr, url,
+ NULL, 0, scheme) && rc != DECLINED)
+ return rc;
+#endif /* EAPI */
if (r->method_number == M_CONNECT)
return ap_proxy_connect_handler(r, cr, url, NULL, 0);
if (strcasecmp(scheme, "http") == 0)
@@ -895,4 +956,10 @@ module MODULE_VAR_EXPORT proxy_module =
NULL, /* child_init */
NULL, /* child_exit */
proxy_detect /* post read-request */
+#ifdef EAPI
+ ,proxy_addmod, /* EAPI: add_module */
+ proxy_remmod, /* EAPI: remove_module */
+ NULL, /* EAPI: rewrite_command */
+ NULL /* EAPI: new_connection */
+#endif
};
diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_http.c b/usr.sbin/httpd/src/modules/proxy/proxy_http.c
index 2447b96aefe..d43dd1ee112 100644
--- a/usr.sbin/httpd/src/modules/proxy/proxy_http.c
+++ b/usr.sbin/httpd/src/modules/proxy/proxy_http.c
@@ -206,6 +206,12 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
return HTTP_BAD_REQUEST;
urlptr += 3;
destport = DEFAULT_HTTP_PORT;
+#ifdef EAPI
+ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
+ AP_HOOK_SIG2(int,ptr),
+ AP_HOOK_TOPMOST,
+ &destport, r);
+#endif /* EAPI */
strp = strchr(urlptr, '/');
if (strp == NULL) {
desthost = ap_pstrdup(p, urlptr);
@@ -301,13 +307,41 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
f = ap_bcreate(p, B_RDWR | B_SOCKET);
ap_bpushfd(f, sock, sock);
+#ifdef EAPI
+ {
+ char *errmsg = NULL;
+ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
+ AP_HOOK_SIG3(ptr,ptr,ptr),
+ AP_HOOK_DECLINE(NULL),
+ &errmsg, r, f);
+ if (errmsg != NULL)
+ return ap_proxyerror(r, errmsg);
+ }
+#endif /* EAPI */
+
ap_hard_timeout("proxy send", r);
ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF,
NULL);
+#ifdef EAPI
+ {
+ int rc = DECLINED;
+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
+ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
+ AP_HOOK_DECLINE(DECLINED),
+ &rc, r, f, desthost, destport, destportstr);
+ if (rc == DECLINED) {
+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
+ else
+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
+ }
+ }
+#else /* EAPI */
if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
else
ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
+#endif /* EAPI */
if (conf->viaopt == via_block) {
/* Block all outgoing Via: headers */