How to get URL of the content filter network operation flow

Hi, I am using content filter network extension to allow/drop the network operations.

Here I want to get URL of the network flow. How can I achieve this? Please help me.

Below is sample content filter NE handleNewFlow().

Code Block
 override func handleNewFlow(_ flow: NEFilterFlow) -> NEFilterNewFlowVerdict {    
guard let socketFlow = flow as? NEFilterSocketFlow,      
let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,      
let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {       
 return .allow()    
}      
 }

Hi,
I able to the URL for safari browser but not for Chrome browser with https://developer.apple.com/forums/thread/655731?answerId=623996022#623996022 changes.

How to get URL for Chrome browser along with Safari? Please help me.
Hi,
I able to the URL for safari browser but not for Chrome browser with https://developer.apple.com/forums/thread/655731?answerId=623996022#623996022 changes. 

How to get URL for Chrome browser also? Please help me.
Right, so using a technique like:

Code Block swift
let url = flow.url?.absoluteString ?? "No URL"


will provide you a hostname for flows that originate from apps that provide hostnames, like Safari. However, if you are receiving IPs, then this what you have to work with in this context. So, you can try and filter upon bundle id and then determine if the flow is originating from an app within an address range that you care about, or if you need the hostname then you would have to do resolution manually to get the hostname.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
How to get URL of the content filter network operation flow
 
 
Q