PortCfg.cc
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 #include "squid.h"
10 #include "anyp/PortCfg.h"
11 #include "comm.h"
12 #include "fatal.h"
13 #include "security/PeerOptions.h"
14 #if USE_OPENSSL
15 #include "ssl/support.h"
16 #endif
17 
18 #include <cstring>
19 #include <limits>
20 
23 
24 int NHttpSockets = 0;
26 
28  next(),
29  s(),
30  transport(AnyP::PROTO_HTTP,1,1), // "Squid is an HTTP proxy", etc.
31  name(NULL),
32  defaultsite(NULL),
33  flags(),
34  allow_direct(false),
35  vhost(false),
36  actAsOrigin(false),
37  ignore_cc(false),
38  connection_auth_disabled(false),
39  ftp_track_dirs(false),
40  vport(0),
41  disable_pmtu_discovery(0),
42  listenConn()
43 {
44  memset(&tcp_keepalive, 0, sizeof(tcp_keepalive));
45 }
46 
48 {
49  if (Comm::IsConnOpen(listenConn)) {
50  listenConn->close();
51  listenConn = NULL;
52  }
53 
54  safe_free(name);
55  safe_free(defaultsite);
56 }
57 
60 {
62  b->s = s;
63  if (name)
64  b->name = xstrdup(name);
65  if (defaultsite)
66  b->defaultsite = xstrdup(defaultsite);
67 
68  b->transport = transport;
69  b->flags = flags;
70  b->allow_direct = allow_direct;
71  b->vhost = vhost;
72  b->vport = vport;
73  b->connection_auth_disabled = connection_auth_disabled;
74  b->ftp_track_dirs = ftp_track_dirs;
75  b->disable_pmtu_discovery = disable_pmtu_discovery;
76  b->tcp_keepalive = tcp_keepalive;
77  b->secure = secure;
78 
79  return b;
80 }
81 
84 {
85  // Unfortunately, .name lifetime is too short in FTP use cases.
86  // TODO: Consider adding InstanceId<uint32_t> to all RefCountable classes.
87  return ScopedId("port");
88 }
89 
90 std::ostream &
91 AnyP::PortCfg::detailCodeContext(std::ostream &os) const
92 {
93  // parsePortSpecification() defaults optional port name to the required
94  // listening address so we cannot easily distinguish one from the other.
95  if (name)
96  os << Debug::Extra << "listening port: " << name;
97  else if (s.port())
98  os << Debug::Extra << "listening port address: " << s;
99  return os;
100 }
101 
Security::ServerOptions secure
TLS configuration options for this listening port.
Definition: PortCfg.h:70
virtual ScopedId codeContextGist() const override
Definition: PortCfg.cc:83
static std::ostream & Extra(std::ostream &os)
prefixes each grouped debugs() line after the first one in the group
Definition: Debug.h:104
int vport
virtual port support. -1 if dynamic, >0 static
Definition: PortCfg.h:52
AnyP::PortCfgPointer HttpPortList
list of Squid http(s)_port configured
Definition: PortCfg.cc:21
bool connection_auth_disabled
Don't support connection oriented auth.
Definition: PortCfg.h:48
char * name
Definition: PortCfg.h:38
int disable_pmtu_discovery
Definition: PortCfg.h:53
virtual std::ostream & detailCodeContext(std::ostream &os) const override
appends human-friendly context description line(s) to a cache.log record
Definition: PortCfg.cc:91
struct AnyP::PortCfg::@27 tcp_keepalive
#define xstrdup
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:26
int HttpSockets[MAXTCPLISTENPORTS]
Definition: PortCfg.cc:25
Ip::Address s
Definition: PortCfg.h:36
AnyP::PortCfgPointer clone() const
Definition: PortCfg.cc:59
bool allow_direct
Allow direct forwarding in accelerator mode.
Definition: PortCfg.h:43
#define NULL
Definition: types.h:166
Definition: forward.h:14
#define safe_free(x)
Definition: xalloc.h:73
AnyP::PortCfgPointer FtpPortList
list of Squid ftp_port configured
Definition: PortCfg.cc:22
AnyP::ProtocolVersion transport
transport protocol and version received by this port
Definition: PortCfg.h:37
char * defaultsite
Definition: PortCfg.h:39
bool vhost
uses host header
Definition: PortCfg.h:44
int NHttpSockets
Definition: PortCfg.cc:24
#define false
Definition: GnuRegex.c:233
#define MAXTCPLISTENPORTS
Definition: PortCfg.h:83
bool ftp_track_dirs
whether transactions should track FTP directories
Definition: PortCfg.h:50
TrafficMode flags
flags indicating what type of traffic to expect via this port.
Definition: PortCfg.h:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors