问题描述
我得到了这个疯狂的想法,我不知道是可能或不...我想要做的是建立了我的手机作为无线接入点,然后让人们连接到它,但处理所有传入的HTTP流量我自己。
I got this crazy idea that I don't know is possible or not... what I want to do is set up my phone as wifi access point, then allow people to connect to it, but handle all incoming http traffic myself.
所以:
-
手机的WiFi接入点模式;开放的wifi网络。(这个珍闻工作 - 是的,我知道这不是官方支持的,但后来我无意分发投放公开市场还是等这个程序,它可以在我的手机和这是够好对我来说)
phone wifi in access point mode; open wifi network (this tidbit works - yes I know it's not officially supported but then I have no intention to distribute put this app on the open market or so, it works on my phone and that's good enough for me).
客户端可以连接到手机(例如:我的笔记本电脑:这也适用)
client can connect to the phone (e.g. my laptop: this also works).
当客户端试图打开HTTP连接到任何随机服务器,这必须由我的应用程序截获,并通过本地Web服务器处理。这是我卡上的点。
when client tries to open an http connection to any random server, this has to be intercepted by my app and handled by a local web server. This is the point that I'm stuck on.
Web服务器部分应该不会太难;有可用(开放源代码)的Web服务器。但得到的流量到Web服务器,有问题。
The web server part shouldn't be too hard; there are (open-source) web servers available. But getting the traffic to that web server, there is the problem.
我以后的行为有点类似于连接到一些开放热点时,你会得到什么,喜欢酒店的热点,那那么您重定向到一个登录页面。连接请求(我怀疑我要看看DNS请求?)这个拦截是我后。
The behaviour I'm after is a bit similar to what you get when connecting to some open hotspot, like hotel hotspots, that then redirect you to a login page. This intercepting of the connection request (I suspect I have to look at DNS requests?) is what I'm after.
我看到一个应用程序,是这样做的,但他们需要植根电话。我希望能找到一个方法来做到这一点不生根的电话。
I have seen an app that is doing this but they require the phone to be rooted. I'm hoping to find a way to do it without rooting the phone.
推荐答案
WiFi热点通常会使用iptables来80/443流量重定向端口连接到本地Web服务器。
Wifi hotspots would usually use IPTables to redirect port 80/443 traffic to a local web server.
我已经在端口3128上运行的鱿鱼在Linux机器上,在过去,然后送到所有端口80/443流量鱿鱼。然后我用鱿鱼重定向任何URL是我没有明确允许本地Web服务器。
I have run squid on linux machines in the past on port 3128, then sent all port 80/443 traffic to squid. Then I used squid redirect any url that I didnt explicitly allow to a local web server.
iptables的上植根Android设备只能访问虽然。
我怀疑有在Android很多代理服务器,所以你就必须发送HTTP流量代理服务器通过网络连接。
And I doubt there are many proxy servers available on android, so you would have to send HTTP traffic to a proxy server over the network connection.
这篇关于使用Android手机的WIFI网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!