MCPcopy Index your code
hub / github.com/AdguardTeam/dnsproxy / parse

Method parse

proxy/upstreams.go:175–193  ·  view source on GitHub ↗

parse returns UpstreamConfig and error if upstreams configuration is invalid.

(lines []string)

Source from the content-addressed store, hash-verified

173
174// parse returns UpstreamConfig and error if upstreams configuration is invalid.
175func (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.
196func (p *configParser) parseLine(idx int, confLine string) (err error) {

Callers 1

ParseUpstreamsConfigFunction · 0.95

Calls 1

parseLineMethod · 0.95

Tested by

no test coverage detected