swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

Custom DNS Server for ClientBootstrap

Open NghiaTranUIT opened this issue 3 years ago • 3 comments

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

  1. Use NIOHTTP1Client example at https://github.com/apple/swift-nio/blob/main/Sources/NIOHTTP1Client/main.swift
  2. 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

NghiaTranUIT avatar Dec 09 '21 01:12 NghiaTranUIT

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.

Lukasa avatar Dec 09 '21 09:12 Lukasa

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?

NghiaTranUIT avatar Dec 09 '21 09:12 NghiaTranUIT

It should do, yes.

Lukasa avatar Dec 09 '21 10:12 Lukasa