NEFilterSocketFlow remoteHostname property

Hi, i was wondering about the remoteHostname property of NEFilterSocketFlow that is available on macOS 11.0+. I have been doing some tests and I can never seem to get a value, it is always nil. I am looking at all flows from all apps. In what cases will this property show up?
Answered by DTS Engineer in 674548022
OK. If you get remoteEndpoint but not remoteHostname then there simply is no DNS name available. The doc comments associated with that property make it clear that this is a possibility:

Code Block
This property is only non-nil if the flow was created using Network.framework or NSURLSession.


Was the connection created by Network framework or NSURLSession (the latter includes Safari)?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Can you get things to a point where remoteEndpoint gets populated?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Yes, I can get the remoteEndpoint populated

Code Block
guard let socketFlow = flow as? NEFilterSocketFlow,
    let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,
    let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {
     return nil
}
     
if #available(macOS 11.0, *) {
if let hostname = socketFlow.remoteHostname {
     // Access hostname
    }
}

Accepted Answer
OK. If you get remoteEndpoint but not remoteHostname then there simply is no DNS name available. The doc comments associated with that property make it clear that this is a possibility:

Code Block
This property is only non-nil if the flow was created using Network.framework or NSURLSession.


Was the connection created by Network framework or NSURLSession (the latter includes Safari)?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
NEFilterSocketFlow remoteHostname property
 
 
Q