From: Remi Gacogne Date: Mon, 20 Jan 2020 11:05:03 +0000 (+0100) Subject: Make ComboAddress::setPort() update the current object X-Git-Tag: auth-4.3.0-beta1~24^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8718%2Fhead;p=thirdparty%2Fpdns.git Make ComboAddress::setPort() update the current object Instead of creating a new one. --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 7b171efec9..77b5667ee2 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -306,11 +306,9 @@ union ComboAddress { return ntohs(sin4.sin_port); } - ComboAddress setPort(uint16_t port) const + void setPort(uint16_t port) { - ComboAddress ret(*this); - ret.sin4.sin_port=htons(port); - return ret; + sin4.sin_port = htons(port); } void reset() diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index e0e78992fb..6d59cff076 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -784,10 +784,11 @@ int PacketHandler::trySuperMaster(const DNSPacket& p, const DNSName& tsigkeyname int PacketHandler::trySuperMasterSynchronous(const DNSPacket& p, const DNSName& tsigkeyname) { - ComboAddress remote = p.getRemote().setPort(53); + ComboAddress remote = p.getRemote(); if(p.hasEDNSSubnet() && ::arg().contains("trusted-notification-proxy", remote.toString())) { - remote = p.getRealRemote().getNetwork().setPort(53); + remote = p.getRealRemote().getNetwork(); } + remote.setPort(53); Resolver::res_t nsset; try { diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index a4f3196d4d..76b325497a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -814,7 +814,7 @@ static void protobufLogQuery(uint8_t maskV4, uint8_t maskV6, const boost::uuids: } Netmask requestorNM(remote, remote.sin4.sin_family == AF_INET ? maskV4 : maskV6); - const ComboAddress requestor = requestorNM.getMaskedNetwork(); + ComboAddress requestor = requestorNM.getMaskedNetwork(); requestor.setPort(remote.getPort()); RecProtoBufMessage message(DNSProtoBufMessage::Query, uniqueId, &requestor, &local, qname, qtype, qclass, id, tcp, len); message.setServerIdentity(SyncRes::s_serverID);