Local Proxy Server Running On Android Device

孤者浪人 提交于 2019-12-20 14:16:13

问题


I am trying to write a http proxy server that would run on the device itself. In fact, need to find a way to capture the outbound http traffic generated by the device.

The code I have so far is compiling OK, it is based on the code found here: http://www.jtmelton.com/2007/11/27/a-simple-multi-threaded-java-http-proxy-server/

The problem is that the http request to the actual server would block and never return .

Is there a better way to write such a service without rooting the device?


回答1:


You should check SandroProxy. Can caputre traffic on non rooted device if os proxy settings are used, or with iptables rules on rooted one. Traffic is stored it in local sqlite database. Captured data can be also examined by chrome devtools. To capture traffic in your app you should check source code for plugins. It has all the code for iptables redirections and proper settings.

Check out the wiki link on google source code HowToInterceptTrafficOnMyOwn

http://code.google.com/p/sandrop/wiki/HowToInterceptTrafficOnMyOwn

btw: send by sandroproxy support :)




回答2:


I've been using a piece of software called proxydroid to use my device as a proxy server, and its the only one I've found which doesn't require root. I'm not sure if it will be any help to you, but its an open source project and the code can be found here:

https://github.com/madeye/proxydroid

I have noticed that the application will freeze after a while, or if a large number of request are sent at once, but I've not had chance to find out why this is happening.




回答3:


Forget about setting proxy, use Facebook Stetho library (http://facebook.github.io/stetho/) to review all http requests and responses from emulator/device



来源:https://stackoverflow.com/questions/19082179/local-proxy-server-running-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!