From: Otto Moerbeek Date: Mon, 8 Apr 2024 08:07:05 +0000 (+0200) Subject: Name the values "interface_localaddr" and "interface_remoteaddr" instead of "phys_..." X-Git-Tag: rec-5.1.0-alpha1~30^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e100a4c81b54e053b784e1682111ef161e5bee8;p=thirdparty%2Fpdns.git Name the values "interface_localaddr" and "interface_remoteaddr" instead of "phys_..." --- diff --git a/pdns/recursordist/docs/lua-scripting/dq.rst b/pdns/recursordist/docs/lua-scripting/dq.rst index aa8fd9641c..b06b268107 100644 --- a/pdns/recursordist/docs/lua-scripting/dq.rst +++ b/pdns/recursordist/docs/lua-scripting/dq.rst @@ -57,13 +57,13 @@ The DNSQuestion object contains at least the following fields: :class:`ComboAddress` where this query was received on. If the proxy protocol is used, this will contain the destination address from the proxy protocol header. - .. attribute:: DNSQuestion.phys_remoteaddr + .. attribute:: DNSQuestion.interface_remoteaddr - :class:`ComboAddress` of the physical requestor, that is, the physical network source address of the request. + :class:`ComboAddress` of the interface the requestor used, that is, the network source address of the request. - .. attribute:: DNSQuestion.phys_localaddr + .. attribute:: DNSQuestion.interface_localaddr - The physical :class:`ComboAddress` where this query was received on, which is one of the listening addresses of the recursor. + The :class:`ComboAddress` of the interface where this query was received on, which is one of the listening addresses of the recursor. .. attribute:: DNSQuestion.variable diff --git a/pdns/recursordist/lua-recursor4-ffi.hh b/pdns/recursordist/lua-recursor4-ffi.hh index 7114951731..12b8bf2538 100644 --- a/pdns/recursordist/lua-recursor4-ffi.hh +++ b/pdns/recursordist/lua-recursor4-ffi.hh @@ -77,12 +77,12 @@ extern "C" void pdns_ffi_param_get_local_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default"))); uint16_t pdns_ffi_param_get_local_port(const pdns_ffi_param_t* ref) __attribute__((visibility("default"))); - const char* pdns_ffi_param_get_phys_remote(pdns_ffi_param_t* ref) __attribute__((visibility("default"))); - void pdns_ffi_param_get_phys_remote_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default"))); - uint16_t pdns_ffi_param_get_phys_remote_port(const pdns_ffi_param_t* ref) __attribute__((visibility("default"))); - const char* pdns_ffi_param_get_phys_local(pdns_ffi_param_t* ref) __attribute__((visibility("default"))); - void pdns_ffi_param_get_phys_local_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default"))); - uint16_t pdns_ffi_param_get_phys_local_port(const pdns_ffi_param_t* ref) __attribute__((visibility("default"))); + const char* pdns_ffi_param_get_interface_remote(pdns_ffi_param_t* ref) __attribute__((visibility("default"))); + void pdns_ffi_param_get_interface_remote_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default"))); + uint16_t pdns_ffi_param_get_interface_remote_port(const pdns_ffi_param_t* ref) __attribute__((visibility("default"))); + const char* pdns_ffi_param_get_interface_local(pdns_ffi_param_t* ref) __attribute__((visibility("default"))); + void pdns_ffi_param_get_interface_local_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default"))); + uint16_t pdns_ffi_param_get_interface_local_port(const pdns_ffi_param_t* ref) __attribute__((visibility("default"))); const char* pdns_ffi_param_get_edns_cs(pdns_ffi_param_t* ref) __attribute__((visibility("default"))); void pdns_ffi_param_get_edns_cs_raw(pdns_ffi_param_t* ref, const void** net, size_t* netSize) __attribute__((visibility("default"))); diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index bc0c80c05a..af5308ad7b 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -167,8 +167,8 @@ void RecursorLua4::postPrepareContext() d_lw->registerMember("isTcp", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.isTcp; }, [](DNSQuestion& /* dnsQuestion */, bool newTcp) { (void) newTcp; }); d_lw->registerMember("localaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.local; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newLocal) { (void) newLocal; }); d_lw->registerMember("remoteaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.remote; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newRemote) { (void) newRemote; }); - d_lw->registerMember("phys_localaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.phys_local; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newLocal) { (void) newLocal; }); - d_lw->registerMember("phys_remoteaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.phys_remote; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newRemote) { (void) newRemote; }); + d_lw->registerMember("interface_localaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.interface_local; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newLocal) { (void) newLocal; }); + d_lw->registerMember("interface_remoteaddr", [](const DNSQuestion& dnsQuestion) -> const ComboAddress& { return dnsQuestion.interface_remote; }, [](DNSQuestion& /* dnsQuestion */, const ComboAddress& newRemote) { (void) newRemote; }); d_lw->registerMember("validationState", [](const DNSQuestion& dnsQuestion) -> uint8_t { return (vStateIsBogus(dnsQuestion.validationState) ? /* in order not to break older scripts */ static_cast(255) : static_cast(dnsQuestion.validationState)); }, [](DNSQuestion& /* dnsQuestion */, uint8_t newState) { (void) newState; }); d_lw->registerMember("detailedValidationState", [](const DNSQuestion& dnsQuestion) -> vState { return dnsQuestion.validationState; }, [](DNSQuestion& /* dnsQuestion */, vState newState) { (void) newState; }); @@ -708,8 +708,8 @@ public: std::unique_ptr qnameStr{nullptr}; std::unique_ptr localStr{nullptr}; std::unique_ptr remoteStr{nullptr}; - std::unique_ptr physLocalStr{nullptr}; - std::unique_ptr physRemoteStr{nullptr}; + std::unique_ptr interfaceLocalStr{nullptr}; + std::unique_ptr interfaceRemoteStr{nullptr}; std::unique_ptr ednssubnetStr{nullptr}; std::vector ednsOptionsVect; std::vector proxyProtocolValuesVect; @@ -870,42 +870,42 @@ uint16_t pdns_ffi_param_get_local_port(const pdns_ffi_param_t* ref) return ref->params.local.getPort(); } -const char* pdns_ffi_param_get_phys_remote(pdns_ffi_param_t* ref) +const char* pdns_ffi_param_get_interface_remote(pdns_ffi_param_t* ref) { - if (!ref->physRemoteStr) { - ref->physRemoteStr = std::make_unique(ref->params.phys_remote.toString()); + if (!ref->interfaceRemoteStr) { + ref->interfaceRemoteStr = std::make_unique(ref->params.interface_remote.toString()); } - return ref->physRemoteStr->c_str(); + return ref->interfaceRemoteStr->c_str(); } -void pdns_ffi_param_get_phys_remote_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) +void pdns_ffi_param_get_interface_remote_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) { - pdns_ffi_comboaddress_to_raw(ref->params.phys_remote, addr, addrSize); + pdns_ffi_comboaddress_to_raw(ref->params.interface_remote, addr, addrSize); } -uint16_t pdns_ffi_param_get_phys_remote_port(const pdns_ffi_param_t* ref) +uint16_t pdns_ffi_param_get_interface_remote_port(const pdns_ffi_param_t* ref) { - return ref->params.phys_remote.getPort(); + return ref->params.interface_remote.getPort(); } -const char* pdns_ffi_param_get_phys_local(pdns_ffi_param_t* ref) +const char* pdns_ffi_param_get_interface_local(pdns_ffi_param_t* ref) { - if (!ref->physLocalStr) { - ref->physLocalStr = std::make_unique(ref->params.phys_local.toString()); + if (!ref->interfaceLocalStr) { + ref->interfaceLocalStr = std::make_unique(ref->params.interface_local.toString()); } - return ref->physLocalStr->c_str(); + return ref->interfaceLocalStr->c_str(); } -void pdns_ffi_param_get_phys_local_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) +void pdns_ffi_param_get_interface_local_raw(pdns_ffi_param_t* ref, const void** addr, size_t* addrSize) { - pdns_ffi_comboaddress_to_raw(ref->params.phys_local, addr, addrSize); + pdns_ffi_comboaddress_to_raw(ref->params.interface_local, addr, addrSize); } -uint16_t pdns_ffi_param_get_phys_local_port(const pdns_ffi_param_t* ref) +uint16_t pdns_ffi_param_get_interface_local_port(const pdns_ffi_param_t* ref) { - return ref->params.phys_local.getPort(); + return ref->params.interface_local.getPort(); } const char* pdns_ffi_param_get_edns_cs(pdns_ffi_param_t* ref) diff --git a/pdns/recursordist/lua-recursor4.hh b/pdns/recursordist/lua-recursor4.hh index 263d2a9392..a275184510 100644 --- a/pdns/recursordist/lua-recursor4.hh +++ b/pdns/recursordist/lua-recursor4.hh @@ -88,12 +88,12 @@ public: { // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) DNSQuestion(const ComboAddress& prem, const ComboAddress& ploc, const ComboAddress& rem, const ComboAddress& loc, const DNSName& query, uint16_t type, bool tcp, bool& variable_, bool& wantsRPZ_, bool& logResponse_, bool& addPaddingToResponse_, const struct timeval& queryTime_) : - qname(query), phys_local(ploc), phys_remote(prem), local(loc), remote(rem), variable(variable_), wantsRPZ(wantsRPZ_), logResponse(logResponse_), addPaddingToResponse(addPaddingToResponse_), queryTime(queryTime_), qtype(type), isTcp(tcp) + qname(query), interface_local(ploc), interface_remote(prem), local(loc), remote(rem), variable(variable_), wantsRPZ(wantsRPZ_), logResponse(logResponse_), addPaddingToResponse(addPaddingToResponse_), queryTime(queryTime_), qtype(type), isTcp(tcp) { } const DNSName& qname; - const ComboAddress& phys_local; - const ComboAddress& phys_remote; + const ComboAddress& interface_local; + const ComboAddress& interface_remote; const ComboAddress& local; const ComboAddress& remote; const ComboAddress* fromAuthIP{nullptr}; @@ -169,14 +169,14 @@ public: public: // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) FFIParams(const DNSName& qname_, uint16_t qtype_, const ComboAddress& plocal_, const ComboAddress& premote_, const ComboAddress& local_, const ComboAddress& remote_, const Netmask& ednssubnet_, LuaContext::LuaObject& data_, std::unordered_set& policyTags_, std::vector& records_, const EDNSOptionViewMap& ednsOptions_, const std::vector& proxyProtocolValues_, std::string& requestorId_, std::string& deviceId_, std::string& deviceName_, std::string& routingTag_, boost::optional& rcode_, uint32_t& ttlCap_, bool& variable_, bool tcp_, bool& logQuery_, bool& logResponse_, bool& followCNAMERecords_, boost::optional& extendedErrorCode_, std::string& extendedErrorExtra_, bool& disablePadding_, std::map& meta_) : - data(data_), qname(qname_), phys_local(plocal_), phys_remote(premote_), local(local_), remote(remote_), ednssubnet(ednssubnet_), policyTags(policyTags_), records(records_), ednsOptions(ednsOptions_), proxyProtocolValues(proxyProtocolValues_), requestorId(requestorId_), deviceId(deviceId_), deviceName(deviceName_), routingTag(routingTag_), extendedErrorExtra(extendedErrorExtra_), rcode(rcode_), extendedErrorCode(extendedErrorCode_), ttlCap(ttlCap_), variable(variable_), logQuery(logQuery_), logResponse(logResponse_), followCNAMERecords(followCNAMERecords_), disablePadding(disablePadding_), qtype(qtype_), tcp(tcp_), meta(meta_) + data(data_), qname(qname_), interface_local(plocal_), interface_remote(premote_), local(local_), remote(remote_), ednssubnet(ednssubnet_), policyTags(policyTags_), records(records_), ednsOptions(ednsOptions_), proxyProtocolValues(proxyProtocolValues_), requestorId(requestorId_), deviceId(deviceId_), deviceName(deviceName_), routingTag(routingTag_), extendedErrorExtra(extendedErrorExtra_), rcode(rcode_), extendedErrorCode(extendedErrorCode_), ttlCap(ttlCap_), variable(variable_), logQuery(logQuery_), logResponse(logResponse_), followCNAMERecords(followCNAMERecords_), disablePadding(disablePadding_), qtype(qtype_), tcp(tcp_), meta(meta_) { } LuaContext::LuaObject& data; const DNSName& qname; - const ComboAddress& phys_local; - const ComboAddress& phys_remote; + const ComboAddress& interface_local; + const ComboAddress& interface_remote; const ComboAddress& local; const ComboAddress& remote; const Netmask& ednssubnet; diff --git a/regression-tests.recursor-dnssec/test_ProxyProtocol.py b/regression-tests.recursor-dnssec/test_ProxyProtocol.py index ffc491811f..5f100fe13e 100644 --- a/regression-tests.recursor-dnssec/test_ProxyProtocol.py +++ b/regression-tests.recursor-dnssec/test_ProxyProtocol.py @@ -111,16 +111,16 @@ class ProxyProtocolAllowedRecursorTest(ProxyProtocolRecursorTest): return true end - local physremoteaddr = dq.phys_remoteaddr:toString() - local physlocaladdr = dq.phys_localaddr:toStringWithPort() + local interfaceremoteaddr = dq.interface_remoteaddr:toString() + local interfacelocaladdr = dq.interface_localaddr:toStringWithPort() - if physremoteaddr ~= '127.0.0.1' and physremoteaddr ~= '[::]' then - pdnslog('invalid phys source '..physremoteaddr) + if interfaceremoteaddr ~= '127.0.0.1' and interfaceremoteaddr ~= '[::]' then + pdnslog('invalid interface source '..interfaceremoteaddr) dq:addAnswer(pdns.A, '192.0.2.131', 60) return true end - if physlocaladdr ~= '127.0.0.1:%d' and physlocaladdr ~= '[::1]:%d' then - pdnslog('invalid physdest '..physlocaladdr) + if interfacelocaladdr ~= '127.0.0.1:%d' and interfacelocaladdr ~= '[::1]:%d' then + pdnslog('invalid interfacedest '..interfacelocaladdr) dq:addAnswer(pdns.A, '192.0.2.132', 60) return true end @@ -478,10 +478,10 @@ class ProxyProtocolAllowedFFIRecursorTest(ProxyProtocolAllowedRecursorTest): uint16_t pdns_ffi_param_get_remote_port(const pdns_ffi_param_t* ref); uint16_t pdns_ffi_param_get_local_port(const pdns_ffi_param_t* ref); - const char* pdns_ffi_param_get_phys_remote(pdns_ffi_param_t* ref); - const char* pdns_ffi_param_get_phys_local(pdns_ffi_param_t* ref); - uint16_t pdns_ffi_param_get_phys_remote_port(const pdns_ffi_param_t* ref); - uint16_t pdns_ffi_param_get_phys_local_port(const pdns_ffi_param_t* ref); + const char* pdns_ffi_param_get_interface_remote(pdns_ffi_param_t* ref); + const char* pdns_ffi_param_get_interface_local(pdns_ffi_param_t* ref); + uint16_t pdns_ffi_param_get_interface_remote_port(const pdns_ffi_param_t* ref); + uint16_t pdns_ffi_param_get_interface_local_port(const pdns_ffi_param_t* ref); void pdns_ffi_param_set_tag(pdns_ffi_param_t* ref, unsigned int tag); ]] @@ -515,22 +515,22 @@ class ProxyProtocolAllowedFFIRecursorTest(ProxyProtocolAllowedRecursorTest): return end - local physremoteaddr = ffi.string(ffi.C.pdns_ffi_param_get_phys_remote(obj)) - local physlocaladdr = ffi.string(ffi.C.pdns_ffi_param_get_phys_local(obj)) + local interfaceremoteaddr = ffi.string(ffi.C.pdns_ffi_param_get_interface_remote(obj)) + local interfacelocaladdr = ffi.string(ffi.C.pdns_ffi_param_get_interface_local(obj)) - if physremoteaddr ~= '127.0.0.1' and remoteaddr ~= '::1' then - pdnslog('gettag-ffi: invalid phys source '..physremoteaddr) + if interfaceremoteaddr ~= '127.0.0.1' and remoteaddr ~= '::1' then + pdnslog('gettag-ffi: invalid interface source '..interfaceremoteaddr) ffi.C.pdns_ffi_param_set_tag(obj, 1) return end - if physlocaladdr ~= '127.0.0.1' and physlocaladdr ~= '::1' then - pdnslog('gettag-ffi: invalid phys dest '..physlocaladdr) + if interfacelocaladdr ~= '127.0.0.1' and interfacelocaladdr ~= '::1' then + pdnslog('gettag-ffi: invalid interface dest '..interfacelocaladdr) ffi.C.pdns_ffi_param_set_tag(obj, 2) return end - if ffi.C.pdns_ffi_param_get_phys_local_port(obj) ~= %d then - pdnslog('gettag-ffi: invalid phys source port '..ffi.C.pdns_ffi_param_get_phys_local_port(obj)) + if ffi.C.pdns_ffi_param_get_interface_local_port(obj) ~= %d then + pdnslog('gettag-ffi: invalid interface source port '..ffi.C.pdns_ffi_param_get_interface_local_port(obj)) ffi.C.pdns_ffi_param_set_tag(obj, 2) return end