MCPcopy
hub / github.com/AdguardTeam/dnsproxy / parseLine

Method parseLine

proxy/upstreams.go:196–222  ·  view source on GitHub ↗

parseLine returns an error if upstream configuration line is invalid.

(idx int, confLine string)

Source from the content-addressed store, hash-verified

194
195// parseLine returns an error if upstream configuration line is invalid.
196func (p *configParser) parseLine(idx int, confLine string) (err error) {
197 if len(confLine) == 0 || confLine[0] == '#' {
198 return nil
199 }
200
201 upstreams, domains, err := splitConfigLine(confLine)
202 if err != nil {
203 // Don't wrap the error since it's informative enough as is.
204 return err
205 }
206
207 if upstreams[0] == "#" && len(domains) > 0 {
208 p.excludeFromReserved(domains)
209
210 return nil
211 }
212
213 for _, u := range upstreams {
214 err = p.specifyUpstream(domains, u, idx)
215 if err != nil {
216 // Don't wrap the error since it's informative enough as is.
217 return err
218 }
219 }
220
221 return nil
222}
223
224// splitConfigLine parses upstream configuration line and returns list upstream
225// addresses (one or many), list of domains for which this upstream is reserved

Callers 1

parseMethod · 0.95

Calls 3

excludeFromReservedMethod · 0.95
specifyUpstreamMethod · 0.95
splitConfigLineFunction · 0.85

Tested by

no test coverage detected