From d4e4083d401524e91d72fb55ad4407b107a58037 Mon Sep 17 00:00:00 2001 From: rong_zhichao Date: Mon, 30 Jun 2025 14:01:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Evpn=20=E5=92=8C=20vpnext?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.net.vpn.d.ts | 85 ++++++++++++++++++++++++++++++++- api/@ohos.net.vpnExtension.d.ts | 32 +++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/api/@ohos.net.vpn.d.ts b/api/@ohos.net.vpn.d.ts index 13af99c3c8..da82310da2 100644 --- a/api/@ohos.net.vpn.d.ts +++ b/api/@ohos.net.vpn.d.ts @@ -82,6 +82,23 @@ declare namespace vpn { */ function on(type: 'connect', callback: Callback): void; + /** + * Subscribes to vpn connect state changes. + * @permission ohos.permission.MANAGE_VPN + * @param { 'connectMulti' } type - Indicates multi vpn connect state changes. + * @param { Callback } callback - The callback of the multi vpn connect state. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function on(type: 'connectMulti', callback: Callback): void; + /** * Unsubscribes from vpn connect state changes. * @permission ohos.permission.MANAGE_VPN @@ -99,6 +116,23 @@ declare namespace vpn { */ function off(type: 'connect', callback?: Callback): void; + /** + * Unsubscribes from vpn connect state changes. + * @permission ohos.permission.MANAGE_VPN + * @param { 'connectMulti' } type - Indicates multi vpn connect state changes. + * @param { Callback } callback - The callback of the multi vpn connect state. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function off(type: 'connectMulti', callback?: Callback): void; + /** * Add a system VPN network configuration. * @permission ohos.permission.MANAGE_VPN @@ -178,6 +212,20 @@ declare namespace vpn { */ function getConnectedSysVpnConfig(): Promise; + /** + * Get the connected VPN App Info. + * @permission ohos.permission.MANAGE_VPN + * @returns { Promise> } The promise returned by the connected VPN App Info. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function getConnectedVpnAppInfo(): Promise>; + /** * Defines a VPN connection. * @interface VpnConnection @@ -482,6 +530,33 @@ declare namespace vpn { * @since 12 */ forwardingRoutes?: string; + + /** + * The array of addresses for remote server. + * @type {?Array} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + remoteAddresses?: Array; + + /** + * The p12 cert password for the ipsec VPN network. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + pkcs12Password?: string; + + /** + * The p12 cert data for the ipsec VPN network. + * @type {?Uint8Array} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + pkcs12FileData?: Uint8Array; } /** @@ -961,7 +1036,15 @@ declare namespace vpn { * @systemapi Hide this for inner system use. * @since 12 */ - OPENVPN = 9 + OPENVPN = 9, + + /** + * The type for the l2tp network. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + L2TP = 10 } } export default vpn; diff --git a/api/@ohos.net.vpnExtension.d.ts b/api/@ohos.net.vpnExtension.d.ts index 6b13b033f7..a4b35e1633 100644 --- a/api/@ohos.net.vpnExtension.d.ts +++ b/api/@ohos.net.vpnExtension.d.ts @@ -175,6 +175,17 @@ declare namespace vpnExtension { * @since 11 */ create(config: VpnConfig): Promise; + + /** + * generate vpn id. + * + * @returns { Promise } The promise returns vpn id. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + generateVpnId(): Promise; /** * Protect a socket from VPN connections. After protecting, data sent through this socket will go directly to the @@ -203,6 +214,19 @@ declare namespace vpnExtension { * @since 11 */ destroy(): Promise; + + /** + * Destroy the VPN network. + * + * @param { string } vpnId - vpn id. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + destroy(vpnId: string): Promise; } /** @@ -213,6 +237,14 @@ declare namespace vpnExtension { * @since 11 */ export interface VpnConfig { + /** + * The uuid for the VPN network. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + vpnId?: string; + /** * The array of addresses for VPN interface. * -- Gitee From 5187a1b718d69a95f0a468182e81ec71cf50d4b9 Mon Sep 17 00:00:00 2001 From: rong_zhichao Date: Tue, 1 Jul 2025 19:44:59 +0800 Subject: [PATCH 2/2] modify Signed-off-by: rong_zhichao --- api/@ohos.net.vpn.d.ts | 17 ++++++++--------- api/@ohos.net.vpnExtension.d.ts | 8 -------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/api/@ohos.net.vpn.d.ts b/api/@ohos.net.vpn.d.ts index da82310da2..e33d963554 100644 --- a/api/@ohos.net.vpn.d.ts +++ b/api/@ohos.net.vpn.d.ts @@ -349,6 +349,14 @@ declare namespace vpn { * @since 10 */ export interface VpnConfig { + /** + * The uuid for the VPN network. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + vpnId?: string; + /** * The array of addresses for VPN interface. * @type {Array} @@ -458,15 +466,6 @@ declare namespace vpn { * @since 12 */ export interface SysVpnConfig extends VpnConfig { - /** - * The uuid for the VPN network. - * @type {?string} - * @syscap SystemCapability.Communication.NetManager.Vpn - * @systemapi Hide this for inner system use. - * @since 12 - */ - vpnId?: string; - /** * The name for the VPN network. * @type {?string} diff --git a/api/@ohos.net.vpnExtension.d.ts b/api/@ohos.net.vpnExtension.d.ts index a4b35e1633..4684d51314 100644 --- a/api/@ohos.net.vpnExtension.d.ts +++ b/api/@ohos.net.vpnExtension.d.ts @@ -237,14 +237,6 @@ declare namespace vpnExtension { * @since 11 */ export interface VpnConfig { - /** - * The uuid for the VPN network. - * @type {?string} - * @syscap SystemCapability.Communication.NetManager.Vpn - * @since 20 - */ - vpnId?: string; - /** * The array of addresses for VPN interface. * -- Gitee