You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2001/04/14 01:56:04 UTC

cvs commit: httpd-proxy/module-2.0 mod_proxy.c mod_proxy.h proxy_connect.c proxy_ftp.c proxy_http.c

minfrin     01/04/13 16:56:04

  Modified:    module-2.0 mod_proxy.c mod_proxy.h proxy_connect.c
                        proxy_ftp.c proxy_http.c
  Log:
  Initial support for proxy protocol handler sub-modules. Work continues.
  
  Revision  Changes    Path
  1.41      +11 -2     httpd-proxy/module-2.0/mod_proxy.c
  
  Index: mod_proxy.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/mod_proxy.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- mod_proxy.c	2001/04/13 15:51:33	1.40
  +++ mod_proxy.c	2001/04/13 23:56:04	1.41
  @@ -60,6 +60,15 @@
   
   #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 @@
       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 @@
       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",
  
  
  
  1.48      +14 -7     httpd-proxy/module-2.0/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/mod_proxy.h,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- mod_proxy.h	2001/04/13 15:51:33	1.47
  +++ mod_proxy.h	2001/04/13 23:56:04	1.48
  @@ -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"
  @@ -119,10 +120,8 @@
   #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 @@
   /* 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 @@
   /* 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 */
   
  @@ -250,5 +249,13 @@
   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*/
  
  
  
  1.40      +17 -1     httpd-proxy/module-2.0/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_connect.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- proxy_connect.c	2001/04/13 18:57:25	1.39
  +++ proxy_connect.c	2001/04/13 23:56:04	1.40
  @@ -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 @@
   }
   
   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 @@
   
       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 */
  +};
  
  
  
  1.46      +19 -2     httpd-proxy/module-2.0/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_ftp.c,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- proxy_ftp.c	2001/04/13 15:41:35	1.45
  +++ proxy_ftp.c	2001/04/13 23:56:04	1.46
  @@ -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 @@
   /*
    * 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 @@
    * PASV added by Chuck
    * Filters by [Graham Leggett <mi...@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 @@
       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 */
  +};
  
  
  
  1.59      +20 -2     httpd-proxy/module-2.0/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_http.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- proxy_http.c	2001/04/13 15:30:32	1.58
  +++ proxy_http.c	2001/04/13 23:56:04	1.59
  @@ -60,13 +60,15 @@
   
   #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 @@
    * 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 @@
   
       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 */
  +};