node-opcua-server-discovery 2.76.1 → 2.76.2
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/dist/index.d.ts +4 -4
- package/dist/index.js +20 -20
- package/dist/mdns_responder.d.ts +13 -13
- package/dist/mdns_responder.js +109 -109
- package/dist/opcua_discovery_server.d.ts +33 -33
- package/dist/opcua_discovery_server.js +449 -449
- package/dist/opcua_discovery_server.js.map +1 -1
- package/package.json +17 -13
- package/source/opcua_discovery_server.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-server-discovery
|
|
3
|
-
*/
|
|
4
|
-
export * from "./opcua_discovery_server";
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-server-discovery
|
|
3
|
+
*/
|
|
4
|
+
export * from "./opcua_discovery_server";
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
/**
|
|
18
|
-
* @module node-opcua-server-discovery
|
|
19
|
-
*/
|
|
20
|
-
__exportStar(require("./opcua_discovery_server"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @module node-opcua-server-discovery
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./opcua_discovery_server"), exports);
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/dist/mdns_responder.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ServerOnNetwork } from "node-opcua-service-discovery";
|
|
2
|
-
export declare class MDNSResponder {
|
|
3
|
-
/**
|
|
4
|
-
* the list of servers that have been activated as mDNS service
|
|
5
|
-
*/
|
|
6
|
-
registeredServers: ServerOnNetwork[];
|
|
7
|
-
private multicastDNS;
|
|
8
|
-
private browser;
|
|
9
|
-
private recordId;
|
|
10
|
-
lastUpdateDate: Date;
|
|
11
|
-
constructor();
|
|
12
|
-
dispose(): void;
|
|
13
|
-
}
|
|
1
|
+
import { ServerOnNetwork } from "node-opcua-service-discovery";
|
|
2
|
+
export declare class MDNSResponder {
|
|
3
|
+
/**
|
|
4
|
+
* the list of servers that have been activated as mDNS service
|
|
5
|
+
*/
|
|
6
|
+
registeredServers: ServerOnNetwork[];
|
|
7
|
+
private multicastDNS;
|
|
8
|
+
private browser;
|
|
9
|
+
private recordId;
|
|
10
|
+
lastUpdateDate: Date;
|
|
11
|
+
constructor();
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
package/dist/mdns_responder.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MDNSResponder = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-server-discovery
|
|
6
|
-
*/
|
|
7
|
-
const sterfive_bonjour_service_1 = require("sterfive-bonjour-service");
|
|
8
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
9
|
-
const node_opcua_object_registry_1 = require("node-opcua-object-registry");
|
|
10
|
-
const node_opcua_service_discovery_1 = require("node-opcua-service-discovery");
|
|
11
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
12
|
-
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename) || true;
|
|
13
|
-
const registry = new node_opcua_object_registry_1.ObjectRegistry();
|
|
14
|
-
class MDNSResponder {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.lastUpdateDate = new Date();
|
|
17
|
-
registry.register(this);
|
|
18
|
-
this.registeredServers = [];
|
|
19
|
-
this.multicastDNS = new sterfive_bonjour_service_1.Bonjour();
|
|
20
|
-
this.recordId = 0;
|
|
21
|
-
this.browser = this.multicastDNS.find({
|
|
22
|
-
protocol: "tcp",
|
|
23
|
-
type: "opcua-tcp"
|
|
24
|
-
});
|
|
25
|
-
const findServiceIndex = (serverName) => {
|
|
26
|
-
const index = this.registeredServers.findIndex((server) => server.serverName === serverName);
|
|
27
|
-
return index;
|
|
28
|
-
};
|
|
29
|
-
const addService = (service) => {
|
|
30
|
-
if (doDebug) {
|
|
31
|
-
debugLog("adding server ", service.name, "port =", service.port);
|
|
32
|
-
}
|
|
33
|
-
// example:
|
|
34
|
-
// {
|
|
35
|
-
// addresses: [ '172.18.207.145', 'fe80::d4e3:352c:9f8b:d0db' ],
|
|
36
|
-
// rawTxt: <Buffer 05 70 61 74 68 3d 08 63 61 70 73 3d 4c 44 53>,
|
|
37
|
-
// txt: { path: '', caps: 'LDS' },
|
|
38
|
-
// name: 'UA Local Discovery Server on STERFIVEPC2',
|
|
39
|
-
// fqdn: 'UA Local Discovery Server on STERFIVEPC2._opcua-tcp._tcp.local',
|
|
40
|
-
// host: 'STERFIVEPC2.local',
|
|
41
|
-
// referer:
|
|
42
|
-
// {
|
|
43
|
-
// address: '172.18.207.145',
|
|
44
|
-
// family: 'IPv4',
|
|
45
|
-
// port: 5353,
|
|
46
|
-
// size: 363
|
|
47
|
-
// },
|
|
48
|
-
// port: 4840,
|
|
49
|
-
// type: 'opcua-tcp',
|
|
50
|
-
// protocol: 'tcp',
|
|
51
|
-
// subtypes: []
|
|
52
|
-
// },
|
|
53
|
-
const existingIndex = findServiceIndex(service.name);
|
|
54
|
-
if (existingIndex >= 0) {
|
|
55
|
-
debugLog("Ignoring existing server ", service.name);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.recordId++;
|
|
59
|
-
const recordId = this.recordId;
|
|
60
|
-
const serverName = service.name;
|
|
61
|
-
service.txt = service.txt || {};
|
|
62
|
-
const service_txt = service.txt;
|
|
63
|
-
service_txt.caps = service_txt.caps || "";
|
|
64
|
-
const serverCapabilities = service_txt.caps
|
|
65
|
-
.split(",")
|
|
66
|
-
.map((x) => x.toUpperCase())
|
|
67
|
-
.sort();
|
|
68
|
-
const path = service_txt.path || "";
|
|
69
|
-
const discoveryUrl = "opc.tcp://" + service.host + ":" + service.port + path;
|
|
70
|
-
this.registeredServers.push(new node_opcua_service_discovery_1.ServerOnNetwork({
|
|
71
|
-
discoveryUrl,
|
|
72
|
-
recordId,
|
|
73
|
-
serverCapabilities,
|
|
74
|
-
serverName
|
|
75
|
-
}));
|
|
76
|
-
this.lastUpdateDate = new Date(Date.now());
|
|
77
|
-
debugLog("a new OPCUA server has been registered on mDNS", service.name, recordId);
|
|
78
|
-
};
|
|
79
|
-
const removeService = (service) => {
|
|
80
|
-
const serverName = service.name;
|
|
81
|
-
debugLog("a OPCUA server has been unregistered in mDNS", serverName);
|
|
82
|
-
const index = findServiceIndex(serverName);
|
|
83
|
-
if (index === -1) {
|
|
84
|
-
debugLog("Cannot find server with name ", serverName, " in registeredServers");
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
this.registeredServers.splice(index, 1); // remove element at index
|
|
88
|
-
this.lastUpdateDate = new Date();
|
|
89
|
-
};
|
|
90
|
-
this.browser.on("up", (service) => {
|
|
91
|
-
if (doDebug) {
|
|
92
|
-
debugLog("MDNSResponder : service is up with ", (0, node_opcua_service_discovery_1.serviceToString)(service));
|
|
93
|
-
}
|
|
94
|
-
addService(service);
|
|
95
|
-
});
|
|
96
|
-
this.browser.on("down", (service) => {
|
|
97
|
-
if (doDebug) {
|
|
98
|
-
debugLog("MDNSResponder : service is down with ", (0, node_opcua_service_discovery_1.serviceToString)(service));
|
|
99
|
-
}
|
|
100
|
-
removeService(service);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
dispose() {
|
|
104
|
-
// yy delete (this as any).multicastDNS;
|
|
105
|
-
this.multicastDNS.destroy();
|
|
106
|
-
registry.unregister(this);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.MDNSResponder = MDNSResponder;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MDNSResponder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-server-discovery
|
|
6
|
+
*/
|
|
7
|
+
const sterfive_bonjour_service_1 = require("sterfive-bonjour-service");
|
|
8
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
9
|
+
const node_opcua_object_registry_1 = require("node-opcua-object-registry");
|
|
10
|
+
const node_opcua_service_discovery_1 = require("node-opcua-service-discovery");
|
|
11
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
12
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename) || true;
|
|
13
|
+
const registry = new node_opcua_object_registry_1.ObjectRegistry();
|
|
14
|
+
class MDNSResponder {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.lastUpdateDate = new Date();
|
|
17
|
+
registry.register(this);
|
|
18
|
+
this.registeredServers = [];
|
|
19
|
+
this.multicastDNS = new sterfive_bonjour_service_1.Bonjour();
|
|
20
|
+
this.recordId = 0;
|
|
21
|
+
this.browser = this.multicastDNS.find({
|
|
22
|
+
protocol: "tcp",
|
|
23
|
+
type: "opcua-tcp"
|
|
24
|
+
});
|
|
25
|
+
const findServiceIndex = (serverName) => {
|
|
26
|
+
const index = this.registeredServers.findIndex((server) => server.serverName === serverName);
|
|
27
|
+
return index;
|
|
28
|
+
};
|
|
29
|
+
const addService = (service) => {
|
|
30
|
+
if (doDebug) {
|
|
31
|
+
debugLog("adding server ", service.name, "port =", service.port);
|
|
32
|
+
}
|
|
33
|
+
// example:
|
|
34
|
+
// {
|
|
35
|
+
// addresses: [ '172.18.207.145', 'fe80::d4e3:352c:9f8b:d0db' ],
|
|
36
|
+
// rawTxt: <Buffer 05 70 61 74 68 3d 08 63 61 70 73 3d 4c 44 53>,
|
|
37
|
+
// txt: { path: '', caps: 'LDS' },
|
|
38
|
+
// name: 'UA Local Discovery Server on STERFIVEPC2',
|
|
39
|
+
// fqdn: 'UA Local Discovery Server on STERFIVEPC2._opcua-tcp._tcp.local',
|
|
40
|
+
// host: 'STERFIVEPC2.local',
|
|
41
|
+
// referer:
|
|
42
|
+
// {
|
|
43
|
+
// address: '172.18.207.145',
|
|
44
|
+
// family: 'IPv4',
|
|
45
|
+
// port: 5353,
|
|
46
|
+
// size: 363
|
|
47
|
+
// },
|
|
48
|
+
// port: 4840,
|
|
49
|
+
// type: 'opcua-tcp',
|
|
50
|
+
// protocol: 'tcp',
|
|
51
|
+
// subtypes: []
|
|
52
|
+
// },
|
|
53
|
+
const existingIndex = findServiceIndex(service.name);
|
|
54
|
+
if (existingIndex >= 0) {
|
|
55
|
+
debugLog("Ignoring existing server ", service.name);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.recordId++;
|
|
59
|
+
const recordId = this.recordId;
|
|
60
|
+
const serverName = service.name;
|
|
61
|
+
service.txt = service.txt || {};
|
|
62
|
+
const service_txt = service.txt;
|
|
63
|
+
service_txt.caps = service_txt.caps || "";
|
|
64
|
+
const serverCapabilities = service_txt.caps
|
|
65
|
+
.split(",")
|
|
66
|
+
.map((x) => x.toUpperCase())
|
|
67
|
+
.sort();
|
|
68
|
+
const path = service_txt.path || "";
|
|
69
|
+
const discoveryUrl = "opc.tcp://" + service.host + ":" + service.port + path;
|
|
70
|
+
this.registeredServers.push(new node_opcua_service_discovery_1.ServerOnNetwork({
|
|
71
|
+
discoveryUrl,
|
|
72
|
+
recordId,
|
|
73
|
+
serverCapabilities,
|
|
74
|
+
serverName
|
|
75
|
+
}));
|
|
76
|
+
this.lastUpdateDate = new Date(Date.now());
|
|
77
|
+
debugLog("a new OPCUA server has been registered on mDNS", service.name, recordId);
|
|
78
|
+
};
|
|
79
|
+
const removeService = (service) => {
|
|
80
|
+
const serverName = service.name;
|
|
81
|
+
debugLog("a OPCUA server has been unregistered in mDNS", serverName);
|
|
82
|
+
const index = findServiceIndex(serverName);
|
|
83
|
+
if (index === -1) {
|
|
84
|
+
debugLog("Cannot find server with name ", serverName, " in registeredServers");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.registeredServers.splice(index, 1); // remove element at index
|
|
88
|
+
this.lastUpdateDate = new Date();
|
|
89
|
+
};
|
|
90
|
+
this.browser.on("up", (service) => {
|
|
91
|
+
if (doDebug) {
|
|
92
|
+
debugLog("MDNSResponder : service is up with ", (0, node_opcua_service_discovery_1.serviceToString)(service));
|
|
93
|
+
}
|
|
94
|
+
addService(service);
|
|
95
|
+
});
|
|
96
|
+
this.browser.on("down", (service) => {
|
|
97
|
+
if (doDebug) {
|
|
98
|
+
debugLog("MDNSResponder : service is down with ", (0, node_opcua_service_discovery_1.serviceToString)(service));
|
|
99
|
+
}
|
|
100
|
+
removeService(service);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
dispose() {
|
|
104
|
+
// yy delete (this as any).multicastDNS;
|
|
105
|
+
this.multicastDNS.destroy();
|
|
106
|
+
registry.unregister(this);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.MDNSResponder = MDNSResponder;
|
|
110
110
|
//# sourceMappingURL=mdns_responder.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-server-discovery
|
|
3
|
-
*/
|
|
4
|
-
import { Message, Response, ServerSecureChannelLayer } from "node-opcua-secure-channel";
|
|
5
|
-
import { OPCUABaseServer, OPCUABaseServerOptions } from "node-opcua-server";
|
|
6
|
-
import { MdnsDiscoveryConfiguration, RegisteredServer } from "node-opcua-service-discovery";
|
|
7
|
-
import { ApplicationDescription } from "node-opcua-service-endpoints";
|
|
8
|
-
import { ErrorCallback } from "node-opcua-status-code";
|
|
9
|
-
export interface OPCUADiscoveryServerOptions extends OPCUABaseServerOptions {
|
|
10
|
-
certificateFile?: string;
|
|
11
|
-
port?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class OPCUADiscoveryServer extends OPCUABaseServer {
|
|
14
|
-
private mDnsResponder?;
|
|
15
|
-
private readonly registeredServers;
|
|
16
|
-
private bonjourHolder;
|
|
17
|
-
private _delayInit?;
|
|
18
|
-
constructor(options: OPCUADiscoveryServerOptions);
|
|
19
|
-
start(): Promise<void>;
|
|
20
|
-
start(callback: ErrorCallback): void;
|
|
21
|
-
shutdown(): Promise<void>;
|
|
22
|
-
shutdown(callback: ErrorCallback): void;
|
|
23
|
-
/**
|
|
24
|
-
* returns the number of registered servers
|
|
25
|
-
*/
|
|
26
|
-
get registeredServerCount(): number;
|
|
27
|
-
getServers(channel: ServerSecureChannelLayer): ApplicationDescription[];
|
|
28
|
-
protected _on_RegisterServer2Request(message: Message, channel: ServerSecureChannelLayer): void;
|
|
29
|
-
protected _on_RegisterServerRequest(message: Message, channel: ServerSecureChannelLayer): void;
|
|
30
|
-
protected _on_FindServersOnNetworkRequest(message: Message, channel: ServerSecureChannelLayer): void;
|
|
31
|
-
protected __internalRegisterServerWithCallback(RegisterServerXResponse: any, rawServer: RegisteredServer, discoveryConfigurations: MdnsDiscoveryConfiguration[] | undefined, callback: (err: Error | null, response?: Response) => void): Promise<void>;
|
|
32
|
-
protected __internalRegisterServer(RegisterServerXResponse: any, rawServer: RegisteredServer, discoveryConfigurations?: MdnsDiscoveryConfiguration[]): Promise<Response>;
|
|
33
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-server-discovery
|
|
3
|
+
*/
|
|
4
|
+
import { Message, Response, ServerSecureChannelLayer } from "node-opcua-secure-channel";
|
|
5
|
+
import { OPCUABaseServer, OPCUABaseServerOptions } from "node-opcua-server";
|
|
6
|
+
import { MdnsDiscoveryConfiguration, RegisteredServer } from "node-opcua-service-discovery";
|
|
7
|
+
import { ApplicationDescription } from "node-opcua-service-endpoints";
|
|
8
|
+
import { ErrorCallback } from "node-opcua-status-code";
|
|
9
|
+
export interface OPCUADiscoveryServerOptions extends OPCUABaseServerOptions {
|
|
10
|
+
certificateFile?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class OPCUADiscoveryServer extends OPCUABaseServer {
|
|
14
|
+
private mDnsResponder?;
|
|
15
|
+
private readonly registeredServers;
|
|
16
|
+
private bonjourHolder;
|
|
17
|
+
private _delayInit?;
|
|
18
|
+
constructor(options: OPCUADiscoveryServerOptions);
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
start(callback: ErrorCallback): void;
|
|
21
|
+
shutdown(): Promise<void>;
|
|
22
|
+
shutdown(callback: ErrorCallback): void;
|
|
23
|
+
/**
|
|
24
|
+
* returns the number of registered servers
|
|
25
|
+
*/
|
|
26
|
+
get registeredServerCount(): number;
|
|
27
|
+
getServers(channel: ServerSecureChannelLayer): ApplicationDescription[];
|
|
28
|
+
protected _on_RegisterServer2Request(message: Message, channel: ServerSecureChannelLayer): void;
|
|
29
|
+
protected _on_RegisterServerRequest(message: Message, channel: ServerSecureChannelLayer): void;
|
|
30
|
+
protected _on_FindServersOnNetworkRequest(message: Message, channel: ServerSecureChannelLayer): void;
|
|
31
|
+
protected __internalRegisterServerWithCallback(RegisterServerXResponse: any, rawServer: RegisteredServer, discoveryConfigurations: MdnsDiscoveryConfiguration[] | undefined, callback: (err: Error | null, response?: Response) => void): Promise<void>;
|
|
32
|
+
protected __internalRegisterServer(RegisterServerXResponse: any, rawServer: RegisteredServer, discoveryConfigurations?: MdnsDiscoveryConfiguration[]): Promise<Response>;
|
|
33
|
+
}
|