#include "squid.h"
#include "anyp/PortCfg.h"
+#include "anyp/UriScheme.h"
#include "comm.h"
#include "fatal.h"
#include "security/PeerOptions.h"
safe_free(defaultsite);
}
-AnyP::PortCfgPointer
-AnyP::PortCfg::clone() const
+AnyP::PortCfg::PortCfg(const PortCfg &other):
+ next(), // special case; see assert() below
+ s(other.s),
+ transport(other.transport),
+ name(other.name ? xstrdup(other.name) : nullptr),
+ defaultsite(other.defaultsite ? xstrdup(other.defaultsite) : nullptr),
+ flags(other.flags),
+ allow_direct(other.allow_direct),
+ vhost(other.vhost),
+ actAsOrigin(other.actAsOrigin),
+ ignore_cc(other.ignore_cc),
+ connection_auth_disabled(other.connection_auth_disabled),
+ ftp_track_dirs(other.ftp_track_dirs),
+ vport(other.vport),
+ disable_pmtu_discovery(other.disable_pmtu_discovery),
+ workerQueues(other.workerQueues),
+ tcp_keepalive(other.tcp_keepalive),
+ listenConn(), // special case; see assert() below
+ secure(other.secure)
{
- AnyP::PortCfgPointer b = new AnyP::PortCfg();
- b->s = s;
- if (name)
- b->name = xstrdup(name);
- if (defaultsite)
- b->defaultsite = xstrdup(defaultsite);
-
- b->transport = transport;
- b->flags = flags;
- b->allow_direct = allow_direct;
- b->vhost = vhost;
- b->vport = vport;
- b->connection_auth_disabled = connection_auth_disabled;
- b->workerQueues = workerQueues;
- b->ftp_track_dirs = ftp_track_dirs;
- b->disable_pmtu_discovery = disable_pmtu_discovery;
- b->tcp_keepalive = tcp_keepalive;
- b->secure = secure;
+ // to simplify, we only support port copying during parsing
+ assert(!other.next);
+ assert(!other.listenConn);
+}
- return b;
+AnyP::PortCfg *
+AnyP::PortCfg::ipV4clone() const
+{
+ const auto clone = new PortCfg(*this);
+ clone->s.setIPv4();
+ debugs(3, 3, AnyP::UriScheme(transport.protocol).image() << "_port: " <<
+ "cloned wildcard address for split-stack: " << s << " and " << clone->s);
+ return clone;
}
ScopedId
{
public:
PortCfg();
+ // no public copying/moving but see ipV4clone()
+ PortCfg(PortCfg &&) = delete;
~PortCfg();
- AnyP::PortCfgPointer clone() const;
+
+ /// creates the same port configuration but listening on any IPv4 address
+ PortCfg *ipV4clone() const;
/* CodeContext API */
virtual ScopedId codeContextGist() const override;
/// TLS configuration options for this listening port
Security::ServerOptions secure;
+
+private:
+ explicit PortCfg(const PortCfg &other); // for ipV4clone() needs only!
};
} // namespace AnyP