OneXray 将支持通过广播指令开关 VPN,默认关闭
在 OneXray #205(功能请求,已关闭)中,作者 yiguodev 说明 Android 广播自动化已在下一个版本实现,默认关闭:需在「Advanced → VPN Tunnel → Android system VPN → External automation」开启并复制生成的 token。他给出的显式广播参数为包名 net.yuandev.onexray、接收类 VpnAutomationReceiver、START_VPN 与 STOP_VPN 两个 action,以及名为 token 的 String 字段;两个 action 都需携带 token。在有保存的配置和必要权限时,启停会经原生 VPN 服务完成,无需打开应用;他提醒先在应用内完成授权并连接一次,更换服务器或路由后要在应用内重新连接,自动化才会使用新生成的配置。当前实现只支持启停,不能通过 intent 参数选择具体服务器;缺少配置或权限时给出失败通知,而不是自动打开应用。他用 Android API 37 上的 Automate 1.53.2 验证了后台启停与 token 撤销。该仓库最新正式版为 9 月 28 日发布的 v26.9.5,早于这条说明,功能尚未随正式版发出。
作者原文@yiguodevThanks for the suggestion! Android broadcast automation has been implemented for the next release.
The feature is disabled by default. Enable it under Advanced → VPN Tunnel → Android system VPN → External automation, then copy the generated token.
Send an explicit broadcast with these parameters:
Package: net.yuandev.onexray Class: net.yuandev.onexray.automation.VpnAutomationReceiver Start action: net.yuandev.onexray.action.START_VPN Stop action: net.yuandev.onexray.action.STOP_VPN Extra: token (String) = your copied tokenBoth actions require the token. With a saved configuration and the necessary permissions, they run through the native VPN service without opening the app. Complete authorization and connect once in OneXray first. After changing servers or routing, connect from the app again so automation uses the newly generated configuration.
This initial implementation supports start/stop only; selecting a specific server through intent parameters is not included. Missing configuration or permissions produce a failure notification rather than automatically opening the app.
We verified background start/stop and token revocation with Automate 1.53.2 on Android API 37. Closing this as implemented; it will be available in the next release.