If someone could provide some example code that would handle the DNS requests in the same way in the case that I did not have my DNS requests go through NEDNSProxyProvider that would be wonderful.
For a
NEDNSProxyProvider there is no selective proxying. If you are claiming the flow by returning true, then you will need to proxy the flow. If you are returning false then the flow will be discarded.
I am actually in the process of formally documenting the flow copying process right now, but a brief overview is:
1) Decide if your provider is handling the flow. Return true or false.
2) If the provider is handling the flow then the a remote connection needs to be setup to handle outbound data. In this case I will use
NWConnection as an example.
3) Once the remote side of the connection goes into the ready state, it's time to open the local flow to handle the inbound data. In this case it would be for
NEAppProxyUDPFlow.
4) Then an inbound copier needs to be created to read from the remote side of the connection and write to the local side on the connection.
5) Then an outbound copier needs to be created to read from the local side of the connection and write to the remote side of the connection.
6) Implementing Flow Control is the next thing to consider during this process to ensure that your provider does not become overloaded and buffer too much data. A great rule of thumb is to not read again before the write has taken place.
7) Last but not least, be sure to mark the local flows as closed and cancel the remote side of the connection after complete.
For further information on the read/write APIs in the flow copying process see
NEAppProxyUDPFlow and
NWConnection.Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com