Transport.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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_TOOLS_SQUIDCLIENT_TRANSPORT_H
10 #define SQUID_TOOLS_SQUIDCLIENT_TRANSPORT_H
11 
13 
14 #if HAVE_GNUTLS_GNUTLS_H
15 #include <gnutls/gnutls.h>
16 #endif
17 #include <list>
18 #include <string>
19 
20 namespace Transport
21 {
22 
24 class TheConfig
25 {
26 public:
28  ioTimeout(120),
29  localHost(NULL),
33  params = "NORMAL";
34  hostname = "localhost";
35  }
36 
37 // TODO: implicit transport options depending on the protocol-specific options
38 // ie --https enables TLS connection settings
39 
41  void usage();
42 
47  bool parseCommandOpts(int argc, char *argv[], int c, int &optIndex);
48 
50  int ioTimeout;
51 
53  const char *localHost;
54 
56  const char *hostname;
57 
59  uint16_t port;
60 
62  bool tlsEnabled;
63 
66 
71  const char *params;
72 
73  // client certificate PEM file(s)
74  std::list<std::string> certFiles;
75 
76  // client trusted x509 certificate authorities file
77  std::list<std::string> caFiles;
78 
79 #if USE_GNUTLS
80  gnutls_anon_client_credentials_t anonCredentials;
82 
83  // client x509 certificate credentials
84  gnutls_certificate_credentials_t certCredentials;
85 
87  gnutls_session_t session;
88 #endif
89 };
90 
91 extern TheConfig Config;
92 
94 bool Connect();
95 
97 void CloseConnection();
98 
100 void InitTls();
101 
105 bool MaybeStartTls(const char *hostname);
106 
108 void ShutdownTls();
109 
112 ssize_t Write(void *buf, size_t len);
113 
116 ssize_t Read(void *buf, size_t len);
117 
118 } // namespace Transport
119 
120 #endif /* SQUID_TOOLS_SQUIDCLIENT_TRANSPORT_H */
121 
int ioTimeout
I/O operation timeout.
Definition: Transport.h:50
bool parseCommandOpts(int argc, char *argv[], int c, int &optIndex)
Definition: Transport.cc:53
gnutls_certificate_credentials_t certCredentials
Definition: Transport.h:84
const char * params
Definition: Transport.h:71
void InitTls()
Initialize TLS library environment when necessary.
Definition: Transport.cc:353
void CloseConnection()
close the current connection
Definition: Transport.cc:285
uint16_t port
port on the server to contact
Definition: Transport.h:59
TheConfig Config
Definition: Transport.cc:23
bool MaybeStartTls(const char *hostname)
Definition: Transport.cc:488
const char * hostname
the destination server host name to contact
Definition: Transport.h:56
gnutls_anon_client_credentials_t anonCredentials
anonymous client credentials
Definition: Transport.h:81
bool tlsEnabled
whether to enable TLS on the server connnection
Definition: Transport.h:62
void usage()
display Transport Options command line help to stderr
Definition: Transport.cc:29
parameters controlling outgoing connection
Definition: Transport.h:24
std::list< std::string > caFiles
Definition: Transport.h:77
ssize_t Write(void *buf, size_t len)
Definition: Transport.cc:238
bool Connect()
locate and connect to the configured server
Definition: Transport.cc:214
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
#define CACHE_HTTP_PORT
Definition: squid.h:21
void const char * buf
Definition: stub_helper.cc:16
ssize_t Read(void *buf, size_t len)
Definition: Transport.cc:262
std::list< std::string > certFiles
Definition: Transport.h:74
const char * localHost
the local hostname to bind as for outgoing IP
Definition: Transport.h:53
gnutls_session_t session
TLS session state.
Definition: Transport.h:87
void ShutdownTls()
De-initialize TLS library environment when necessary.
Definition: Transport.cc:511
#define NULL
Definition: types.h:166
#define false
Definition: GnuRegex.c:233
bool tlsAnonymous
whether to do anonymous TLS (non-authenticated)
Definition: Transport.h:65

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors