parse returns UpstreamConfig and error if upstreams configuration is invalid.
(lines []string)
| 173 | |
| 174 | // parse returns UpstreamConfig and error if upstreams configuration is invalid. |
| 175 | func (p *configParser) parse(lines []string) (c *UpstreamConfig, err error) { |
| 176 | var errs []error |
| 177 | for i, l := range lines { |
| 178 | if err = p.parseLine(i, l); err != nil { |
| 179 | errs = append(errs, &ParseError{Idx: i, err: err}) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // Rewrite upstreams for wildcard subdomains to remove upper level domains |
| 184 | // specifications. |
| 185 | maps.Copy(p.domainReservedUpstreams, p.subdomainsOnlyUpstreams) |
| 186 | |
| 187 | return &UpstreamConfig{ |
| 188 | Upstreams: p.upstreams, |
| 189 | DomainReservedUpstreams: p.domainReservedUpstreams, |
| 190 | SpecifiedDomainUpstreams: p.specifiedDomainUpstreams, |
| 191 | SubdomainExclusions: p.subdomainsOnlyExclusions, |
| 192 | }, errors.Join(errs...) |
| 193 | } |
| 194 | |
| 195 | // parseLine returns an error if upstream configuration line is invalid. |
| 196 | func (p *configParser) parseLine(idx int, confLine string) (err error) { |
no test coverage detected