apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

connect.cc File Reference
#include <config.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/srvrec.h>
#include <apt-pkg/strutl.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <list>
#include <set>
#include <sstream>
#include <string>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <sys/socket.h>
#include "aptmethod.h"
#include "connect.h"
#include "rfc2553emu.h"
#include <apti18n.h>
Include dependency graph for connect.cc:

Go to the source code of this file.

Classes

struct  FdFd
 
struct  Connection
 
struct  TlsFd
 

Macros

#define APT_WriteOrFail(TYPE, DATA, LENGTH)
 
#define APT_ReadOrFail(TYPE, DATA, LENGTH)
 

Functions

void RotateDNS ()
 
static bool ConnectionAllowed (char const *const Service, std::string const &Host)
 
static std::vector< struct addrinfo_emu * > OrderAddresses (struct addrinfo_emu *CurHost)
 
static ResultState WaitAndCheckErrors (std::list< Connection > &Conns, std::unique_ptr< MethodFd > &Fd, long TimeoutMsec, bool ReportTimeout)
 
static ResultState ConnectToHostname (std::string const &Host, int const Port, const char *const Service, int DefPort, std::unique_ptr< MethodFd > &Fd, unsigned long const TimeOut, aptMethod *const Owner)
 
ResultState Connect (std::string Host, int Port, const char *Service, int DefPort, std::unique_ptr< MethodFd > &Fd, unsigned long TimeOut, aptMethod *Owner)
 
static bool TalkToSocksProxy (int const ServerFd, std::string const &Proxy, char const *const type, bool const ReadWrite, uint8_t *const ToFrom, unsigned int const Size, unsigned int const Timeout)
 
ResultState UnwrapSocks (std::string Host, int Port, URI Proxy, std::unique_ptr< MethodFd > &Fd, unsigned long Timeout, aptMethod *Owner)
 
ResultState UnwrapTLS (std::string const &Host, std::unique_ptr< MethodFd > &Fd, unsigned long Timeout, aptMethod *Owner)
 

Variables

static std::string LastHost
 
static std::string LastService
 
static struct addrinfo_emuLastHostAddr = 0
 
static struct addrinfo_emuLastUsed = 0
 
static std::vector< SrvRecSrvRecords
 
static std::set< std::string > bad_addr
 

Macro Definition Documentation

◆ APT_ReadOrFail

#define APT_ReadOrFail (   TYPE,
  DATA,
  LENGTH 
)
Value:
if (TalkToSocksProxy(Fd->Fd(), ProxyInfo, TYPE, false, DATA, LENGTH, Timeout) == false) \
static bool TalkToSocksProxy(int const ServerFd, std::string const &Proxy, char const *const type, bool const ReadWrite, uint8_t *const ToFrom, unsigned int const Size, unsigned int const Timeout)
Definition: connect.cc:545

◆ APT_WriteOrFail

#define APT_WriteOrFail (   TYPE,
  DATA,
  LENGTH 
)
Value:
if (TalkToSocksProxy(Fd->Fd(), ProxyInfo, TYPE, true, DATA, LENGTH, Timeout) == false) \

Function Documentation

◆ Connect()

ResultState Connect ( std::string  Host,
int  Port,
const char *  Service,
int  DefPort,
std::unique_ptr< MethodFd > &  Fd,
unsigned long  TimeOut,
aptMethod Owner 
)

◆ ConnectionAllowed()

static bool ConnectionAllowed ( char const *const  Service,
std::string const &  Host 
)
static

Definition at line 69 of file connect.cc.

References _config, APT::String::Endswith(), and Configuration::FindB().

Referenced by Connect(), and ConnectToHostname().

◆ ConnectToHostname()

static ResultState ConnectToHostname ( std::string const &  Host,
int const  Port,
const char *const  Service,
int  DefPort,
std::unique_ptr< MethodFd > &  Fd,
unsigned long const  TimeOut,
aptMethod *const  Owner 
)
static

◆ OrderAddresses()

static std::vector<struct addrinfo_emu *> OrderAddresses ( struct addrinfo_emu CurHost)
static

Definition at line 225 of file connect.cc.

References LastHostAddr, and LastUsed.

Referenced by ConnectToHostname().

◆ RotateDNS()

void RotateDNS ( )

Definition at line 61 of file connect.cc.

References addrinfo_emu::ai_next, LastHostAddr, and LastUsed.

Referenced by FTPConn::Open().

◆ TalkToSocksProxy()

static bool TalkToSocksProxy ( int const  ServerFd,
std::string const &  Proxy,
char const *const  type,
bool const  ReadWrite,
uint8_t *const  ToFrom,
unsigned int const  Size,
unsigned int const  Timeout 
)
static

Definition at line 545 of file connect.cc.

References Proxy, FileFd::Read(), URI::SiteOnly(), WaitFd(), and FileFd::Write().

◆ UnwrapSocks()

ResultState UnwrapSocks ( std::string  Host,
int  Port,
URI  Proxy,
std::unique_ptr< MethodFd > &  Fd,
unsigned long  Timeout,
aptMethod Owner 
)

◆ UnwrapTLS()

◆ WaitAndCheckErrors()

static ResultState WaitAndCheckErrors ( std::list< Connection > &  Conns,
std::unique_ptr< MethodFd > &  Fd,
long  TimeoutMsec,
bool  ReportTimeout 
)
static

Definition at line 269 of file connect.cc.

References bad_addr, SUCCESSFUL, and TRANSIENT_ERROR.

Referenced by ConnectToHostname().

Variable Documentation

◆ bad_addr

std::set<std::string> bad_addr
static

◆ LastHost

std::string LastHost
static

Definition at line 47 of file connect.cc.

Referenced by Connect(), and ConnectToHostname().

◆ LastHostAddr

struct addrinfo_emu* LastHostAddr = 0
static

Definition at line 49 of file connect.cc.

Referenced by ConnectToHostname(), OrderAddresses(), and RotateDNS().

◆ LastService

std::string LastService
static

Definition at line 48 of file connect.cc.

Referenced by Connect(), and ConnectToHostname().

◆ LastUsed

struct addrinfo_emu* LastUsed = 0
static

Definition at line 50 of file connect.cc.

Referenced by ConnectToHostname(), OrderAddresses(), RotateDNS(), and Connection::Take().

◆ SrvRecords

std::vector<SrvRec> SrvRecords
static

Definition at line 52 of file connect.cc.

Referenced by Connect().