You need to sign in or sign up before continuing.
提交 e62d56be 编写于 作者: 徐杰

网卡代理API说明补充

Signed-off-by: N徐杰 <xujie223@huawei.com>
Change-Id: Ia8d1bf1bd3c72aba98ceb48db78e4559cc8fd706
上级 034850b6
diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
index 5472a539d30867ef98180265007158cf0018bf0e..a309f528e00101326a9a5a6eecb880afde9a1a98 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
@@ -310,6 +310,71 @@ connection.setGlobalHttpProxy(httpProxy).then(() => {
})
```
+## connection.getDefaultHttpProxy<sup>10+</sup>
+
+getDefaultHttpProxy(callback: AsyncCallback\<HttpProxy>): void
+
+获取网络默认的代理配置信息。
+如果设置了全局代理,则会返回全局代理配置信息。如果进程使用[setAppNet](#connectionsetappnet)绑定到指定[NetHandle](#nethandle)对应的网络,则返回[NetHandle](#nethandle)对应网络的代理配置信息。在其他情况下,将返回默认网络的代理配置信息。
+使用callback方式作为异步方法。
+
+**系统能力**:SystemCapability.Communication.NetManager.Core
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<[HttpProxy](#httpproxy)> | 是 | 回调函数。当成功获取网络默认的代理配置信息时,err为undefined,data为网络默认的代理配置信息;否则为错误对象 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | -------------------------------------------- |
+| 2100002 | Operation failed. Cannot connect to service. |
+| 2100003 | System internal error. |
+
+**示例:**
+
+```js
+connection.getDefaultHttpProxy((error, data) => {
+ console.info(JSON.stringify(error));
+ console.info(JSON.stringify(data));
+})
+```
+
+## connection.getDefaultHttpProxy<sup>10+</sup>
+
+getDefaultHttpProxy(): Promise\<HttpProxy>;
+
+获取网络默认的代理配置信息。
+如果设置了全局代理,则会返回全局代理配置信息。如果进程使用[setAppNet](#connectionsetappnet)绑定到指定[NetHandle](#nethandle)对应的网络,则返回[NetHandle](#nethandle)对应网络的代理配置信息。在其他情况下,将返回默认网络的代理配置信息。
+使用Promise方式作为异步方法。
+
+**系统能力**:SystemCapability.Communication.NetManager.Core
+
+**返回值:**
+
+| 类型 | 说明 |
+| -------------------------------- | ----------------------------------------- |
+| Promise<[HttpProxy](#httpproxy)> | 以Promise形式返回网络默认的代理配置信息。 |
+
+**错误码:**
+
+| 错误码ID | 错误信息 |
+| -------- | -------------------------------------------- |
+| 2100002 | Operation failed. Cannot connect to service. |
+| 2100003 | System internal error. |
+
+**示例:**
+
+```js
+connection.getDefaultHttpProxy().then((data) => {
+ console.info(JSON.stringify(data));
+}).catch(error => {
+ console.info(JSON.stringify(error));
+})
+```
+
## connection.getAppNet<sup>9+</sup>
getAppNet(callback: AsyncCallback\<NetHandle>): void
@@ -1864,7 +1929,7 @@ connection.getDefaultNet().then(function (netHandle) {
## HttpProxy<sup>10+</sup>
-网络全局代理配置信息
+网络代理配置信息
**系统能力**:SystemCapability.Communication.NetManager.Core
diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md b/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
index 93cf43ff4db4b90fce37d811e112666edce72cdb..6e7558ca3431fe4a61a2e49ad20589f3d10c6407 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
@@ -1,6 +1,6 @@
# @ohos.net.ethernet (以太网连接管理)
-以太网连接管理主要提供有线网络能力,提供设置有线网络的IP地址,子网掩码,网关,DNS等信息
+以太网连接管理主要提供有线网络能力,提供设置有线网络的IP地址,子网掩码,网关,DNS,代理等信息
> **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
@@ -55,7 +55,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
- dnsServers: "1.1.1.1"
+ dnsServers: "1.1.1.1",
+ httpProxy: {
+ host: "180.89.xx.xx",
+ port: 8080,
+ exclusionList: {"192.168","example.com"}
+ }
}, (error) => {
if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error));
@@ -114,7 +119,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
- dnsServers: "1.1.1.1"
+ dnsServers: "1.1.1.1",
+ httpProxy: {
+ host: "180.89.xx.xx",
+ port: 8080,
+ exclusionList: {"192.168","example.com"}
+ }
}).then(() => {
console.log("setIfaceConfig promise ok ");
}).catch(error => {
@@ -476,16 +486,4 @@ ethernet.off('interfaceStateChange');
| gateway | string | 是 | 以太网连接配置网关信息,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 |
| netMask | string | 是 | 以太网连接配置子网掩码,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 |
| dnsServers | string | 是 | 以太网连接配置dns服务地址,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)多地址间用“,”隔开。 |
-
-## IPSetMode<sup>9+</sup>
-
-以太网连接模式。
-
-**系统接口**:此接口为系统接口。
-
-**系统能力**:SystemCapability.Communication.NetManager.Ethernet
-
-| 名称 | 值 | 说明 |
-| ------------------------ | ---- | ---------------------- |
-| STATIC | 0 | 以太网连接静态配置网络信息。 |
-| DHCP | 1 | 以太网连接动态配置网络信息。 |
+| httpProxy<sup>10+</sup> | [HttpProxy](#connectionhttpproxy) | 否 | 以太网连接代理配置信息,默认情况下不配置任何代理信息。 |
...@@ -310,6 +310,71 @@ connection.setGlobalHttpProxy(httpProxy).then(() => { ...@@ -310,6 +310,71 @@ connection.setGlobalHttpProxy(httpProxy).then(() => {
}) })
``` ```
## connection.getDefaultHttpProxy<sup>10+</sup>
getDefaultHttpProxy(callback: AsyncCallback\<HttpProxy>): void
获取网络默认的代理配置信息。
如果设置了全局代理,则会返回全局代理配置信息。如果进程使用[setAppNet](#connectionsetappnet)绑定到指定[NetHandle](#nethandle)对应的网络,则返回[NetHandle](#nethandle)对应网络的代理配置信息。在其他情况下,将返回默认网络的代理配置信息。
使用callback方式作为异步方法。
**系统能力**:SystemCapability.Communication.NetManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<[HttpProxy](#httpproxy)> | 是 | 回调函数。当成功获取网络默认的代理配置信息时,err为undefined,data为网络默认的代理配置信息;否则为错误对象 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 2100002 | Operation failed. Cannot connect to service. |
| 2100003 | System internal error. |
**示例:**
```js
connection.getDefaultHttpProxy((error, data) => {
console.info(JSON.stringify(error));
console.info(JSON.stringify(data));
})
```
## connection.getDefaultHttpProxy<sup>10+</sup>
getDefaultHttpProxy(): Promise\<HttpProxy>;
获取网络默认的代理配置信息。
如果设置了全局代理,则会返回全局代理配置信息。如果进程使用[setAppNet](#connectionsetappnet)绑定到指定[NetHandle](#nethandle)对应的网络,则返回[NetHandle](#nethandle)对应网络的代理配置信息。在其他情况下,将返回默认网络的代理配置信息。
使用Promise方式作为异步方法。
**系统能力**:SystemCapability.Communication.NetManager.Core
**返回值:**
| 类型 | 说明 |
| -------------------------------- | ----------------------------------------- |
| Promise<[HttpProxy](#httpproxy)> | 以Promise形式返回网络默认的代理配置信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 2100002 | Operation failed. Cannot connect to service. |
| 2100003 | System internal error. |
**示例:**
```js
connection.getDefaultHttpProxy().then((data) => {
console.info(JSON.stringify(data));
}).catch(error => {
console.info(JSON.stringify(error));
})
```
## connection.getAppNet<sup>9+</sup> ## connection.getAppNet<sup>9+</sup>
getAppNet(callback: AsyncCallback\<NetHandle>): void getAppNet(callback: AsyncCallback\<NetHandle>): void
...@@ -1864,7 +1929,7 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -1864,7 +1929,7 @@ connection.getDefaultNet().then(function (netHandle) {
## HttpProxy<sup>10+</sup> ## HttpProxy<sup>10+</sup>
网络全局代理配置信息 网络代理配置信息
**系统能力**:SystemCapability.Communication.NetManager.Core **系统能力**:SystemCapability.Communication.NetManager.Core
......
# @ohos.net.ethernet (以太网连接管理) # @ohos.net.ethernet (以太网连接管理)
以太网连接管理主要提供有线网络能力,提供设置有线网络的IP地址,子网掩码,网关,DNS等信息 以太网连接管理主要提供有线网络能力,提供设置有线网络的IP地址,子网掩码,网关,DNS,代理等信息
> **说明:** > **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -55,7 +55,12 @@ ethernet.setIfaceConfig("eth0", { ...@@ -55,7 +55,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1" dnsServers: "1.1.1.1",
httpProxy: {
host: "180.89.xx.xx",
port: 8080,
exclusionList: {"192.168","example.com"}
}
}, (error) => { }, (error) => {
if (error) { if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error)); console.log("setIfaceConfig callback error = " + JSON.stringify(error));
...@@ -114,7 +119,12 @@ ethernet.setIfaceConfig("eth0", { ...@@ -114,7 +119,12 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1" dnsServers: "1.1.1.1",
httpProxy: {
host: "180.89.xx.xx",
port: 8080,
exclusionList: {"192.168","example.com"}
}
}).then(() => { }).then(() => {
console.log("setIfaceConfig promise ok "); console.log("setIfaceConfig promise ok ");
}).catch(error => { }).catch(error => {
...@@ -476,16 +486,4 @@ ethernet.off('interfaceStateChange'); ...@@ -476,16 +486,4 @@ ethernet.off('interfaceStateChange');
| gateway | string | 是 | 以太网连接配置网关信息,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 | | gateway | string | 是 | 以太网连接配置网关信息,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 |
| netMask | string | 是 | 以太网连接配置子网掩码,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 | | netMask | string | 是 | 以太网连接配置子网掩码,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)。 |
| dnsServers | string | 是 | 以太网连接配置dns服务地址,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)多地址间用“,”隔开。 | | dnsServers | string | 是 | 以太网连接配置dns服务地址,地址值范围0-255.0-255.0-255.0-255(DHCP模式无需配置)多地址间用“,”隔开。 |
| httpProxy<sup>10+</sup> | [HttpProxy](#connectionhttpproxy) | 否 | 以太网连接代理配置信息,默认情况下不配置任何代理信息。 |
## IPSetMode<sup>9+</sup>
以太网连接模式。
**系统接口**:此接口为系统接口。
**系统能力**:SystemCapability.Communication.NetManager.Ethernet
| 名称 | 值 | 说明 |
| ------------------------ | ---- | ---------------------- |
| STATIC | 0 | 以太网连接静态配置网络信息。 |
| DHCP | 1 | 以太网连接动态配置网络信息。 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册