Loading DnsProxyListener.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -46,11 +46,11 @@ #include <sysutils/SocketClient.h> // TODO: Considering moving ResponseCode.h Stopwatch.h thread_util.h to libnetdutils. #include "DnsProxyListener.h" #include "NetdClient.h" // NETID_USE_LOCAL_NAMESERVERS #include "ResolverEventReporter.h" #include "ResponseCode.h" #include "Stopwatch.h" #include "netd_resolv/DnsProxyListener.h" #include "netd_resolv/ResolverEventReporter.h" #include "netd_resolv/stats.h" // RCODE_TIMEOUT #include "netdutils/InternetAddresses.h" #include "thread_util.h" Loading include/netd_resolv/DnsProxyListener.h→DnsProxyListener.h +6 −7 Original line number Diff line number Diff line Loading @@ -17,11 +17,10 @@ #ifndef _DNSPROXYLISTENER_H__ #define _DNSPROXYLISTENER_H__ #include <netd_resolv/resolv.h> // android_net_context #include <sysutils/FrameworkCommand.h> #include <sysutils/FrameworkListener.h> #include "resolv.h" // android_net_context namespace android { namespace net { Loading DnsTlsDispatcher.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #define LOG_TAG "DnsTlsDispatcher" //#define LOG_NDEBUG 0 #include "netd_resolv/DnsTlsDispatcher.h" #include "netd_resolv/DnsTlsSocketFactory.h" #include "DnsTlsDispatcher.h" #include "DnsTlsSocketFactory.h" #include "log/log.h" Loading include/netd_resolv/DnsTlsDispatcher.h→DnsTlsDispatcher.h +12 −15 Original line number Diff line number Diff line Loading @@ -23,19 +23,15 @@ #include <mutex> #include <android-base/thread_annotations.h> #include <netdutils/Slice.h> #include "DnsTlsServer.h" #include "DnsTlsTransport.h" #include "IDnsTlsSocketFactory.h" #include "params.h" namespace android { namespace net { using netdutils::Slice; // This is a singleton class that manages the collection of active DnsTlsTransports. // Queries made here are dispatched to an existing or newly constructed DnsTlsTransport. class DnsTlsDispatcher { Loading @@ -44,8 +40,8 @@ class DnsTlsDispatcher { DnsTlsDispatcher(); // Constructor with dependency injection for testing. explicit DnsTlsDispatcher(std::unique_ptr<IDnsTlsSocketFactory> factory) : mFactory(std::move(factory)) {} explicit DnsTlsDispatcher(std::unique_ptr<IDnsTlsSocketFactory> factory) : mFactory(std::move(factory)) {} // Enqueues |query| for resolution via the given |tlsServers| on the // network indicated by |mark|; writes the response into |ans|, and stores Loading @@ -53,13 +49,15 @@ class DnsTlsDispatcher { // The order in which servers from |tlsServers| are queried may not be the // order passed in by the caller. DnsTlsTransport::Response query(const std::list<DnsTlsServer>& tlsServers, unsigned mark, const Slice query, const Slice ans, int * _Nonnull resplen); const netdutils::Slice query, const netdutils::Slice ans, int* _Nonnull resplen); // Given a |query|, sends it to the server on the network indicated by |mark|, // and writes the response into |ans|, and indicates // the number of bytes written in |resplen|. Returns a success or error code. DnsTlsTransport::Response query(const DnsTlsServer& server, unsigned mark, const Slice query, const Slice ans, int * _Nonnull resplen); const netdutils::Slice query, const netdutils::Slice ans, int* _Nonnull resplen); private: // This lock is static so that it can be used to annotate the Transport struct. Loading @@ -73,9 +71,8 @@ private: // Transport is a thin wrapper around DnsTlsTransport, adding reference counting and // usage monitoring so we can expire idle sessions from the cache. struct Transport { Transport(const DnsTlsServer& server, unsigned mark, IDnsTlsSocketFactory* _Nonnull factory) : transport(server, mark, factory) {} Transport(const DnsTlsServer& server, unsigned mark, IDnsTlsSocketFactory* _Nonnull factory) : transport(server, mark, factory) {} // DnsTlsTransport is thread-safe, so it doesn't need to be guarded. DnsTlsTransport transport; // This use counter and timestamp are used to ensure that only idle sessions are Loading @@ -99,8 +96,8 @@ private: void cleanup(std::chrono::time_point<std::chrono::steady_clock> now) REQUIRES(sLock); // Return a sorted list of DnsTlsServers in preference order. std::list<DnsTlsServer> getOrderedServerList( const std::list<DnsTlsServer> &tlsServers, unsigned mark) const; std::list<DnsTlsServer> getOrderedServerList(const std::list<DnsTlsServer>& tlsServers, unsigned mark) const; // Trivial factory for DnsTlsSockets. Dependency injection is only used for testing. std::unique_ptr<IDnsTlsSocketFactory> mFactory; Loading DnsTlsQueryMap.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -17,14 +17,15 @@ #define LOG_TAG "DnsTlsQueryMap" //#define LOG_NDEBUG 0 #include "netd_resolv/DnsTlsQueryMap.h" #include "DnsTlsQueryMap.h" #include "log/log.h" namespace android { namespace net { std::unique_ptr<DnsTlsQueryMap::QueryFuture> DnsTlsQueryMap::recordQuery(const Slice query) { std::unique_ptr<DnsTlsQueryMap::QueryFuture> DnsTlsQueryMap::recordQuery( const netdutils::Slice query) { std::lock_guard guard(mLock); // Store the query so it can be matched to the response or reissued. Loading Loading
DnsProxyListener.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -46,11 +46,11 @@ #include <sysutils/SocketClient.h> // TODO: Considering moving ResponseCode.h Stopwatch.h thread_util.h to libnetdutils. #include "DnsProxyListener.h" #include "NetdClient.h" // NETID_USE_LOCAL_NAMESERVERS #include "ResolverEventReporter.h" #include "ResponseCode.h" #include "Stopwatch.h" #include "netd_resolv/DnsProxyListener.h" #include "netd_resolv/ResolverEventReporter.h" #include "netd_resolv/stats.h" // RCODE_TIMEOUT #include "netdutils/InternetAddresses.h" #include "thread_util.h" Loading
include/netd_resolv/DnsProxyListener.h→DnsProxyListener.h +6 −7 Original line number Diff line number Diff line Loading @@ -17,11 +17,10 @@ #ifndef _DNSPROXYLISTENER_H__ #define _DNSPROXYLISTENER_H__ #include <netd_resolv/resolv.h> // android_net_context #include <sysutils/FrameworkCommand.h> #include <sysutils/FrameworkListener.h> #include "resolv.h" // android_net_context namespace android { namespace net { Loading
DnsTlsDispatcher.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #define LOG_TAG "DnsTlsDispatcher" //#define LOG_NDEBUG 0 #include "netd_resolv/DnsTlsDispatcher.h" #include "netd_resolv/DnsTlsSocketFactory.h" #include "DnsTlsDispatcher.h" #include "DnsTlsSocketFactory.h" #include "log/log.h" Loading
include/netd_resolv/DnsTlsDispatcher.h→DnsTlsDispatcher.h +12 −15 Original line number Diff line number Diff line Loading @@ -23,19 +23,15 @@ #include <mutex> #include <android-base/thread_annotations.h> #include <netdutils/Slice.h> #include "DnsTlsServer.h" #include "DnsTlsTransport.h" #include "IDnsTlsSocketFactory.h" #include "params.h" namespace android { namespace net { using netdutils::Slice; // This is a singleton class that manages the collection of active DnsTlsTransports. // Queries made here are dispatched to an existing or newly constructed DnsTlsTransport. class DnsTlsDispatcher { Loading @@ -44,8 +40,8 @@ class DnsTlsDispatcher { DnsTlsDispatcher(); // Constructor with dependency injection for testing. explicit DnsTlsDispatcher(std::unique_ptr<IDnsTlsSocketFactory> factory) : mFactory(std::move(factory)) {} explicit DnsTlsDispatcher(std::unique_ptr<IDnsTlsSocketFactory> factory) : mFactory(std::move(factory)) {} // Enqueues |query| for resolution via the given |tlsServers| on the // network indicated by |mark|; writes the response into |ans|, and stores Loading @@ -53,13 +49,15 @@ class DnsTlsDispatcher { // The order in which servers from |tlsServers| are queried may not be the // order passed in by the caller. DnsTlsTransport::Response query(const std::list<DnsTlsServer>& tlsServers, unsigned mark, const Slice query, const Slice ans, int * _Nonnull resplen); const netdutils::Slice query, const netdutils::Slice ans, int* _Nonnull resplen); // Given a |query|, sends it to the server on the network indicated by |mark|, // and writes the response into |ans|, and indicates // the number of bytes written in |resplen|. Returns a success or error code. DnsTlsTransport::Response query(const DnsTlsServer& server, unsigned mark, const Slice query, const Slice ans, int * _Nonnull resplen); const netdutils::Slice query, const netdutils::Slice ans, int* _Nonnull resplen); private: // This lock is static so that it can be used to annotate the Transport struct. Loading @@ -73,9 +71,8 @@ private: // Transport is a thin wrapper around DnsTlsTransport, adding reference counting and // usage monitoring so we can expire idle sessions from the cache. struct Transport { Transport(const DnsTlsServer& server, unsigned mark, IDnsTlsSocketFactory* _Nonnull factory) : transport(server, mark, factory) {} Transport(const DnsTlsServer& server, unsigned mark, IDnsTlsSocketFactory* _Nonnull factory) : transport(server, mark, factory) {} // DnsTlsTransport is thread-safe, so it doesn't need to be guarded. DnsTlsTransport transport; // This use counter and timestamp are used to ensure that only idle sessions are Loading @@ -99,8 +96,8 @@ private: void cleanup(std::chrono::time_point<std::chrono::steady_clock> now) REQUIRES(sLock); // Return a sorted list of DnsTlsServers in preference order. std::list<DnsTlsServer> getOrderedServerList( const std::list<DnsTlsServer> &tlsServers, unsigned mark) const; std::list<DnsTlsServer> getOrderedServerList(const std::list<DnsTlsServer>& tlsServers, unsigned mark) const; // Trivial factory for DnsTlsSockets. Dependency injection is only used for testing. std::unique_ptr<IDnsTlsSocketFactory> mFactory; Loading
DnsTlsQueryMap.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -17,14 +17,15 @@ #define LOG_TAG "DnsTlsQueryMap" //#define LOG_NDEBUG 0 #include "netd_resolv/DnsTlsQueryMap.h" #include "DnsTlsQueryMap.h" #include "log/log.h" namespace android { namespace net { std::unique_ptr<DnsTlsQueryMap::QueryFuture> DnsTlsQueryMap::recordQuery(const Slice query) { std::unique_ptr<DnsTlsQueryMap::QueryFuture> DnsTlsQueryMap::recordQuery( const netdutils::Slice query) { std::lock_guard guard(mLock); // Store the query so it can be matched to the response or reissued. Loading