Post

Replies

Boosts

Views

Activity

Reply to How to get inBytes & outBytes as part of Content Filter simple firewall extension
I got some help on NEFilterReport from https://developer.apple.com/forums/thread/665784?answerId=645327022#645327022. Looks like, able to get in & out Bytes after allowing/dropping the connection. I want to get this data before allowing/dropping the connection, So that I can send in & out bytes to my custom API to evaluate the rule & to prepare the report and then decide allow/drop. So, Is it possible to get the in & out Bytes data before allow/drop the connection? Thanks.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’20
Reply to How to get inBytes & outBytes as part of Content Filter simple firewall extension
Looks like https://developer.apple.com/documentation/networkextension/nefilterreport gives read & write Bytes. But how to use this to get bytesInboundCount & bytesOutboundCount? Please help.   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()     		} 		DispatchQueue.global(qos: .default).async {				  				     		var bytes :Int32 = 0          				if socketFlow.direction.rawValue == 1 {         						// bytes = inBytes       				}else {         						//bytes = outBytes       				} 				 				let userVerdict: NEFilterNewFlowVerdict 				var error = customAPIToDecideAllowOrDrop() 				userVerdict = error == 0 ? .allow() : .drop() 				 				self.resumeFlow(flow, with: userVerdict)		 		}		 		return .pause() }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’20