How to block request use swiftNIO?

I have created a local VPN tunnel using NEPacketTunnelProvider and SwiftNIO. How should I use the ConnectHandler for content filtering? Should I handle this logic in the func channelRead(context: ChannelHandlerContext, data: NIOAny) ?

Generally yes, that would be right. What content filtering are you trying to achieve?

I want to block ads

Assuming you're happy with domain level blocking then yes, you can use the existing connect handler and block requests in that function.

If you're looking for something more detailed, such as the request path, this gets a lot harder as you need to MITM the connection itself.