Repository navigation
feat(nameresolving): add system DNS discovery - #3379
richard-ramos wants to merge 6 commits into
Conversation
a944e56 to
4322731
Compare
|
/review |
|
🔍 OpenCodeReview found 6 issue(s) in this PR.
Model: |
gmelodie
left a comment
There was a problem hiding this comment.
Nit: maybe have linux/windows specific behavior on respective files, and a top-level files calls the common code that chooses which (also, maybe have similar procs be called the same in both)
There was a problem hiding this comment.
there is to be key principle that Switch / SwitchBuilders are going to follow.
-
when it comes to managing lifecycle of components created by user, they should be one to manage it.
Switchshould just use the interface it needs. if library does not need lifecycle, for it's own purpose, than library should not care about what user does. library only cares about interface it needs and depends on. -
building anything with SwitchBuilder's
withXXXprocs should only set config (they build configuration), andbuildfinally builds everything into Switch. meaning user should not care about types. meaningwithNameResolver()will set some propertyuseNameResolverto true, then we create default name resolver. only if we want to allow custom implementations then there could be overloadedwithNameResolver(resolver: NameResolverInterface), but in this case they will manage it (start/stop).
| method start*(self: DnsResolver) {.gcsafe.} = | ||
| discard | ||
|
|
||
| method stop*(self: DnsResolver) {.async: (raises: []).} = | ||
| discard |
There was a problem hiding this comment.
why is strat/stop added when all code here never use it? all are discard / raiseAssert?
There was a problem hiding this comment.
@richard-ramos now i see that next PR in stack has start/stop. so likely all name resolver should have it...
also the way users should use this in SwitchBuilder should be via 2 procs
.withDNSNameResolver( nameServers: seq[TransportAddress] )
.withSystemNameResolver()
then each of these will create appropriate NameResolver and hook it to Switch. user shouldn't care about state (because it is created by SwithcBuilder).
NameResolver should be treated as a service. So that Switch reuses same logic for starting/stoping.
For example, all NameResolvers could have method .Service() that will provide accessor this name resolver from Service interface, and SwitchBuilder would do services.add(nameResolver.Service()) in addition to what it does in this pr
Summary
Add system DNS server discovery from
/etc/resolv.confon Unix and adapter configuration on Windows, with the existing public DNS servers as a fallback. Discovery skips unusable IPv6 link-local servers and down Windows adapters, and retries Windows adapter queries when the required buffer grows.Keep platform discovery in separate POSIX and Windows modules with a common
getNameServersentry point. The common module applies the fallback;dnsresolverre-exports the public discovery API.Usage
Construct a resolver explicitly with
DnsResolver.new(getSystemNameServers())and pass it towithNameResolver(resolver). The caller retains ownership.DnsResolverhas no persistent worker resources to start or stop.Stack
1 of 3 — merge in this order:
master.feat/system-name-resolver.feat/system-resolver-backend.Validation
References
Continues the DNS discovery work from #3114, originally authored by @nate-staked. Related: #3378.