Transport.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
20namespace Transport
21{
22
25{
26public:
28 ioTimeout(120),
29 localHost(nullptr),
31 tlsEnabled(false),
32 tlsAnonymous(false) {
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
51
53 const char *localHost;
54
56 const char *hostname;
57
59 uint16_t port;
60
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
81 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
91extern TheConfig Config;
92
94bool Connect();
95
97void CloseConnection();
98
100void InitTls();
101
105bool MaybeStartTls(const char *hostname);
106
108void ShutdownTls();
109
112ssize_t Write(const void *buf, size_t len);
113
116ssize_t Read(void *buf, size_t len);
117
118} // namespace Transport
119
120#endif /* SQUID_TOOLS_SQUIDCLIENT_TRANSPORT_H */
121
parameters controlling outgoing connection
Definition: Transport.h:25
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
int ioTimeout
I/O operation timeout.
Definition: Transport.h:50
void usage()
display Transport Options command line help to stderr
Definition: Transport.cc:29
gnutls_certificate_credentials_t certCredentials
Definition: Transport.h:84
bool tlsEnabled
whether to enable TLS on the server connection
Definition: Transport.h:62
gnutls_anon_client_credentials_t anonCredentials
anonymous client credentials
Definition: Transport.h:81
bool parseCommandOpts(int argc, char *argv[], int c, int &optIndex)
Definition: Transport.cc:53
std::list< std::string > certFiles
Definition: Transport.h:74
const char * hostname
the destination server host name to contact
Definition: Transport.h:56
const char * params
Definition: Transport.h:71
std::list< std::string > caFiles
Definition: Transport.h:77
bool tlsAnonymous
whether to do anonymous TLS (non-authenticated)
Definition: Transport.h:65
uint16_t port
port on the server to contact
Definition: Transport.h:59
ssize_t Read(void *buf, size_t len)
Definition: Transport.cc:262
bool MaybeStartTls(const char *hostname)
Definition: Transport.cc:488
TheConfig Config
Definition: Transport.cc:23
void ShutdownTls()
De-initialize TLS library environment when necessary.
Definition: Transport.cc:513
ssize_t Write(const void *buf, size_t len)
Definition: Transport.cc:238
void InitTls()
Initialize TLS library environment when necessary.
Definition: Transport.cc:353
bool Connect()
locate and connect to the configured server
Definition: Transport.cc:214
void CloseConnection()
close the current connection
Definition: Transport.cc:285
#define CACHE_HTTP_PORT
Definition: squid.h:16

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors