I'm implementing a NEDNSProxyProvider on macOS 15.x and macOS 26.x. The flow works correctly up to the last step — returning the DNS response to the client via writeDatagrams.
Environment:
macOS 15.x, 26.x
Xcode 26.x
NEDNSProxyProvider with NEAppProxyUDPFlow
What I'm doing:
override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {
guard let udpFlow = flow as? NEAppProxyUDPFlow else { return false }
udpFlow.readDatagrams { datagrams, endpoints, error in
// 1. Read DNS request from client
// 2. Forward to upstream DNS server via TCP
// 3. Receive response from upstream
// 4. Try to return response to client:
udpFlow.writeDatagrams([responseData], sentBy: [endpoints.first!]) { error in
// Always fails: "The datagram was too large"
// responseData is 50-200 bytes — well within UDP limits
}
}
return true
}
Investigation:
I added logging to check the type of endpoints.first :
// On macOS 15.0 and 26.3.1:
// type(of: endpoints.first) → NWAddressEndpoint
// Not NWHostEndpoint as expected
On both macOS 15.4 and 26.3.1, readDatagrams returns [NWEndpoint] where each endpoint appears to be NWAddressEndpoint — a type that is not publicly documented.
When I try to create NWHostEndpoint manually from hostname and port, and pass it to writeDatagrams, the error "The datagram was too large" still occurs in some cases.
Questions:
What is the correct endpoint type to pass to writeDatagrams on macOS 15.x, 26.x?
Should we pass the exact same NWEndpoint objects returned by readDatagrams, or create new ones?
NWEndpoint, NWHostEndpoint, and writeDatagrams are all deprecated in macOS 15. Is there a replacement API for NEAppProxyUDPFlow that works with nw_endpoint_t from the Network framework?
Is the error "The datagram was too large" actually about the endpoint type rather than the data size?
Any guidance would be appreciated. :-))
5
0
91