initUpstreams inits upstream-related config fields. TODO(d.kolyshev): Join errors.
( ctx context.Context, l *slog.Logger, config *proxy.Config, )
| 162 | // |
| 163 | // TODO(d.kolyshev): Join errors. |
| 164 | func (conf *configuration) initUpstreams( |
| 165 | ctx context.Context, |
| 166 | l *slog.Logger, |
| 167 | config *proxy.Config, |
| 168 | ) (err error) { |
| 169 | httpVersions := upstream.DefaultHTTPVersions |
| 170 | if conf.HTTP3 { |
| 171 | httpVersions = []upstream.HTTPVersion{ |
| 172 | upstream.HTTPVersion3, |
| 173 | upstream.HTTPVersion2, |
| 174 | upstream.HTTPVersion11, |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | timeout := time.Duration(conf.Timeout) |
| 179 | bootOpts := &upstream.Options{ |
| 180 | Logger: l, |
| 181 | HTTPVersions: httpVersions, |
| 182 | InsecureSkipVerify: conf.Insecure, |
| 183 | Timeout: timeout, |
| 184 | } |
| 185 | boot, err := initBootstrap(ctx, l, conf.BootstrapDNS, bootOpts) |
| 186 | if err != nil { |
| 187 | return fmt.Errorf("initializing bootstrap: %w", err) |
| 188 | } |
| 189 | |
| 190 | upsOpts := &upstream.Options{ |
| 191 | Logger: l, |
| 192 | HTTPVersions: httpVersions, |
| 193 | InsecureSkipVerify: conf.Insecure, |
| 194 | Bootstrap: boot, |
| 195 | Timeout: timeout, |
| 196 | } |
| 197 | upstreams := loadServersList(conf.Upstreams) |
| 198 | |
| 199 | config.UpstreamConfig, err = proxy.ParseUpstreamsConfig(upstreams, upsOpts) |
| 200 | if err != nil { |
| 201 | return fmt.Errorf("parsing upstreams configuration: %w", err) |
| 202 | } |
| 203 | |
| 204 | privateUpsOpts := &upstream.Options{ |
| 205 | Logger: l, |
| 206 | HTTPVersions: httpVersions, |
| 207 | Bootstrap: boot, |
| 208 | Timeout: min(defaultLocalTimeout, timeout), |
| 209 | } |
| 210 | privateUpstreams := loadServersList(conf.PrivateRDNSUpstreams) |
| 211 | |
| 212 | private, err := proxy.ParseUpstreamsConfig(privateUpstreams, privateUpsOpts) |
| 213 | if err != nil { |
| 214 | return fmt.Errorf("parsing private rdns upstreams configuration: %w", err) |
| 215 | } |
| 216 | |
| 217 | if !isEmpty(private) { |
| 218 | config.PrivateRDNSUpstreamConfig = private |
| 219 | } |
| 220 | |
| 221 | fallbackUpstreams := loadServersList(conf.Fallbacks) |
no test coverage detected