mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Support FWTK-style proxies.
Pbublished in <sxslmbsxptu.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
278b63093f
commit
5390ada318
4
NEWS
4
NEWS
@ -15,6 +15,10 @@ Previously it only affected reading and writing data.
|
||||
** Download speed shown by the progress bar is based on the data
|
||||
recently read, rather than the average speed of the entire download.
|
||||
The ETA is still based on the average speed, though.
|
||||
|
||||
** It is now possible to connect to FTP servers through FWTK
|
||||
firewalls. Set ftp_proxy to an FTP URL, and Wget will automatically
|
||||
log on to the proxy as "username@host".
|
||||
|
||||
* Wget 1.8.1 is a bugfix release with no user-visible changes.
|
||||
|
||||
|
5
TODO
5
TODO
@ -25,11 +25,6 @@ represent user-visible changes.
|
||||
* Be careful not to lose username/password information given for the
|
||||
URL on the command line.
|
||||
|
||||
* Support FWTK firewalls. It should work like this: if ftp_proxy is
|
||||
set to an ftp URL, Wget should assume the use of an FWTK firewall.
|
||||
It should connect to the proxy URL, log in as username@target-site,
|
||||
and continue as usual.
|
||||
|
||||
* Add a --range parameter allowing you to explicitly specify a range of bytes to
|
||||
get from a file over HTTP (FTP only supports ranges ending at the end of the
|
||||
file, though forcibly disconnecting from the server at the desired endpoint
|
||||
|
@ -1,3 +1,12 @@
|
||||
2002-04-13 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||
|
||||
* url.c (getproxy): Accept a struct url argument. This obviates
|
||||
the need for USE_PROXY_P.
|
||||
|
||||
* retr.c (retrieve_url): Allow proxy to be a non-FTP URL.
|
||||
|
||||
* ftp.c (getftp): Recognize FWTK-style proxy.
|
||||
|
||||
2002-04-12 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||
|
||||
* config.h.in: Only define _VA_LIST when compiled with gcc.
|
||||
|
27
src/ftp.c
27
src/ftp.c
@ -63,6 +63,7 @@ typedef struct
|
||||
enum stype rs; /* remote system reported by ftp server */
|
||||
char *id; /* initial directory */
|
||||
char *target; /* target file name */
|
||||
struct url *proxy; /* FTWK-style proxy */
|
||||
} ccon;
|
||||
|
||||
|
||||
@ -150,15 +151,26 @@ getftp (struct url *u, long *len, long restval, ccon *con)
|
||||
char type_char;
|
||||
struct address_list *al;
|
||||
|
||||
char *host = con->proxy ? con->proxy->host : u->host;
|
||||
int port = con->proxy ? con->proxy->port : u->port;
|
||||
char *logname = user;
|
||||
|
||||
if (con->proxy)
|
||||
{
|
||||
/* If proxy is in use, log in as username@target-site. */
|
||||
logname = xmalloc (strlen (user) + 1 + strlen (u->host) + 1);
|
||||
sprintf (logname, "%s@%s", user, u->host);
|
||||
}
|
||||
|
||||
/* Login to the server: */
|
||||
|
||||
/* First: Establish the control connection. */
|
||||
|
||||
al = lookup_host (u->host, 0);
|
||||
al = lookup_host (host, 0);
|
||||
if (!al)
|
||||
return HOSTERR;
|
||||
set_connection_host_name (u->host);
|
||||
csock = connect_to_many (al, u->port, 0);
|
||||
set_connection_host_name (host);
|
||||
csock = connect_to_many (al, port, 0);
|
||||
set_connection_host_name (NULL);
|
||||
address_list_release (al);
|
||||
|
||||
@ -178,7 +190,11 @@ getftp (struct url *u, long *len, long restval, ccon *con)
|
||||
logprintf (LOG_VERBOSE, _("Logging in as %s ... "), user);
|
||||
if (opt.server_response)
|
||||
logputs (LOG_ALWAYS, "\n");
|
||||
err = ftp_login (&con->rbuf, user, passwd);
|
||||
err = ftp_login (&con->rbuf, logname, passwd);
|
||||
|
||||
if (con->proxy)
|
||||
xfree (logname);
|
||||
|
||||
/* FTPRERR, FTPSRVERR, WRITEFAILED, FTPLOGREFUSED, FTPLOGINC */
|
||||
switch (err)
|
||||
{
|
||||
@ -1629,7 +1645,7 @@ ftp_retrieve_glob (struct url *u, ccon *con, int action)
|
||||
of URL. Inherently, its capabilities are limited on what can be
|
||||
encoded into a URL. */
|
||||
uerr_t
|
||||
ftp_loop (struct url *u, int *dt)
|
||||
ftp_loop (struct url *u, int *dt, struct url *proxy)
|
||||
{
|
||||
ccon con; /* FTP connection */
|
||||
uerr_t res;
|
||||
@ -1642,6 +1658,7 @@ ftp_loop (struct url *u, int *dt)
|
||||
con.st = ON_YOUR_OWN;
|
||||
con.rs = ST_UNIX;
|
||||
con.id = NULL;
|
||||
con.proxy = proxy;
|
||||
res = RETROK; /* in case it's not used */
|
||||
|
||||
/* If the file name is empty, the user probably wants a directory
|
||||
|
@ -105,7 +105,7 @@ enum wget_ftp_fstatus
|
||||
};
|
||||
|
||||
struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
|
||||
uerr_t ftp_loop PARAMS ((struct url *, int *));
|
||||
uerr_t ftp_loop PARAMS ((struct url *, int *, struct url *));
|
||||
|
||||
uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));
|
||||
|
||||
|
45
src/retr.c
45
src/retr.c
@ -274,10 +274,6 @@ calc_rate (long bytes, long msecs, int *units)
|
||||
return dlrate;
|
||||
}
|
||||
|
||||
#define USE_PROXY_P(u) (opt.use_proxy && getproxy((u)->scheme) \
|
||||
&& no_proxy_match((u)->host, \
|
||||
(const char **)opt.no_proxy))
|
||||
|
||||
/* Maximum number of allowed redirections. 20 was chosen as a
|
||||
"reasonable" value, which is low enough to not cause havoc, yet
|
||||
high enough to guarantee that normal retrievals will not be hurt by
|
||||
@ -295,9 +291,8 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
uerr_t result;
|
||||
char *url;
|
||||
int location_changed, dummy;
|
||||
int use_proxy;
|
||||
char *mynewloc, *proxy;
|
||||
struct url *u;
|
||||
struct url *u, *proxy_url;
|
||||
int up_error_code; /* url parse error code */
|
||||
char *local_file;
|
||||
int redirection_count = 0;
|
||||
@ -327,22 +322,11 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
result = NOCONERROR;
|
||||
mynewloc = NULL;
|
||||
local_file = NULL;
|
||||
proxy_url = NULL;
|
||||
|
||||
use_proxy = USE_PROXY_P (u);
|
||||
if (use_proxy)
|
||||
proxy = getproxy (u);
|
||||
if (proxy)
|
||||
{
|
||||
struct url *proxy_url;
|
||||
|
||||
/* Get the proxy server for the current scheme. */
|
||||
proxy = getproxy (u->scheme);
|
||||
if (!proxy)
|
||||
{
|
||||
logputs (LOG_NOTQUIET, _("Could not find proxy host.\n"));
|
||||
url_free (u);
|
||||
xfree (url);
|
||||
return PROXERR;
|
||||
}
|
||||
|
||||
/* Parse the proxy URL. */
|
||||
proxy_url = url_parse (proxy, &up_error_code);
|
||||
if (!proxy_url)
|
||||
@ -352,24 +336,22 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
xfree (url);
|
||||
return PROXERR;
|
||||
}
|
||||
if (proxy_url->scheme != SCHEME_HTTP)
|
||||
if (proxy_url->scheme != SCHEME_HTTP && proxy_url->scheme != u->scheme)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Error in proxy URL %s: Must be HTTP.\n"), proxy);
|
||||
url_free (proxy_url);
|
||||
xfree (url);
|
||||
return PROXERR;
|
||||
}
|
||||
|
||||
result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url);
|
||||
url_free (proxy_url);
|
||||
}
|
||||
else if (u->scheme == SCHEME_HTTP
|
||||
|
||||
if (u->scheme == SCHEME_HTTP
|
||||
#ifdef HAVE_SSL
|
||||
|| u->scheme == SCHEME_HTTPS
|
||||
#endif
|
||||
)
|
||||
|| (proxy_url && proxy_url->scheme == SCHEME_HTTP))
|
||||
{
|
||||
result = http_loop (u, &mynewloc, &local_file, refurl, dt, NULL);
|
||||
result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url);
|
||||
}
|
||||
else if (u->scheme == SCHEME_FTP)
|
||||
{
|
||||
@ -379,7 +361,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
int oldrec = opt.recursive;
|
||||
if (redirection_count)
|
||||
opt.recursive = 0;
|
||||
result = ftp_loop (u, dt);
|
||||
result = ftp_loop (u, dt, proxy_url);
|
||||
opt.recursive = oldrec;
|
||||
|
||||
/* There is a possibility of having HTTP being redirected to
|
||||
@ -392,6 +374,13 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
*dt |= TEXTHTML;
|
||||
}
|
||||
}
|
||||
|
||||
if (proxy_url)
|
||||
{
|
||||
url_free (proxy_url);
|
||||
proxy_url = NULL;
|
||||
}
|
||||
|
||||
location_changed = (result == NEWLOCATION);
|
||||
if (location_changed)
|
||||
{
|
||||
|
14
src/url.c
14
src/url.c
@ -1883,15 +1883,20 @@ url_string (const struct url *url, int hide_password)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Returns proxy host address, in accordance with SCHEME. */
|
||||
/* Return the URL of the proxy appropriate for url U. */
|
||||
char *
|
||||
getproxy (enum url_scheme scheme)
|
||||
getproxy (struct url *u)
|
||||
{
|
||||
char *proxy = NULL;
|
||||
char *rewritten_url;
|
||||
static char rewritten_storage[1024];
|
||||
|
||||
switch (scheme)
|
||||
if (!opt.use_proxy)
|
||||
return NULL;
|
||||
if (!no_proxy_match (u->host, (const char **)opt.no_proxy))
|
||||
return NULL;
|
||||
|
||||
switch (u->scheme)
|
||||
{
|
||||
case SCHEME_HTTP:
|
||||
proxy = opt.http_proxy ? opt.http_proxy : getenv ("http_proxy");
|
||||
@ -1910,7 +1915,8 @@ getproxy (enum url_scheme scheme)
|
||||
if (!proxy || !*proxy)
|
||||
return NULL;
|
||||
|
||||
/* Handle shorthands. */
|
||||
/* Handle shorthands. `rewritten_storage' is a kludge to allow
|
||||
getproxy() to return static storage. */
|
||||
rewritten_url = rewrite_shorthand_url (proxy);
|
||||
if (rewritten_url)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void rotate_backups PARAMS ((const char *));
|
||||
int mkalldirs PARAMS ((const char *));
|
||||
char *url_filename PARAMS ((const struct url *));
|
||||
|
||||
char *getproxy PARAMS ((enum url_scheme));
|
||||
char *getproxy PARAMS ((struct url *));
|
||||
int no_proxy_match PARAMS ((const char *, const char **));
|
||||
|
||||
void convert_links PARAMS ((const char *, struct urlpos *));
|
||||
|
Loading…
Reference in New Issue
Block a user