Unable to get local ip and port correctly

Why is the local ip and port obtained through localEndpoint 0.0.0.0:0 when handlenewflow (outbound flow), the remote ip and port are normal, and the local/remote ip and port for the inbound flow are normal.

 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()
        }

        os_log("Got a new flow with local endpoint %@, remote endpoint %@", localEndpoint, remoteEndpoint)

        let flowInfo = [
            FlowInfoKey.localPort.rawValue: localEndpoint.port,
            FlowInfoKey.remoteAddress.rawValue: remoteEndpoint.hostname
        ]
        
        let flowInfo2 = [
            FlowInfoKey2.localAddress.rawValue: localEndpoint.hostname,
            FlowInfoKey2.remotePort.rawValue: remoteEndpoint.port
        ]
……………………
}
Answered by DTS Engineer in 761529022

Last I checked we don’t bind the flow to a local IP and port until some data moves over it.

Share and Enjoy

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

Accepted Answer

Last I checked we don’t bind the flow to a local IP and port until some data moves over it.

Share and Enjoy

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

Unable to get local ip and port correctly
 
 
Q