swift-nio
swift-nio copied to clipboard
Custom DNS Server for ClientBootstrap
Expected behavior
I expect that there is an API that I can configure my DNS Server of ClientBootstrap.
Actual behavior
I don't know how to manually configure the DNS Server of ClientBootstrap to 8.8.8.8
Steps to reproduce
- Use NIOHTTP1Client example at https://github.com/apple/swift-nio/blob/main/Sources/NIOHTTP1Client/main.swift
- Start the server with any Host & Port
If possible, minimal yet complete reproducer code (or URL to code)
Try to provide 8.8.8.8 as a custom DNS server.
SwiftNIO version/commit hash
SwiftNIO 2.35.0
Swift & OS version (output of swift --version && uname -a)
swift-driver version: 1.26.9 Apple Swift version 5.5.1 (swiftlang-1300.0.31.4 clang-1300.0.29.6)
Target: arm64-apple-macosx11.0
Darwin Nghias-Mac-mini.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:38 PDT 2021; root:xnu-7195.141.8~1/RELEASE_ARM64_T8101 arm64
Thanks for filing this issue!
Unfortunately, currently we only support the system resolver, as we delegate all our DNS resolution to libc via getaddrinfo. While in principle we could add this functionality, to do it would require either adding a dependency on a 3rd-party DNS library or providing an entirely custom DNS stack, neither of which is a small scale project.
Thanks, @Lukasa I understand 👍
If I manually set DNS in Network.pref -> Wifi -> Advanced -> DNS to 8.8.8 and run ClientBootstrap on my machine, does getaddrinfo use 8.8.8.8 as a custom DNS?
It should do, yes.