1

我正在尝试使用 VpnService 编写一个 VPN 应用程序。我基于示例 ToyVpn 启动了我的应用程序。它似乎工作正常,但我想知道当我单击连接时是否有办法摆脱弹出对话框。我希望我可以单击“连接”,它会启动而无需单击“我信任此应用程序...”复选框和“确定”。

谢谢。

4

1 回答 1

1

I don't think it's possible. They seem to be very careful about this class. If you take a look at the documentation you can see it says:

Letting applications intercept packets raises huge security concerns. A VPN application can easily break the network. Besides, two of them may conflict with each other. The system takes several actions to address these issues. Here are some key points:

  • User action is required to create a VPN connection. [emphasis mine]
  • There can be only one VPN connection running at the same time. The existing interface is deactivated when a new one is created.
  • A system-managed notification is shown during the lifetime of a VPN connection.
  • A system-managed dialog gives the information of the current VPN connection. It also provides a button to disconnect. The network is restored automatically when the file descriptor is closed. It also covers the cases when a VPN application is crashed or killed by the system.

Since it says that user action is required to create the VPN connection, I assume they mean this is something you cannot control yourself.

于 2012-05-30T14:01:19.120 回答