// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: ftp.cc,v 1.21 2001/02/20 07:03:18 jgg Exp $
+// $Id: ftp.cc,v 1.29 2002/04/24 05:35:13 jgg Exp $
/* ######################################################################
- HTTP Aquire Method - This is the FTP aquire method for APT.
+ FTP Aquire Method - This is the FTP aquire method for APT.
This is a very simple implementation that does not try to optimize
at all. Commands are sent syncronously with the FTP server (as the
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/md5.h>
+#include <apt-pkg/hashes.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
+#include <iostream>
// Internet stuff
#include <netinet/in.h>
#include "ftp.h"
/*}}}*/
+using namespace std;
+
/* This table is for the EPRT and EPSV commands, it maps the OS address
family to the IETF address families */
struct AFMap
else
Proxy = getenv("ftp_proxy");
+ // Parse no_proxy, a , separated list of domains
+ if (getenv("no_proxy") != 0)
+ {
+ if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
+ Proxy = "";
+ }
+
// Determine what host and port to use based on the proxy settings
int Port = 0;
string Host;
RotateDNS();
if (Connect(Host,Port,"ftp",21,ServerFd,TimeOut,Owner) == false)
return false;
+
+ // Login must be before getpeername otherwise dante won't work.
+ Owner->Status("Logging in");
+ bool Res = Login();
// Get the remote server's address
PeerAddrLen = sizeof(PeerAddr);
if (getsockname(ServerFd,(sockaddr *)&ServerAddr,&ServerAddrLen) != 0)
return _error->Errno("getsockname","Unable to determine the local name");
- Owner->Status("Logging in");
- return Login();
+ return Res;
}
/*}}}*/
// FTPConn::Login - Login to the remote server /*{{{*/
// Setup the variables needed for authentication
string User = "anonymous";
- string Pass = "apt_get_ftp_2.0@debian.linux.user";
+ string Pass = "apt_get_ftp_2.1@debian.linux.user";
// Fill in the user/pass
if (ServerName.User.empty() == false)
/* This opens a data connection, sends REST and RETR and then
transfers the file over. */
bool FTPConn::Get(const char *Path,FileFd &To,unsigned long Resume,
- MD5Summation &MD5,bool &Missing)
+ Hashes &Hash,bool &Missing)
{
Missing = false;
if (CreateDataFd() == false)
if (Resume != 0)
{
- if (MD5.AddFD(To.Fd(),Resume) == false)
+ if (Hash.AddFD(To.Fd(),Resume) == false)
{
_error->Errno("read","Problem hashing file");
return false;
break;
}
- MD5.Add(Buffer,Res);
+ Hash.Add(Buffer,Res);
if (To.Write(Buffer,Res) == false)
{
Close();
}
// Open the file
- MD5Summation MD5;
+ Hashes Hash;
{
FileFd Fd(Itm->DestFile,FileFd::WriteAny);
if (_error->PendingError() == true)
FailFd = Fd.Fd();
bool Missing;
- if (Server->Get(File,Fd,Res.ResumePoint,MD5,Missing) == false)
+ if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing) == false)
{
Fd.Close();
}
Res.LastModified = FailTime;
- Res.MD5Sum = MD5.Result();
+ Res.TakeHashes(Hash);
// Timestamp
struct utimbuf UBuf;
if (getenv("ftp_proxy") != 0)
{
URI Proxy = string(getenv("ftp_proxy"));
+
+ // Run the HTTP method
if (Proxy.Access == "http")
{
// Copy over the environment setting
char S[300];
snprintf(S,sizeof(S),"http_proxy=%s",getenv("ftp_proxy"));
putenv(S);
+ putenv("no_proxy=");
// Run the http method
- string Path = flNotFile(argv[0]) + "/http";
+ string Path = flNotFile(argv[0]) + "http";
execl(Path.c_str(),Path.c_str(),0);
cerr << "Unable to invoke " << Path << endl;
exit(100);