]> granicus.if.org Git - apache/commitdiff
Initial support for proxy protocol handler sub-modules. Work continues.
authorGraham Leggett <minfrin@apache.org>
Fri, 13 Apr 2001 23:56:04 +0000 (23:56 +0000)
committerGraham Leggett <minfrin@apache.org>
Fri, 13 Apr 2001 23:56:04 +0000 (23:56 +0000)
PR:
Obtained from:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88853 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_connect.c
modules/proxy/proxy_ftp.c
modules/proxy/proxy_http.c

index fdab3b31bc7dcb3826db307dcd9d6c66e8401588..33004834c3f0df42db08f1af8f44816371b7f8d8 100644 (file)
 
 #include "mod_proxy.h"
 
+APR_HOOK_STRUCT(
+       APR_HOOK_LINK(proxy_scheme_handler)
+       APR_HOOK_LINK(proxy_canon_handler)
+)
+
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport),(r,url,proxyhost,proxyport),DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port),(r,url,scheme,def_port),DECLINED)
+
+
 /*
  * A Web proxy module. Stages:
  *
@@ -206,7 +215,7 @@ static int proxy_fixup(request_rec *r)
     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)
-       return ap_proxy_ftp_canon(r, url + 4);
+       return ap_proxy_ftp_canon(r, url + 4, NULL, 0);
 
     p = strchr(url, ':');
     if (p == NULL || p == url)
@@ -399,7 +408,7 @@ static int proxy_handler(request_rec *r)
     if (strcasecmp(scheme, "http") == 0)
        return ap_proxy_http_handler(r, url, NULL, 0);
     if (strcasecmp(scheme, "ftp") == 0)
-       return ap_proxy_ftp_handler(r, url);
+       return ap_proxy_ftp_handler(r, url, NULL, 0);
     else {
         ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
                     "Neither CONNECT, HTTP or FTP for %s",
index 2838986eff2aa6ae508d9618874856c7e7fbd3b9..f349394d2e06f7c1362d59462c5d00c650ab8a6b 100644 (file)
@@ -89,6 +89,7 @@
 #include "apr_md5.h"
 #include "apr_pools.h"
 #include "apr_strings.h"
+#include "apr_hooks.h"
 
 #include "httpd.h"
 #include "http_config.h"
 #include <arpa/inet.h>
 #endif
 
-
 extern module AP_MODULE_DECLARE_DATA proxy_module;
 
-
 /* for proxy_canonenc() */
 enum enctype {
     enc_path, enc_search, enc_user, enc_fpath, enc_parm
@@ -208,12 +207,12 @@ typedef struct {
 /* proxy_connect.c */
 
 int ap_proxy_connect_handler(request_rec *r, char *url,
-                         const char *proxyhost, int proxyport);
+                         const char *proxyhost, apr_port_t proxyport);
 
 /* proxy_ftp.c */
 
-int ap_proxy_ftp_canon(request_rec *r, char *url);
-int ap_proxy_ftp_handler(request_rec *r, char *url);
+int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port);
+int ap_proxy_ftp_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport);
 apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f,
                                      apr_bucket_brigade *bb);
 
@@ -221,9 +220,9 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f,
 /* proxy_http.c */
 
 int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme,
-                    int def_port);
+                    apr_port_t def_port);
 int ap_proxy_http_handler(request_rec *r, char *url,
-                      const char *proxyhost, int proxyport);
+                      const char *proxyhost, apr_port_t proxyport);
 
 /* proxy_util.c */
 
@@ -251,4 +250,12 @@ int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r);
 apr_status_t ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
 void ap_proxy_reset_output_filters(conn_rec *c);
 
+
+/* hooks */
+
+
+AP_DECLARE_HOOK(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport))
+AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme, apr_port_t def_port))
+
+
 #endif /*MOD_PROXY_H*/
index 9658b6c9593db4739b016843a133f29bd41f49c2..133d510a0f2aed4e4bf384e5b065f6d6d1f58b9c 100644 (file)
@@ -62,6 +62,7 @@
 
 #include "mod_proxy.h"
 
