]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
f7f3304a | 9 | #include "squid.h" |
65d448bc | 10 | #include "anyp/PortCfg.h" |
cbff89ba | 11 | #include "comm.h" |
eb6ac808 | 12 | #include "fatal.h" |
6bd62757 | 13 | #include "security/PeerOptions.h" |
cb4f4424 | 14 | #if USE_OPENSSL |
f4e4d4d6 CT |
15 | #include "ssl/support.h" |
16 | #endif | |
1b26be8f | 17 | |
eb6ac808 | 18 | #include <cstring> |
eb6ac808 | 19 | #include <limits> |
eb6ac808 | 20 | |
fa720bfb | 21 | AnyP::PortCfgPointer HttpPortList; |
8ea0d847 | 22 | AnyP::PortCfgPointer FtpPortList; |
65d448bc AJ |
23 | |
24 | int NHttpSockets = 0; | |
25 | int HttpSockets[MAXTCPLISTENPORTS]; | |
26 | ||
eb6ac808 | 27 | AnyP::PortCfg::PortCfg() : |
f53969cc SM |
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), | |
7d17a6a6 | 42 | workerQueues(false), |
f53969cc | 43 | listenConn() |
a97126cc AJ |
44 | { |
45 | memset(&tcp_keepalive, 0, sizeof(tcp_keepalive)); | |
46 | } | |
1b26be8f | 47 | |
65d448bc | 48 | AnyP::PortCfg::~PortCfg() |
1b26be8f | 49 | { |
8bbb16e3 | 50 | if (Comm::IsConnOpen(listenConn)) { |
00406b24 | 51 | listenConn->close(); |
8bbb16e3 | 52 | listenConn = NULL; |
cbff89ba | 53 | } |
04f55905 | 54 | |
1b26be8f | 55 | safe_free(name); |
56 | safe_free(defaultsite); | |
1b26be8f | 57 | } |
f4e4d4d6 | 58 | |
fa720bfb | 59 | AnyP::PortCfgPointer |
65d448bc AJ |
60 | AnyP::PortCfg::clone() const |
61 | { | |
fa720bfb | 62 | AnyP::PortCfgPointer b = new AnyP::PortCfg(); |
65d448bc AJ |
63 | b->s = s; |
64 | if (name) | |
65 | b->name = xstrdup(name); | |
66 | if (defaultsite) | |
67 | b->defaultsite = xstrdup(defaultsite); | |
68 | ||
eb6ac808 | 69 | b->transport = transport; |
6a25a046 | 70 | b->flags = flags; |
65d448bc AJ |
71 | b->allow_direct = allow_direct; |
72 | b->vhost = vhost; | |
65d448bc AJ |
73 | b->vport = vport; |
74 | b->connection_auth_disabled = connection_auth_disabled; | |
7d17a6a6 | 75 | b->workerQueues = workerQueues; |
e7ce227f | 76 | b->ftp_track_dirs = ftp_track_dirs; |
65d448bc | 77 | b->disable_pmtu_discovery = disable_pmtu_discovery; |
86ab7a90 | 78 | b->tcp_keepalive = tcp_keepalive; |
9a622f3e | 79 | b->secure = secure; |
65d448bc | 80 | |
65d448bc AJ |
81 | return b; |
82 | } | |
5ae65581 | 83 | |
ccfbe8f4 AR |
84 | ScopedId |
85 | AnyP::PortCfg::codeContextGist() const | |
86 | { | |
87 | // Unfortunately, .name lifetime is too short in FTP use cases. | |
88 | // TODO: Consider adding InstanceId<uint32_t> to all RefCountable classes. | |
89 | return ScopedId("port"); | |
90 | } | |
91 | ||
92 | std::ostream & | |
93 | AnyP::PortCfg::detailCodeContext(std::ostream &os) const | |
94 | { | |
95 | // parsePortSpecification() defaults optional port name to the required | |
96 | // listening address so we cannot easily distinguish one from the other. | |
97 | if (name) | |
98 | os << Debug::Extra << "listening port: " << name; | |
99 | else if (s.port()) | |
100 | os << Debug::Extra << "listening port address: " << s; | |
101 | return os; | |
102 | } | |
103 |