HN 用户提问:如何绕过强制门户网站 Webview 的限制?
1 分•作者: remohexa•4 个月前
我搭建了一个完全运行在树莓派热点上的本地媒体分享网站。主要思路是利用安卓的强制门户机制。
当安卓设备连接到网络时,它会检查一个特定的URL(connectivitycheck.gstatic.com/generate_204)。如果响应是204,则不会触发任何操作,但如果收到其他响应(如302),它将在沙盒化的webview中打开该页面,并遵循“Location”标头(如果存在)。
我使用dnsmasq来欺骗该URL并返回所需的响应代码。令我惊讶的是,它真的奏效了,但后来我才发现强制门户默认是被沙盒化的。整个网站运行正常,唯一缺少的功能是无法选择任何类型的文件。
我很好奇这里是否有人之前尝试过强制门户。有没有办法打开用户的浏览器?我觉得如果我提示他们用浏览器打开一个URL,可能会失去用户的兴趣。
查看原文
I built a local media sharing website that runs entirely on a Pi hotspot. The main idea was to rely on Android's captive portal mechanism.<p>When an Android device connects to a network, it checks a specific URL (connectivitycheck.gstatic.com/generate_204). If the response is 204, it won't trigger anything, but if it receives something else (like 302), it will open that page inside a sandboxed webview and follow the "Location" header if it is present.<p>I used dnsmasq to spoof that URL and return the required response code. To my surprise, it actually worked, but only then did I discover that captive portals are sandboxed by default. The whole website is working as it should, with the only missing feature being that I can't select any type of files.<p>I'm curious if anyone here has ever experimented with captive portals before. Is there any way to open the user's browser? I feel like I might lose the user interest if I prompt them with a url to open in their browser.