+module AP_MODULE_DECLARE_DATA proxy_connect_module;
 
 /*  
  * This handles Netscape CONNECT method secure proxy requests.
@@ -100,7 +101,7 @@ allowed_port(proxy_server_conf *conf, int port)
 }
 
 int ap_proxy_connect_handler(request_rec *r, char *url,
-                         const char *proxyname, int proxyport)
+                         const char *proxyname, apr_port_t proxyport)
 {
     apr_pool_t *p = r->pool;
     apr_socket_t *sock;
@@ -383,3 +384,18 @@ int ap_proxy_connect_handler(request_rec *r, char *url,
 
     return OK;
 }
+
+static void ap_proxy_connect_register_hook(apr_pool_t *p)
+{
+    ap_hook_proxy_scheme_handler(ap_proxy_connect_handler, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
+module AP_MODULE_DECLARE_DATA proxy_connect_module = {
+    STANDARD20_MODULE_STUFF,
+    NULL,              /* create per-directory config structure */
+    NULL,              /* merge per-directory config structures */
+    NULL,              /* create per-server config structure */
+    NULL,              /* merge per-server config structures */
+    NULL,              /* command apr_table_t */
+    ap_proxy_connect_register_hook     /* register hooks */
+};
index 8d693b3d7751425b979e5916b58c57aad5878210..effa19aeac72643049a734e726d04b6dec19acc9 100644 (file)
@@ -62,6 +62,7 @@
 
 #define AUTODETECT_PWD
 
+module AP_MODULE_DECLARE_DATA proxy_ftp_module;
 
 /*
  * Decodes a '%' escaped string, and returns the number of characters
@@ -112,7 +113,7 @@ static int ftp_check_string(const char *x)
 /*
  * Canonicalise ftp URLs.
  */
-int ap_proxy_ftp_canon(request_rec *r, char *url)
+int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port)
 {
     char *user, *password, *host, *path, *parms, *strp, sport[7];
     apr_pool_t *p = r->pool;
@@ -504,7 +505,7 @@ static int ftp_unauthorized (request_rec *r, int log_it)
  * PASV added by Chuck
  * Filters by [Graham Leggett <minfrin@sharp.fm>]
  */
-int ap_proxy_ftp_handler(request_rec *r, char *url)
+int ap_proxy_ftp_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport)
 {
     apr_pool_t *p = r->pool;
     conn_rec *c = r->connection;
@@ -1607,3 +1608,19 @@ int ap_proxy_ftp_handler(request_rec *r, char *url)
     apr_brigade_destroy(bb);
     return OK;
 }
+
+static void ap_proxy_ftp_register_hook(apr_pool_t *p)
+{
+    ap_hook_proxy_scheme_handler(ap_proxy_ftp_handler, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_proxy_canon_handler(ap_proxy_ftp_canon, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
+module AP_MODULE_DECLARE_DATA proxy_ftp_module = {
+    STANDARD20_MODULE_STUFF,
+    NULL,              /* create per-directory config structure */
+    NULL,              /* merge per-directory config structures */
+    NULL,              /* create per-server config structure */
+    NULL,              /* merge per-server config structures */
+    NULL,              /* command apr_table_t */
+    ap_proxy_ftp_register_hook /* register hooks */
+};
index 5fd9f92a0b42fd69bd72f49e662220f3262919df..9b1411fc81abcc20d5b5161239e2ed210c4cc2c2 100644 (file)
 
 #include "mod_proxy.h"
 
+module AP_MODULE_DECLARE_DATA proxy_http_module;
+
 /*
  * Canonicalise http-like URLs.
  *  scheme is the scheme for the URL
  *  url    is the URL starting with the first '/'
  *  def_port is the default port for this scheme.
  */
-int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, int def_port)
+int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port)
 {
     char *host, *path, *search, sport[7];
     const char *err;
@@ -166,7 +168,7 @@ static void ap_proxy_clear_connection(apr_pool_t *p, apr_table_t *headers)
  * route.)
  */
 int ap_proxy_http_handler(request_rec *r, char *url,
-                      const char *proxyname, int proxyport)
+                      const char *proxyname, apr_port_t proxyport)
 {
     request_rec *rp;
     const char *connectname;
@@ -767,3 +769,19 @@ int ap_proxy_http_handler(request_rec *r, char *url,
 
     return OK;
 }
+
+static void ap_proxy_http_register_hook(apr_pool_t *p)
+{
+    ap_hook_proxy_scheme_handler(ap_proxy_http_handler, NULL, NULL, APR_HOOK_FIRST);
+    ap_hook_proxy_canon_handler(ap_proxy_http_canon, NULL, NULL, APR_HOOK_FIRST);
+}
+
+module AP_MODULE_DECLARE_DATA proxy_http_module = {
+    STANDARD20_MODULE_STUFF,
+    NULL,              /* create per-directory config structure */
+    NULL,              /* merge per-directory config structures */
+    NULL,              /* create per-server config structure */
+    NULL,              /* merge per-server config structures */
+    NULL,              /* command apr_table_t */
+    ap_proxy_http_register_hook        /* register hooks */
+};