Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaeeeb86 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Remove revalidationEnabled from DnsTlsDispatcher::Transport am: 0a86b0ed

parents 183a98da 0a86b0ed
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -308,12 +308,11 @@ DnsTlsDispatcher::Transport* DnsTlsDispatcher::addTransport(const DnsTlsServer&
    int queryTimeout = instance->getFlag("dot_query_timeout_ms", Transport::kDotQueryTimeoutMs);

    // Check and adjust the parameters if they are improperly set.
    bool revalidationEnabled = false;
    const bool isForOpportunisticMode = server.name.empty();
    if (triggerThr > 0 && unusableThr > 0 && isForOpportunisticMode) {
        revalidationEnabled = true;
    } else {
    if (triggerThr <= 0 || !isForOpportunisticMode) {
        triggerThr = -1;
    }
    if (unusableThr <= 0 || !isForOpportunisticMode) {
        unusableThr = -1;
    }
    if (queryTimeout < 0) {
@@ -322,9 +321,8 @@ DnsTlsDispatcher::Transport* DnsTlsDispatcher::addTransport(const DnsTlsServer&
        queryTimeout = 1000;
    }

    ret = new Transport(server, mark, netId, mFactory.get(), revalidationEnabled, triggerThr,
                        unusableThr, queryTimeout);
    LOG(DEBUG) << "Transport is initialized with { " << triggerThr << ", " << unusableThr << ", "
    ret = new Transport(server, mark, netId, mFactory.get(), triggerThr, unusableThr, queryTimeout);
    LOG(INFO) << "Transport is initialized with { " << triggerThr << ", " << unusableThr << ", "
              << queryTimeout << "ms }"
              << " for server { " << server.toIpString() << "/" << server.name << " }";

@@ -339,7 +337,7 @@ DnsTlsDispatcher::Transport* DnsTlsDispatcher::getTransport(const Key& key) {
}

bool DnsTlsDispatcher::Transport::checkRevalidationNecessary(DnsTlsTransport::Response code) {
    if (!revalidationEnabled) return false;
    if (triggerThreshold <= 0) return false;

    if (code == DnsTlsTransport::Response::network_error) {
        continuousfailureCount++;
@@ -355,7 +353,7 @@ bool DnsTlsDispatcher::Transport::checkRevalidationNecessary(DnsTlsTransport::Re
}

bool DnsTlsDispatcher::Transport::usable() const {
    if (!revalidationEnabled) return true;
    if (unusableThreshold <= 0) return true;

    return continuousfailureCount < unusableThreshold;
}
+11 −16
Original line number Diff line number Diff line
@@ -83,11 +83,10 @@ class DnsTlsDispatcher : public PrivateDnsValidationObserver {
    // usage monitoring so we can expire idle sessions from the cache.
    struct Transport {
        Transport(const DnsTlsServer& server, unsigned mark, unsigned netId,
                  IDnsTlsSocketFactory* _Nonnull factory, bool revalidationEnabled, int triggerThr,
                  int unusableThr, int timeout)
                  IDnsTlsSocketFactory* _Nonnull factory, int triggerThr, int unusableThr,
                  int timeout)
            : transport(server, mark, factory),
              mNetId(netId),
              revalidationEnabled(revalidationEnabled),
              triggerThreshold(triggerThr),
              unusableThreshold(unusableThr),
              mTimeout(timeout) {}
@@ -120,22 +119,18 @@ class DnsTlsDispatcher : public PrivateDnsValidationObserver {
        // Used to track if this Transport is usable.
        int continuousfailureCount GUARDED_BY(sLock) = 0;

        // Used to indicate whether DoT revalidation is enabled for this Transport.
        // The value is set to true only if:
        //    1. both triggerThreshold and unusableThreshold are  positive values.
        //    2. private DNS mode is opportunistic.
        const bool revalidationEnabled;

        // The number of continuous failures to trigger a validation. It takes effect when DoT
        // revalidation is on. If the value is not a positive value, DoT revalidation is disabled.
        // Note that it must be at least 10, or it breaks ConnectTlsServerTimeout_ConcurrentQueries
        // test.
        // If the number of continuous query timeouts reaches the threshold, mark the
        // server as unvalidated and trigger a validation.
        // If the value is not a positive value or private DNS mode is strict mode, no threshold is
        // set. Note that it must be at least 10, or it breaks
        // ConnectTlsServerTimeout_ConcurrentQueries test.
        const int triggerThreshold;

        // The threshold to determine if this Transport is considered unusable.
        // If continuousfailureCount reaches this value, this Transport is no longer used. It
        // takes effect when DoT revalidation is on. If the value is not a positive value, DoT
        // revalidation is disabled.
        // If the number of continuous query timeouts reaches the threshold, mark this
        // Transport as unusable. An unusable Transport won't be used anymore.
        // If the value is not a positive value or private DNS mode is strict mode, no threshold is
        // set.
        const int unusableThreshold;

        // The time to await a future (the result of a DNS request) from the DnsTlsTransport