* @private * @description 创建隧道 * @function EncryptRequest.prototype._createTunnel
()
| 120 | * @function EncryptRequest.prototype._createTunnel |
| 121 | */ |
| 122 | async _createTunnel() { |
| 123 | if (!this.tunnelUrl) { |
| 124 | try { |
| 125 | const data = await this._getRSAPublicKey(); |
| 126 | if (!data) { |
| 127 | throw 'fetch RSA publicKey failed'; |
| 128 | } |
| 129 | // 创建隧道 |
| 130 | const response = await FetchRequest.post(URI(this.serverUrl).segment('services/security/tunnel/v1/tunnels').toString(), data); |
| 131 | const result = await response.json(); |
| 132 | Object.assign(this, { |
| 133 | tunnelUrl: result.tunnelUrl, |
| 134 | blockedUrlRegex: Object.assign({}, this.blockedUrlRegex, result.blockedUrlRegex) |
| 135 | }); |
| 136 | } catch (error) { |
| 137 | console.debug('安全隧道创建失败,错误详情:' + error); |
| 138 | } |
| 139 | } |
| 140 | return this.tunnelUrl; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
no test coverage detected