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