Proxy combines the proxy server state and configuration. TODO(a.garipov): Consider extracting conf blocks for better fieldalignment.
| 62 | // |
| 63 | // TODO(a.garipov): Consider extracting conf blocks for better fieldalignment. |
| 64 | type Proxy struct { |
| 65 | // requestsSema limits the number of simultaneous requests. |
| 66 | // |
| 67 | // TODO(a.garipov): Currently we have to pass this exact semaphore to the |
| 68 | // workers, to prevent races on restart. In the future we will need a |
| 69 | // better restarting mechanism that completely prevents such invalid states. |
| 70 | // |
| 71 | // See also: https://github.com/AdguardTeam/AdGuardHome/issues/2242. |
| 72 | requestsSema syncutil.Semaphore |
| 73 | |
| 74 | // privateNets determines if the requested address and the client address |
| 75 | // are private. |
| 76 | privateNets netutil.SubnetSet |
| 77 | |
| 78 | // time provides the current time. |
| 79 | // |
| 80 | // TODO(e.burkov): Consider configuring it. |
| 81 | time timeutil.Clock |
| 82 | |
| 83 | // randSrc provides the source of randomness. |
| 84 | // |
| 85 | // TODO(e.burkov): Consider configuring it. |
| 86 | randSrc rand.Source |
| 87 | |
| 88 | // messages constructs DNS messages. |
| 89 | messages MessageConstructor |
| 90 | |
| 91 | // requestHandler handles the DNS request. It is never nil. |
| 92 | requestHandler Handler |
| 93 | |
| 94 | // dnsCryptServers serve DNSCrypt queries. |
| 95 | dnsCryptServers []*dnscrypt.Server |
| 96 | |
| 97 | // logger is used for logging in the proxy service. It is never nil. |
| 98 | logger *slog.Logger |
| 99 | |
| 100 | // fastestAddr finds the fastest IP address for the resolved domain. |
| 101 | fastestAddr *fastip.FastestAddr |
| 102 | |
| 103 | // cache is used to cache requests. It is disabled if nil. |
| 104 | // |
| 105 | // TODO(d.kolyshev): Move this cache to [Proxy.UpstreamConfig] field. |
| 106 | cache *cache |
| 107 | |
| 108 | // shortFlighter is used to resolve the expired cached requests without |
| 109 | // repetitions. |
| 110 | shortFlighter *optimisticResolver |
| 111 | |
| 112 | // recDetector detects recursive requests that may appear when resolving |
| 113 | // requests for private addresses. |
| 114 | recDetector *recursionDetector |
| 115 | |
| 116 | // reqCtx is a constructor for the request contexts. It is never nil. |
| 117 | reqCtx contextutil.Constructor |
| 118 | |
| 119 | // pendingRequests is a storage for duplicated requests. It is used to |
| 120 | // prevent sending the same request to upstreams multiple times. |
| 121 | pendingRequests pendingRequests |
nothing calls this directly
no outgoing calls
no test coverage detected