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/06 16:25:56 UTC

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

minfrin     01/04/06 07:25:56

  Modified:    module-2.0 mod_proxy.c mod_proxy.h proxy_ftp.c proxy_http.c
                        proxy_util.c
  Log:
  Bugfixes to proxy_ftp.c -> in some places uri_addr was used instead
  of connect_addr - all hail cut and paste!
  
  Revision  Changes    Path
  1.35      +1 -5      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- mod_proxy.c	2001/04/06 10:44:07	1.34
  +++ mod_proxy.c	2001/04/06 14:25:52	1.35
  @@ -203,10 +203,8 @@
   /* canonicalise each specific scheme */
       if (strncasecmp(url, "http:", 5) == 0)
   	return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
  -#if FTP
       else if (strncasecmp(url, "ftp:", 4) == 0)
   	return ap_proxy_ftp_canon(r, url + 4);
  -#endif
   
       p = strchr(url, ':');
       if (p == NULL || p == url)
  @@ -387,10 +385,8 @@
   	return ap_proxy_connect_handler(r, url, NULL, 0);
       if (strcasecmp(scheme, "http") == 0)
   	return ap_proxy_http_handler(r, url, NULL, 0);
  -#if FTP
       if (strcasecmp(scheme, "ftp") == 0)
   	return ap_proxy_ftp_handler(r, url);
  -#endif
       else {
           ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
   		     "Neither CONNECT, HTTP or FTP for %s",
  @@ -721,7 +717,7 @@
       ap_hook_handler(proxy_handler, NULL, NULL, APR_HOOK_FIRST);
       /* filename-to-URI translation */
       ap_hook_translate_name(proxy_trans, NULL, NULL, APR_HOOK_FIRST);
  -#ifdef FTP
  +#ifdef FTP_FILTER
       /* filters */
       ap_register_output_filter("PROXY_SEND_DIR", ap_proxy_send_dir_filter, AP_FTYPE_CONNECTION);
   #endif
  
  
  
  1.35      +1 -1      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- mod_proxy.h	2001/04/06 10:44:07	1.34
  +++ mod_proxy.h	2001/04/06 14:25:53	1.35
  @@ -259,6 +259,6 @@
   int ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
   int ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
   int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
  -int ap_proxy_pre_http_connection(conn_rec *c);
  +int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r);
   
   #endif /*MOD_PROXY_H*/
  
  
  
  1.34      +20 -12    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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- proxy_ftp.c	2001/04/06 10:44:07	1.33
  +++ proxy_ftp.c	2001/04/06 14:25:53	1.34
  @@ -198,12 +198,18 @@
       apr_bucket *e;
       apr_bucket_brigade *bb = apr_brigade_create(c->pool);
   
  +
       bb = apr_brigade_create(c->pool);
   
       /* Tell http_filter to grab the data one line at a time. */
       c->remain = 0;
   
       ap_get_brigade(c->input_filters, bb, AP_MODE_BLOCKING);
  +
  +/* FIXME: When reading the initial server response to the connect, there
  + * is a hang at this point...
  + */
  +
       e = APR_BRIGADE_FIRST(bb);
       apr_bucket_read(e, (const char **)&response, &len, APR_BLOCK_READ);
       if (len == -1) {
  @@ -434,7 +440,7 @@
   {
       apr_pool_t *p = r->pool;
       apr_socket_t *sock, *local_sock, *remote_sock;
  -    apr_sockaddr_t *uri_addr, *connect_addr;
  +    apr_sockaddr_t *connect_addr;
       conn_rec *origin, *remote;
       int err;
       apr_bucket *e;
  @@ -442,7 +448,6 @@
       char *buf, *pasv, *connectname;
       apr_port_t connectport;
       char buffer[MAX_STRING_LEN];
  -
       char *path, *strp, *parms;
       char *cwd = NULL;
       char *user = NULL;
  @@ -522,15 +527,14 @@
   		 "proxy: FTP connecting %s to %s:%d", url, connectname, connectport);
   
       /* do a DNS lookup for the destination host */
  -    err = apr_sockaddr_info_get(&uri_addr, connectname, APR_UNSPEC, connectport, 0, p);
  +    err = apr_sockaddr_info_get(&connect_addr, connectname, APR_UNSPEC, connectport, 0, p);
   
       /* check if ProxyBlock directive on this host */
  -    if (OK != ap_proxy_checkproxyblock(r, conf, uri_addr)) {
  +    if (OK != ap_proxy_checkproxyblock(r, conf, connect_addr)) {
   	return ap_proxyerror(r, HTTP_FORBIDDEN,
   			     "Connect to remote machine blocked");
       }
   
  -//return HTTP_NOT_IMPLEMENTED;
   
       /*
        * II: Make the Connection
  @@ -548,6 +552,7 @@
                                connectname, NULL));
       }
   
  +
       if ((apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) {
           ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                         "proxy: error creating socket");
  @@ -612,9 +617,9 @@
   	/* handle a permanent error from the above loop */
   	if (failed) {
   	    apr_socket_close(sock);
  -	    return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(r->pool,
  -				 "Could not connect to remote machine: ",
  -				 r->parsed_uri.hostname, NULL));
  +	    return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_psprintf(r->pool,
  +				 "Could not connect to remote machine: %s port %d",
  +				 connectname, connectport));
   	}
       }
   
  @@ -653,19 +658,20 @@
        */
   
       /* set up the connection filters */
  -    ap_proxy_pre_http_connection(origin);
  +    ap_proxy_pre_http_connection(origin, NULL);
   
       /* possible results: */
       /*   120 Service ready in nnn minutes. */
       /*   220 Service ready for new user. */
       /*   421 Service not available, closing control connection. */
       i = ftp_getrc_msg(origin, buffer, sizeof(buffer));
  -	ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
  -				 "FTP: initial connect returned status %d", i);
  +    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  +		 "FTP: initial connect returned status %d", i);
       if (i == -1) {
   	return ap_proxyerror(r, HTTP_BAD_GATEWAY,
   			     "Error reading from remote server");
       }
  +return HTTP_NOT_IMPLEMENTED;
   #if 0
       if (i == 120) {
   	/* RFC2068 states:
  @@ -1319,7 +1325,7 @@
       }
   
       /* set up the connection filters */
  -    ap_proxy_pre_http_connection(remote);
  +    ap_proxy_pre_http_connection(remote, NULL);
   
   
       /*
  @@ -1333,10 +1339,12 @@
       /* send response */
       r->sent_bodyct = 1;
   
  +#ifdef FTP_FILTER
      if (parms[0] == 'd') {
   	/* insert directory filter */
   	ap_add_output_filter("PROXY_SEND_DIR", NULL, r, r->connection);
      }
  +#endif
   
       /* send body */
       if (!r->header_only) {
  
  
  
  1.44      +3 -9      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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- proxy_http.c	2001/04/06 10:44:08	1.43
  +++ proxy_http.c	2001/04/06 14:25:53	1.44
  @@ -369,9 +369,8 @@
   	return HTTP_INTERNAL_SERVER_ERROR;
       }
       conf->id = r->connection->id;
  -    /* allocate this out of the connection pool - the check on r->connection->id makes
  -     * sure that this string does not live past the connection lifetime */
  -    conf->connectname = apr_pstrdup(r->connection->pool, connectname);
  +    /* allocate this out of the config pool */
  +    conf->connectname = apr_pstrdup(r->server->process->pconf, connectname);
       conf->connectport = connectport;
       conf->client_socket = sock;
   
  @@ -387,7 +386,7 @@
        */
   
       /* set up the connection filters */
  -    ap_proxy_pre_http_connection(origin);
  +    ap_proxy_pre_http_connection(origin, NULL);
   
       /* strip connection listed hop-by-hop headers from the request */
       /* even though in theory a connection: close coming from the client
  @@ -555,10 +554,6 @@
   
       ap_get_brigade(origin->input_filters, bb, AP_MODE_BLOCKING);
       e = APR_BRIGADE_FIRST(bb);
  -    /* XXX FIXME: a bug exists where apr_bucket_read() is returning
  -     * len=0 when the response line is expected... we try it up to
  -     * 5 times - this has not fixed the problem though.
  -     */
       i = 5;
       len = 0;
       while (!len && i--) {
  @@ -678,7 +673,6 @@
           APR_BRIGADE_INSERT_TAIL(bb, e);
       }
   
  -/* XXX FIXME - what about 304 et al responses that have no body and no content-length? */
       /* send body */
       if (!r->header_only) {
   	const char *buf;
  
  
  
  1.49      +4 -4      httpd-proxy/module-2.0/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_util.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- proxy_util.c	2001/04/06 10:44:08	1.48
  +++ proxy_util.c	2001/04/06 14:25:54	1.49
  @@ -1073,11 +1073,11 @@
   }
   
   /* set up the minimal filter set */
  -int ap_proxy_pre_http_connection(conn_rec *c)
  +int ap_proxy_pre_http_connection(conn_rec *c, request_rec *r)
   {
  -    ap_add_input_filter("HTTP_IN", NULL, NULL, c);
  -    ap_add_input_filter("CORE_IN", NULL, NULL, c);
  -    ap_add_output_filter("CORE", NULL, NULL, c);
  +    ap_add_input_filter("HTTP_IN", NULL, r, c);
  +    ap_add_input_filter("CORE_IN", NULL, r, c);
  +    ap_add_output_filter("CORE", NULL, r, c);
       return OK;
   }