我想知道如何管理连接到我的android热点的客户端的流量 . 我想要实现的两个主要功能是:

  • 拒绝/允许互联网访问客户端 .

  • 测量客户端消耗的数据量 .

我正在使用VpnService,它允许我将所有设备流量指向tun接口 . 我可以看到每个IP数据包通过来自我的设备的隧道,但经过多次尝试(很多天), I assumed that is impossible to see the android hotspot's traffic. 根据我的知识,这可能是因为android热点的层低于VpnService并且数据包是透明地送出隧道 . 我对吗 ?

VPN接口构建为:

mInterface = builder.setSession("MyVpnServiceSession")
        .addAddress("10.0.0.2", 32)
        .addRoute("0.0.0.0", 0)
        .establish()

请问,有人知道如何使用(或不使用)VpnService或其他解决方案来实现这些功能?

谢谢

PS . 回答 must work for NON-ROOTED devices