setMinMaxTTL sets the TTL values of all records according to the proxy settings. r must not be nil.
(ctx context.Context, r *dns.Msg)
| 170 | // setMinMaxTTL sets the TTL values of all records according to the proxy |
| 171 | // settings. r must not be nil. |
| 172 | func (p *Proxy) setMinMaxTTL(ctx context.Context, r *dns.Msg) { |
| 173 | rrSets := container.KeyValues[string, []dns.RR]{{ |
| 174 | Key: "answer", |
| 175 | Value: r.Answer, |
| 176 | }, { |
| 177 | Key: "extra", |
| 178 | Value: r.Extra, |
| 179 | }, { |
| 180 | Key: "ns", |
| 181 | Value: r.Ns, |
| 182 | }} |
| 183 | |
| 184 | for _, rrSet := range rrSets { |
| 185 | for _, rr := range rrSet.Value { |
| 186 | original := rr.Header().Ttl |
| 187 | overridden := respectTTLOverrides(original, p.CacheMinTTL, p.CacheMaxTTL) |
| 188 | |
| 189 | if original == overridden { |
| 190 | continue |
| 191 | } |
| 192 | |
| 193 | optslog.Trace3( |
| 194 | ctx, |
| 195 | p.logger, |
| 196 | "ttl overwritten", |
| 197 | "section", rrSet.Key, |
| 198 | "old", original, |
| 199 | "new", overridden, |
| 200 | ) |
| 201 | rr.Header().Ttl = overridden |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // logDNSMessage logs the given DNS message. |
| 207 | func (p *Proxy) logDNSMessage(ctx context.Context, m *dns.Msg) { |
no test coverage detected