0

**Hi, I have configured NEDNSProxyProvider I am getting proper calls in following function but on device no website is getting opened. **

func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {

       var host = ""
       var port = ""
       var blocked:Bool = false
       var endpoint = NWHostEndpoint.init()
       NSLog("DNSProxyProvider handleNewFlow : ")
       if let tcpFlow = flow as? NEAppProxyTCPFlow {
           host = (tcpFlow.remoteEndpoint as! NWHostEndpoint).hostname
           port = (tcpFlow.remoteEndpoint as! NWHostEndpoint).port
           NSLog("DNSProxyProvider TCP HOST : \(host)")
           NSLog("DNSProxyProvider TCP PORT : \(port)")
           NSLog("DNSProxyProvider TCP debugDescription : \(tcpFlow.debugDescription)")
           if let ep = tcpFlow.remoteEndpoint as? NWHostEndpoint{
               endpoint = ep
           }
       } else if let udpFlow = flow as? NEAppProxyUDPFlow {
           host = (udpFlow.localEndpoint as! NWHostEndpoint).hostname
           port = (udpFlow.localEndpoint as! NWHostEndpoint).port

           NSLog("DNSProxyProvider UDP HOST : \(host)")
           NSLog("DNSProxyProvider UDP PORT : \(port)")
           NSLog("DNSProxyProvider UDP debugDescription : \(String(describing: udpFlow.localEndpoint))")
           if let ep = udpFlow.localEndpoint as? NWHostEndpoint{
               endpoint = ep
           }

       }

  //*


       flow.open(withLocalEndpoint: endpoint, completionHandler: { (error) in
       if error != nil  {
           NSLog("DNSProxyProvider: open error: \(error.debugDescription)")

           }

       });

// */
       return true
   }
Bhatti
  • 41
  • 7
  • I was able to resolve this, because I had to provide IPs for dns packets for which I am returning true from handleNewFlow function – Bhatti Jun 18 '20 at 07:56
  • Hi @Bhatti if you don't mind could you please share the code to handle the flow and pass in our DNS, my handleNewFlow() method is being called but I don't know how to handle it and what to do. Thanks in advance. – superGokuN Jun 28 '21 at 05:58

1 Answers1

0

I was able to resolve this, because I had to provide IPs for dns packets for which I am returning true from handleNewFlow function. here is the basic flow

call open on flowReference check error, if error is nil call readDatagrams send datagrams to your server to get them resolved call writeDatagrams with retuned modified datagrams from server then check if more datagrams exists by calling readDatagrams again or close the handle

Bhatti
  • 41
  • 7