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)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.