Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ?
I'm trying to write a VpnService based ad-blocker on android.
I've found a few open source projects using VpnService (NetGuard, NetKnight), so I could learn from them.
And I known OkHTTP could make a request using just url and method, which means it could understood some thing like GET http://stackoverflow.com Http/1.1, and transform it to a real TCP/IP based request, even decode response. So I tried to read some source code of Okio to found out what it does, but failed.
So I was wondering if I could use Okio's component to decode/encode TCP/IP packets?
Yes. Create a Socket using the normal APIs, then use
Okio.source(Socket)andOkio.sink(Socket)to get streams from it. Also don't forget that you can buffer these streams withOkio.buffer().