Network is not working when upload smb using NEFilterDataProvider in macOS

Network is not working when over 50MB size file upload smb using NEFilterDataProvider in macOS

The event received through NEFilterDataProvider is returned immediately without doing any other work.

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

        return .filterDataVerdict(withFilterInbound: true, peekInboundBytes: Int.max, filterOutbound: true, peekOutboundBytes: Int.max)
}

override func handleInboundData(from flow: NEFilterFlow, readBytesStartOffset offset: Int, readBytes: Data) -> NEFilterDataVerdict {
    guard let socketFlow = flow as? NEFilterSocketFlow,
          let auditToken = socketFlow.sourceAppAuditToken,
          let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,
          let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {
            return .allow()
    }
        return NEFilterDataVerdict(passBytes: readBytes.count, peekBytes: Int.max)
}

override func handleOutboundData(from flow: NEFilterFlow, readBytesStartOffset offset: Int, readBytes: Data) -> NEFilterDataVerdict {
    guard let socketFlow = flow as? NEFilterSocketFlow,
          let auditToken = socketFlow.sourceAppAuditToken,
          let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,
          let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {
        return .allow()
    }

    return NEFilterDataVerdict(passBytes: readBytes.count, peekBytes: Int.max)
}

override func handleInboundDataComplete(for flow: NEFilterFlow) -> NEFilterDataVerdict {
    guard let socketFlow = flow as? NEFilterSocketFlow,
          let auditToken = socketFlow.sourceAppAuditToken,
          let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,
          let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {
            return .allow()
        }
    return .allow()
}

override func handleOutboundDataComplete(for flow: NEFilterFlow) -> NEFilterDataVerdict {
    guard let socketFlow = flow as? NEFilterSocketFlow,
          let auditToken = socketFlow.sourceAppAuditToken,
          let remoteEndpoint = socketFlow.remoteEndpoint as? NWHostEndpoint,
          let localEndpoint = socketFlow.localEndpoint as? NWHostEndpoint else {
            return .allow()
    }
    return .allow()
}

how can i fix it?

The event received through NEFilterDataProvider is returned immediately without doing any other work.

I’m glad you tried that because it’s always the first debugging step I suggest (-:

If you change your filter to do nothing at all — that is, return .allow() from handleNewFlow(_:) in all cases — do it still reproduce the problem?

IMPORTANT I’m not suggesting this as a workaround, just another diagnostic test.

Share and Enjoy

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

thanks to reply

good working if returned .allow()

tested possible filtering smb peekBytes max value handleInboundData func return peekBytes: Int.max handleOutboundData func return peekBytes: 102264(1024 * 99 + 888)

if handleOutboundData peekBytes over 102264 not working

Network is not working when upload smb using NEFilterDataProvider in macOS
 
 
Q