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.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Connect - Replacement connect call
6 
7  ##################################################################### */
8  /*}}}*/
9 #ifndef CONNECT_H
10 #define CONNECT_H
11 
12 #include <memory>
13 #include <string>
14 #include <stddef.h>
15 
16 #include "aptmethod.h"
17 
18 /**
19  * \brief Small representation of a file descriptor for network traffic.
20  *
21  * This provides support for TLS, SOCKS, and HTTP CONNECT proxies.
22  */
23 struct MethodFd
24 {
25  /// \brief Returns -1 for unusable, or an fd to select() on otherwise
26  virtual int Fd() = 0;
27  /// \brief Should behave like read(2)
28  virtual ssize_t Read(void *buf, size_t count) = 0;
29  /// \brief Should behave like write(2)
30  virtual ssize_t Write(void *buf, size_t count) = 0;
31  /// \brief Closes the file descriptor. Can be called multiple times.
32  virtual int Close() = 0;
33  /// \brief Destructor
34  virtual ~MethodFd(){};
35  /// \brief Construct a MethodFd from a UNIX file descriptor
36  static std::unique_ptr<MethodFd> FromFd(int iFd);
37  /// \brief If there is pending data.
38  virtual bool HasPending();
39 };
40 
41 ResultState Connect(std::string To, int Port, const char *Service, int DefPort,
42  std::unique_ptr<MethodFd> &Fd, unsigned long TimeOut, aptMethod *Owner);
43 
44 ResultState UnwrapSocks(std::string To, int Port, URI Proxy, std::unique_ptr<MethodFd> &Fd, unsigned long Timeout, aptMethod *Owner);
45 ResultState UnwrapTLS(std::string const &To, std::unique_ptr<MethodFd> &Fd, unsigned long Timeout, aptMethod *Owner);
46 
47 void RotateDNS();
48 
49 #endif
ResultState
Definition: aptmethod.h:35
Definition: strutl.h:193
ResultState UnwrapSocks(std::string To, int Port, URI Proxy, std::unique_ptr< MethodFd > &Fd, unsigned long Timeout, aptMethod *Owner)
Definition: connect.cc:569
ResultState UnwrapTLS(std::string const &To, std::unique_ptr< MethodFd > &Fd, unsigned long Timeout, aptMethod *Owner)
Definition: connect.cc:896
ResultState Connect(std::string To, int Port, const char *Service, int DefPort, std::unique_ptr< MethodFd > &Fd, unsigned long TimeOut, aptMethod *Owner)
Definition: connect.cc:476
void RotateDNS()
Definition: connect.cc:61
unsigned long TimeOut
Definition: ftp.cc:65
URI Proxy
Definition: ftp.cc:66
Small representation of a file descriptor for network traffic.
Definition: connect.h:24
virtual int Fd()=0
Returns -1 for unusable, or an fd to select() on otherwise.
virtual bool HasPending()
If there is pending data.
Definition: connect.cc:102
static std::unique_ptr< MethodFd > FromFd(int iFd)
Construct a MethodFd from a UNIX file descriptor.
Definition: connect.cc:106
virtual ~MethodFd()
Destructor.
Definition: connect.h:34
virtual int Close()=0
Closes the file descriptor. Can be called multiple times.
virtual ssize_t Read(void *buf, size_t count)=0
Should behave like read(2)
virtual ssize_t Write(void *buf, size_t count)=0
Should behave like write(2)