@openziti/ziti-sdk-nodejs 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/connect.js +16 -5
- package/package.json +1 -1
package/lib/connect.js
CHANGED
|
@@ -17,8 +17,11 @@ limitations under the License.
|
|
|
17
17
|
const http = require('node:http');
|
|
18
18
|
const net = require('node:net');
|
|
19
19
|
|
|
20
|
-
const connect = (
|
|
21
|
-
|
|
20
|
+
const connect = (dialInfo, cb) => {
|
|
21
|
+
if (typeof dialInfo === 'string') {
|
|
22
|
+
dialInfo = { service: dialInfo };
|
|
23
|
+
}
|
|
24
|
+
ziti.ziti_connect(dialInfo.service, dialInfo.identity, dialInfo.dial_data, (err, sock) => {
|
|
22
25
|
if (err) {
|
|
23
26
|
return cb(err);
|
|
24
27
|
}
|
|
@@ -27,14 +30,22 @@ const connect = (service, cb) => {
|
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
function
|
|
33
|
+
function getDialInfo(protocol, host, port) {
|
|
31
34
|
return ziti.get_ziti_service(protocol, host, port);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
class HttpAgent extends http.Agent {
|
|
35
38
|
createConnection(options, callback) {
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
let dialInfo;
|
|
40
|
+
try {
|
|
41
|
+
dialInfo = getDialInfo('tcp', options.host, options.port);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
dialInfo = {
|
|
44
|
+
service: options.host,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
connect(dialInfo, (err, sock) => {
|
|
38
49
|
if (err) {
|
|
39
50
|
console.error('Error from ziti.ziti_connect:', err);
|
|
40
51
|
// fallback to default connect
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openziti/ziti-sdk-nodejs",
|
|
3
3
|
"description": "A NodeJS-based SDK for delivering secure applications over a Ziti Network",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"main": "./lib/ziti",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "npm run build:configure && npm run build:make",
|