Post

Replies

Boosts

Views

Activity

Reply to Filtering Network Traffic sample not working with Safari for protocol TCP
Can you please check Apple sample, it has some issues I guess for Safari? It has some problem with object passing to remoteNetwork (NWHostEndpoint). The sample code you have shared here, it's working. Not working from Apple sample: let filterRules = ["0.0.0.0", "::"].map { address -> NEFilterRule in       let localNetwork = NWHostEndpoint(hostname: address, port: FilterDataProvider.localPort)       let inboundNetworkRule = NENetworkRule(remoteNetwork: nil,                           remotePrefix: 0,                           localNetwork: localNetwork,                           localPrefix: 0,                           protocol: .TCP,                           direction: .inbound)       return NEFilterRule(networkRule: inboundNetworkRule, action: .filterData) } Working code shared by you: let anyHostAndPortRule = NENetworkRule(       remoteNetwork: NWHostEndpoint(hostname: "0.0.0.0", port: "0"),       remotePrefix: 0,       localNetwork: nil,       localPrefix: 0,       protocol: .TCP,       direction: .any ) let filterRule = NEFilterRule(networkRule: anyHostAndPortRule, action: .filterData) May be we should fix this in Apple sample too... Also in call back handleNewFlow, remoteEndpoint or localEndpoint getting nil for Safari due to which it is returning from guard let condition. It is all working fine for other browsers like Google Chrome and Firefox with Apple Sample...
Aug ’20