FwdState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_FORWARD_H
10 #define SQUID_FORWARD_H
11 
12 #include "base/RefCount.h"
13 #include "clients/forward.h"
14 #include "comm.h"
15 #include "comm/Connection.h"
16 #include "err_type.h"
17 #include "fde.h"
18 #include "http/StatusCode.h"
19 #include "ip/Address.h"
20 #include "PeerSelectState.h"
21 #include "security/forward.h"
22 #if USE_OPENSSL
23 #include "ssl/support.h"
24 #endif
25 
26 /* forward decls */
27 
30 class PconnPool;
32 class ErrorState;
33 class HttpRequest;
34 
35 #if USE_OPENSSL
36 namespace Ssl
37 {
38 class ErrorDetail;
39 class CertValidationResponse;
40 };
41 #endif
42 
48 
54 
57 
58 class HelperReply;
59 
61 {
63 
64 public:
66  virtual ~FwdState();
67  static void initModule();
68 
70  static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp);
72  static void fwdStart(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *);
74  static time_t ForwardTimeout(const time_t fwdStart);
77  static bool EnoughTimeToReForward(const time_t fwdStart);
78 
82  void useDestinations();
83 
84  void fail(ErrorState *err);
85  void unregister(Comm::ConnectionPointer &conn);
86  void unregister(int fd);
87  void complete();
88  void handleUnregisteredServerEnd();
89  int reforward();
90  bool reforwardableStatus(const Http::StatusCode s) const;
91  void serverClosed(int fd);
92  void connectStart();
93  void connectDone(const Comm::ConnectionPointer & conn, Comm::Flag status, int xerrno);
94  void connectTimeout(int fd);
95  bool checkRetry();
96  bool checkRetriable();
97  void dispatch();
100  Comm::ConnectionPointer pconnPop(const Comm::ConnectionPointer &dest, const char *domain);
101  void pconnPush(Comm::ConnectionPointer & conn, const char *domain);
102 
103  bool dontRetry() { return flags.dont_retry; }
104 
105  void dontRetry(bool val) { flags.dont_retry = val; }
106 
108  Comm::ConnectionPointer const & serverConnection() const { return serverConn; };
109 
110 private:
111  // hidden for safer management of self; use static fwdStart
113  void start(Pointer aSelf);
114  void stopAndDestroy(const char *reason);
115 
116  /* PeerSelectionInitiator API */
117  virtual void noteDestination(Comm::ConnectionPointer conn) override;
118  virtual void noteDestinationsEnd(ErrorState *selectionError) override;
119 
120 #if STRICT_ORIGINAL_DST
121  void selectPeerForIntercepted();
122 #endif
123  static void logReplyStatus(int tries, const Http::StatusCode status);
124  void doneWithRetries();
125  void completed();
126  void retryOrBail();
127 
128  void usePinned();
129 
132  bool pinnedCanRetry() const;
133 
134  ErrorState *makeConnectingError(const err_type type) const;
135  void connectedToPeer(Security::EncryptorAnswer &answer);
136  static void RegisterWithCacheManager(void);
137 
138  void establishTunnelThruProxy();
139  void tunnelEstablishmentDone(Http::TunnelerAnswer &answer);
140  void secureConnectionToPeerIfNeeded();
141  void successfullyConnectedToPeer();
142 
144  void closeServerConnection(const char *reason);
145 
146  void syncWithServerConn(const char *host);
147  void syncHierNote(const Comm::ConnectionPointer &server, const char *host);
148 
150  bool exhaustedTries() const;
151 
153  time_t connectingTimeout(const Comm::ConnectionPointer &conn) const;
154 
155 public:
159 
160  static void abort(void*);
161 
162 private:
163  Pointer self;
166  time_t start_t;
167  int n_tries;
168 
169  struct {
173  } flags;
174 
177 
179 
181 
183  typedef enum { raceImpossible, racePossible, raceHappened } PconnRace;
184  PconnRace pconnRace;
185 };
186 
188 
189 #endif /* SQUID_FORWARD_H */
190 
static void dispatch(thing *t, char *url)
Definition: tcp-banger3.c:298
void getOutgoingAddress(HttpRequest *request, Comm::ConnectionPointer conn)
Definition: FwdState.cc:1454
int type
Definition: errorpage.cc:152
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
std::vector< Comm::ConnectionPointer > ConnectionList
Definition: forward.h:29
HttpRequest * request
Definition: FwdState.h:157
Interface for those who need a list of peers to forward a request to.
int conn
the current server connection FD
Definition: Transport.cc:26
Comm::ConnectionPointer const & serverConnection() const
Definition: FwdState.h:108
PconnRace
possible pconn race states
Definition: FwdState.h:183
unsigned char tos_t
Definition: forward.h:26
time_t start_t
Definition: FwdState.h:166
void GetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Sets initial TOS value and Netfilter for the future outgoing connection.
Definition: FwdState.cc:1521
void dontRetry(bool val)
Definition: FwdState.h:105
StatusCode
Definition: StatusCode.h:20
Comm::ConnectionPointer clientConn
a possibly open connection to the client.
Definition: FwdState.h:165
tos_t GetTosToServer(HttpRequest *request)
Definition: FwdState.cc:1506
Comm::ConnectionList serverDestinations
Definition: FwdState.h:176
PconnRace pconnRace
current pconn race state
Definition: FwdState.h:184
nfmark_t GetNfmarkToServer(HttpRequest *request)
Definition: FwdState.cc:1513
bool dont_retry
Definition: FwdState.h:171
RefCount< FwdState > Pointer
Definition: FwdState.h:65
Flag
Definition: Flag.h:15
RefCount< PconnPool > PconnPoolPointer
Definition: FwdState.h:30
AsyncCall::Pointer closeHandler
The serverConn close handler.
Definition: FwdState.h:180
AccessLogEntryPointer al
info for the future access.log entry
Definition: FwdState.h:158
Definition: Xaction.cc:47
static char server[MAXLINE]
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: FwdState.h:28
bool connected_okay
TCP link ever opened properly. This affects retry of POST,PUT,CONNECT,etc.
Definition: FwdState.h:170
bool dontRetry()
Definition: FwdState.h:103
Comm::ConnectionPointer serverConn
a successfully opened connection to a server.
Definition: FwdState.h:178
#define CBDATA_CHILD(type)
Definition: cbdata.h:307
int n_tries
the number of forwarding attempts so far
Definition: FwdState.h:167
ErrorState * err
Definition: FwdState.h:164
bool forward_completed
Definition: FwdState.h:172
StoreEntry * entry
Definition: FwdState.h:156
uint32_t nfmark_t
Definition: forward.h:25
void Start(const Comm::ConnectionPointer &conn, IDCB *callback, void *cbdata)
Definition: Ident.cc:237
err_type
Definition: err_type.h:12

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors