node-opcua-server 2.53.0 → 2.56.1
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/LICENSE +20 -20
- package/dist/base_server.js +12 -14
- package/dist/base_server.js.map +1 -1
- package/dist/factory.d.ts +4 -2
- package/dist/factory.js.map +1 -1
- package/dist/history_server_capabilities.js.map +1 -1
- package/dist/i_server_side_publish_engine.d.ts +1 -1
- package/dist/i_server_side_publish_engine.js +1 -1
- package/dist/i_server_side_publish_engine.js.map +1 -1
- package/dist/monitored_item.d.ts +3 -0
- package/dist/monitored_item.js +7 -14
- package/dist/monitored_item.js.map +1 -1
- package/dist/node_sampler.js +1 -1
- package/dist/node_sampler.js.map +1 -1
- package/dist/opcua_server.d.ts +29 -44
- package/dist/opcua_server.js +218 -262
- package/dist/opcua_server.js.map +1 -1
- package/dist/queue.js +1 -0
- package/dist/queue.js.map +1 -1
- package/dist/register_server_manager.d.ts +4 -1
- package/dist/register_server_manager.js +5 -5
- package/dist/register_server_manager.js.map +1 -1
- package/dist/register_server_manager_hidden.d.ts +1 -1
- package/dist/register_server_manager_hidden.js.map +1 -1
- package/dist/register_server_manager_mdns_only.d.ts +4 -1
- package/dist/register_server_manager_mdns_only.js +1 -1
- package/dist/register_server_manager_mdns_only.js.map +1 -1
- package/dist/server_capabilities.js.map +1 -1
- package/dist/server_end_point.d.ts +4 -1
- package/dist/server_end_point.js +10 -11
- package/dist/server_end_point.js.map +1 -1
- package/dist/server_engine.d.ts +11 -7
- package/dist/server_engine.js +72 -74
- package/dist/server_engine.js.map +1 -1
- package/dist/server_publish_engine.d.ts +4 -1
- package/dist/server_publish_engine.js +5 -5
- package/dist/server_publish_engine.js.map +1 -1
- package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +2 -2
- package/dist/server_publish_engine_for_orphan_subscriptions.js.map +1 -1
- package/dist/server_session.d.ts +1 -1
- package/dist/server_session.js +24 -29
- package/dist/server_session.js.map +1 -1
- package/dist/server_subscription.d.ts +3 -1
- package/dist/server_subscription.js +6 -6
- package/dist/server_subscription.js.map +1 -1
- package/dist/sessions_compatible_for_transfer.js +2 -1
- package/dist/sessions_compatible_for_transfer.js.map +1 -1
- package/dist/validate_filter.js +4 -7
- package/dist/validate_filter.js.map +1 -1
- package/package.json +45 -44
- package/source/base_server.ts +19 -22
- package/source/factory.ts +5 -2
- package/source/history_server_capabilities.ts +3 -4
- package/source/i_channel_data.ts +4 -8
- package/source/i_register_server_manager.ts +0 -3
- package/source/i_server_side_publish_engine.ts +5 -6
- package/source/i_socket_data.ts +1 -1
- package/source/index.ts +14 -14
- package/source/monitored_item.ts +32 -44
- package/source/node_sampler.ts +82 -82
- package/source/opcua_server.ts +326 -357
- package/source/queue.ts +6 -7
- package/source/register_server_manager.ts +35 -23
- package/source/register_server_manager_hidden.ts +8 -10
- package/source/register_server_manager_mdns_only.ts +8 -13
- package/source/server_capabilities.ts +0 -5
- package/source/server_end_point.ts +28 -30
- package/source/server_engine.ts +122 -122
- package/source/server_publish_engine.ts +24 -21
- package/source/server_publish_engine_for_orphan_subscriptions.ts +26 -26
- package/source/server_session.ts +44 -49
- package/source/server_subscription.ts +23 -23
- package/source/sessions_compatible_for_transfer.ts +26 -25
- package/source/validate_filter.ts +8 -22
- package/test_helpers/create_certificates.js +1 -1
package/source/queue.ts
CHANGED
|
@@ -14,7 +14,7 @@ export class Queue<T> {
|
|
|
14
14
|
if (this.size === 0) {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
-
return this._d.first() as T;
|
|
17
|
+
return this._d.first() as T;
|
|
18
18
|
}
|
|
19
19
|
public shift(): T | undefined {
|
|
20
20
|
if (this.size === 0) {
|
|
@@ -29,18 +29,16 @@ export class Queue<T> {
|
|
|
29
29
|
this._d.push(value);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
public filterOut(predicate: (element: T)=> boolean): number {
|
|
33
|
-
|
|
32
|
+
public filterOut(predicate: (element: T) => boolean): number {
|
|
34
33
|
let counter = 0;
|
|
35
34
|
let p = this._d.head.next;
|
|
36
|
-
while(p != this._d.head) {
|
|
37
|
-
|
|
35
|
+
while (p != this._d.head) {
|
|
38
36
|
const shouldRemove = predicate(p.data);
|
|
39
37
|
const pPrev = p;
|
|
40
|
-
p= p.next;
|
|
38
|
+
p = p.next;
|
|
41
39
|
if (shouldRemove) {
|
|
42
40
|
this.size -= 1;
|
|
43
|
-
counter+=1;
|
|
41
|
+
counter += 1;
|
|
44
42
|
pPrev.remove();
|
|
45
43
|
}
|
|
46
44
|
}
|
|
@@ -48,6 +46,7 @@ export class Queue<T> {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
public values(): Iterable<T> {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
51
50
|
const self = this;
|
|
52
51
|
const iteratable = {
|
|
53
52
|
[Symbol.iterator]() {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module node-opcua-server
|
|
3
3
|
*/
|
|
4
4
|
// tslint:disable:no-console
|
|
5
|
+
import { EventEmitter } from "events";
|
|
5
6
|
import * as async from "async";
|
|
6
7
|
import * as chalk from "chalk";
|
|
7
|
-
import { EventEmitter } from "events";
|
|
8
8
|
|
|
9
9
|
import { assert } from "node-opcua-assert";
|
|
10
10
|
import { ErrorCallback, UAString } from "node-opcua-basic-types";
|
|
@@ -26,9 +26,9 @@ import {
|
|
|
26
26
|
RegisterServerResponse
|
|
27
27
|
} from "node-opcua-service-discovery";
|
|
28
28
|
import { ApplicationType, EndpointDescription, MdnsDiscoveryConfiguration, RegisteredServerOptions } from "node-opcua-types";
|
|
29
|
-
import { IRegisterServerManager } from "./i_register_server_manager";
|
|
30
29
|
import { exploreCertificate } from "node-opcua-crypto";
|
|
31
30
|
import { OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
31
|
+
import { IRegisterServerManager } from "./i_register_server_manager";
|
|
32
32
|
|
|
33
33
|
const doDebug = checkDebugFlag(__filename);
|
|
34
34
|
const debugLog = make_debugLog(__filename);
|
|
@@ -314,7 +314,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
314
314
|
this._registrationTimerId = null;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
public dispose() {
|
|
317
|
+
public dispose(): void {
|
|
318
318
|
this.server = null;
|
|
319
319
|
debugLog("RegisterServerManager#dispose", this.state.toString());
|
|
320
320
|
assert(this.state === RegisterServerManagerStatus.INACTIVE);
|
|
@@ -322,13 +322,13 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
322
322
|
this.removeAllListeners();
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
public _emitEvent(eventName: string) {
|
|
325
|
+
public _emitEvent(eventName: string): void {
|
|
326
326
|
setImmediate(() => {
|
|
327
327
|
this.emit(eventName);
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
public _setState(status: RegisterServerManagerStatus) {
|
|
331
|
+
public _setState(status: RegisterServerManagerStatus): void {
|
|
332
332
|
const previousState = this.state || RegisterServerManagerStatus.INACTIVE;
|
|
333
333
|
debugLog(
|
|
334
334
|
"RegisterServerManager#setState : ",
|
|
@@ -339,7 +339,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
339
339
|
this.state = status;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
public start(callback: ErrorCallback) {
|
|
342
|
+
public start(callback: ErrorCallback): void {
|
|
343
343
|
debugLog("RegisterServerManager#start");
|
|
344
344
|
if (this.state !== RegisterServerManagerStatus.INACTIVE) {
|
|
345
345
|
return callback(new Error("RegisterServer process already started")); // already started
|
|
@@ -352,7 +352,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
352
352
|
if (err) {
|
|
353
353
|
debugLog("RegisterServerManager#start => _establish_initial_connection has failed");
|
|
354
354
|
return callback(err);
|
|
355
|
-
}
|
|
355
|
+
}
|
|
356
356
|
if (this.state !== RegisterServerManagerStatus.INITIALIZING) {
|
|
357
357
|
debugLog("RegisterServerManager#start => _establish_initial_connection has failed");
|
|
358
358
|
return callback();
|
|
@@ -367,7 +367,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
367
367
|
if (err1) {
|
|
368
368
|
warningLog(
|
|
369
369
|
"RegisterServerManager#start - registering server has failed ! \n" +
|
|
370
|
-
|
|
370
|
+
"please check that your server certificate is accepted by the LDS"
|
|
371
371
|
);
|
|
372
372
|
this._setState(RegisterServerManagerStatus.INACTIVE);
|
|
373
373
|
this._emitEvent("serverRegistrationFailure");
|
|
@@ -478,14 +478,17 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
478
478
|
},
|
|
479
479
|
// function wait_a_little_bit
|
|
480
480
|
(callback: ErrorCallback) => {
|
|
481
|
-
setTimeout(callback,
|
|
481
|
+
setTimeout(callback, 10);
|
|
482
482
|
}
|
|
483
483
|
],
|
|
484
484
|
(err?: Error | null) => {
|
|
485
485
|
debugLog("-------------------------------", !!err);
|
|
486
486
|
|
|
487
487
|
if (this.state !== RegisterServerManagerStatus.INITIALIZING) {
|
|
488
|
-
debugLog(
|
|
488
|
+
debugLog(
|
|
489
|
+
"RegisterServerManager#_establish_initial_connection has been interrupted ",
|
|
490
|
+
RegisterServerManagerStatus[this.state]
|
|
491
|
+
);
|
|
489
492
|
this._setState(RegisterServerManagerStatus.INACTIVE);
|
|
490
493
|
if (this._registration_client) {
|
|
491
494
|
this._registration_client.disconnect((err2?: Error) => {
|
|
@@ -513,7 +516,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
513
516
|
);
|
|
514
517
|
}
|
|
515
518
|
|
|
516
|
-
public _trigger_next() {
|
|
519
|
+
public _trigger_next(): void {
|
|
517
520
|
assert(!this._registrationTimerId);
|
|
518
521
|
assert(this.state === RegisterServerManagerStatus.WAITING);
|
|
519
522
|
// from spec 1.04 part 4:
|
|
@@ -562,7 +565,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
562
565
|
}, this.timeout);
|
|
563
566
|
}
|
|
564
567
|
|
|
565
|
-
public stop(callback: ErrorCallback) {
|
|
568
|
+
public stop(callback: ErrorCallback): void {
|
|
566
569
|
debugLog("RegisterServerManager#stop");
|
|
567
570
|
|
|
568
571
|
if (this._registrationTimerId) {
|
|
@@ -592,7 +595,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
592
595
|
* @param outer_callback
|
|
593
596
|
* @private
|
|
594
597
|
*/
|
|
595
|
-
public _registerServer(isOnline: boolean, outer_callback: ErrorCallback) {
|
|
598
|
+
public _registerServer(isOnline: boolean, outer_callback: ErrorCallback): void {
|
|
596
599
|
assert(typeof outer_callback === "function");
|
|
597
600
|
|
|
598
601
|
debugLog(
|
|
@@ -626,11 +629,15 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
626
629
|
return outer_callback();
|
|
627
630
|
}
|
|
628
631
|
assert(this.state === RegisterServerManagerStatus.INITIALIZING || this.state === RegisterServerManagerStatus.WAITING);
|
|
629
|
-
|
|
632
|
+
|
|
630
633
|
this._setState(theStatus);
|
|
631
634
|
|
|
632
635
|
if (this._registration_client) {
|
|
633
|
-
warningLog(
|
|
636
|
+
warningLog(
|
|
637
|
+
`Warning there is already a registering/unregistering task taking place: ${
|
|
638
|
+
RegisterServerManagerStatus[this.state]
|
|
639
|
+
} state`
|
|
640
|
+
);
|
|
634
641
|
}
|
|
635
642
|
|
|
636
643
|
const options: OPCUAClientBaseOptions = {
|
|
@@ -651,7 +658,7 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
651
658
|
|
|
652
659
|
connectionStrategy: no_reconnect_connectivity_strategy,
|
|
653
660
|
|
|
654
|
-
clientName: "server client to LDS " + RegisterServerManagerStatus[theStatus]
|
|
661
|
+
clientName: "server client to LDS " + RegisterServerManagerStatus[theStatus]
|
|
655
662
|
};
|
|
656
663
|
|
|
657
664
|
const client = OPCUAClientBase.create(options) as ClientBaseEx;
|
|
@@ -668,20 +675,20 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
668
675
|
[
|
|
669
676
|
// establish_connection_with_lds
|
|
670
677
|
(callback: ErrorCallback) => {
|
|
671
|
-
client.connect(selectedEndpoint
|
|
678
|
+
client.connect(selectedEndpoint!.endpointUrl!, (err?: Error) => {
|
|
672
679
|
debugLog("establish_connection_with_lds => err = ", err);
|
|
673
680
|
if (err) {
|
|
674
681
|
debugLog("RegisterServerManager#_registerServer connection to client has failed");
|
|
675
682
|
debugLog(
|
|
676
683
|
"RegisterServerManager#_registerServer " +
|
|
677
|
-
|
|
684
|
+
"=> please check that you server certificate is trusted by the LDS"
|
|
678
685
|
);
|
|
679
686
|
warningLog(
|
|
680
687
|
"RegisterServer to the LDS has failed during secure connection " +
|
|
681
|
-
|
|
688
|
+
"=> please check that you server certificate is trusted by the LDS.",
|
|
682
689
|
"\nerr: " + err.message,
|
|
683
690
|
"\nLDS endpoint :",
|
|
684
|
-
selectedEndpoint
|
|
691
|
+
selectedEndpoint!.endpointUrl!,
|
|
685
692
|
"\nsecurity mode :",
|
|
686
693
|
MessageSecurityMode[selectedEndpoint.securityMode],
|
|
687
694
|
"\nsecurity policy :",
|
|
@@ -699,14 +706,20 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
699
706
|
});
|
|
700
707
|
},
|
|
701
708
|
(callback: ErrorCallback) => {
|
|
702
|
-
if (!this._registration_client) {
|
|
709
|
+
if (!this._registration_client) {
|
|
710
|
+
callback();
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
703
713
|
sendRegisterServerRequest(this.server!, client as ClientBaseEx, isOnline, (err?: Error | null) => {
|
|
704
714
|
callback(/* intentionally no error propagation*/);
|
|
705
715
|
});
|
|
706
716
|
},
|
|
707
717
|
// close_connection_with_lds
|
|
708
718
|
(callback: ErrorCallback) => {
|
|
709
|
-
if (!this._registration_client) {
|
|
719
|
+
if (!this._registration_client) {
|
|
720
|
+
callback();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
710
723
|
client.disconnect(callback);
|
|
711
724
|
}
|
|
712
725
|
],
|
|
@@ -721,7 +734,6 @@ export class RegisterServerManager extends EventEmitter implements IRegisterServ
|
|
|
721
734
|
this._registration_client = null;
|
|
722
735
|
outer_callback(err!);
|
|
723
736
|
});
|
|
724
|
-
|
|
725
737
|
}
|
|
726
738
|
);
|
|
727
739
|
}
|
|
@@ -8,26 +8,24 @@ import { IRegisterServerManager } from "./i_register_server_manager";
|
|
|
8
8
|
* a IRegisterServerManager that hides the server from any local discover server
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
export class RegisterServerManagerHidden
|
|
12
|
-
|
|
13
|
-
implements IRegisterServerManager {
|
|
11
|
+
export class RegisterServerManagerHidden extends EventEmitter implements IRegisterServerManager {
|
|
12
|
+
public discoveryServerEndpointUrl = "";
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
constructor(options?: {
|
|
15
|
+
/** */
|
|
16
|
+
}) {
|
|
18
17
|
super();
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
public stop(callback: () => void) {
|
|
20
|
+
public stop(callback: () => void): void {
|
|
22
21
|
setImmediate(callback);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
public start(callback: () => void) {
|
|
24
|
+
public start(callback: () => void): void {
|
|
26
25
|
setImmediate(callback);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
public dispose() {
|
|
28
|
+
public dispose(): void {
|
|
30
29
|
//
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
}
|
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { EventEmitter } from "events";
|
|
7
7
|
import { assert } from "node-opcua-assert";
|
|
8
|
-
import {
|
|
9
|
-
BonjourHolder
|
|
10
|
-
} from "node-opcua-service-discovery";
|
|
8
|
+
import { BonjourHolder } from "node-opcua-service-discovery";
|
|
11
9
|
import { OPCUABaseServer } from "./base_server";
|
|
12
10
|
import { IRegisterServerManager } from "./i_register_server_manager";
|
|
13
11
|
|
|
@@ -15,16 +13,13 @@ import { IRegisterServerManager } from "./i_register_server_manager";
|
|
|
15
13
|
* a RegisterServerManager that declare the server the OPCUA Bonjour service
|
|
16
14
|
* available on the current computer
|
|
17
15
|
*/
|
|
18
|
-
export class RegisterServerManagerMDNSONLY
|
|
19
|
-
|
|
20
|
-
implements IRegisterServerManager {
|
|
21
|
-
|
|
22
|
-
public discoveryServerEndpointUrl: string = "";
|
|
16
|
+
export class RegisterServerManagerMDNSONLY extends EventEmitter implements IRegisterServerManager {
|
|
17
|
+
public discoveryServerEndpointUrl = "";
|
|
23
18
|
|
|
24
19
|
private server?: OPCUABaseServer;
|
|
25
20
|
private bonjour: BonjourHolder;
|
|
26
21
|
|
|
27
|
-
constructor(options:
|
|
22
|
+
constructor(options: { server: OPCUABaseServer }) {
|
|
28
23
|
super();
|
|
29
24
|
this.server = options.server;
|
|
30
25
|
assert(this.server);
|
|
@@ -32,7 +27,7 @@ export class RegisterServerManagerMDNSONLY
|
|
|
32
27
|
this.bonjour = new BonjourHolder();
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
public stop(callback: () => void) {
|
|
30
|
+
public stop(callback: () => void): void {
|
|
36
31
|
if (this.bonjour) {
|
|
37
32
|
this.bonjour._stop_announcedOnMulticastSubnet();
|
|
38
33
|
}
|
|
@@ -42,7 +37,7 @@ export class RegisterServerManagerMDNSONLY
|
|
|
42
37
|
});
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
public start(callback: () => void) {
|
|
40
|
+
public start(callback: () => void): void {
|
|
46
41
|
// istanbul ignore next
|
|
47
42
|
if (!this.server) {
|
|
48
43
|
throw new Error("internal error");
|
|
@@ -53,7 +48,7 @@ export class RegisterServerManagerMDNSONLY
|
|
|
53
48
|
capabilities: this.server.capabilitiesForMDNS,
|
|
54
49
|
name: this.server.serverInfo.applicationUri!,
|
|
55
50
|
path: "/", // <- to do
|
|
56
|
-
port: this.server.endpoints[0].port
|
|
51
|
+
port: this.server.endpoints[0].port
|
|
57
52
|
});
|
|
58
53
|
setImmediate(() => {
|
|
59
54
|
this.emit("serverRegistered");
|
|
@@ -61,7 +56,7 @@ export class RegisterServerManagerMDNSONLY
|
|
|
61
56
|
});
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
public dispose() {
|
|
59
|
+
public dispose(): void {
|
|
65
60
|
assert(!this.bonjour.isStarted());
|
|
66
61
|
assert(this.server);
|
|
67
62
|
this.server = undefined;
|
|
@@ -23,7 +23,6 @@ export interface OperationLimitsOptions {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class OperationLimits {
|
|
26
|
-
|
|
27
26
|
public maxNodesPerRead: number;
|
|
28
27
|
public maxNodesPerBrowse: number;
|
|
29
28
|
public maxNodesPerWrite: number;
|
|
@@ -38,7 +37,6 @@ export class OperationLimits {
|
|
|
38
37
|
public maxNodesPerTranslateBrowsePathsToNodeIds: number;
|
|
39
38
|
|
|
40
39
|
constructor(options: OperationLimitsOptions) {
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
* @property maxNodesPerRead
|
|
44
42
|
* @default 0
|
|
@@ -98,7 +96,6 @@ export class OperationLimits {
|
|
|
98
96
|
* @default 0
|
|
99
97
|
*/
|
|
100
98
|
this.maxNodesPerTranslateBrowsePathsToNodeIds = options.maxNodesPerTranslateBrowsePathsToNodeIds || 0;
|
|
101
|
-
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
101
|
|
|
@@ -120,7 +117,6 @@ export interface ServerCapabilitiesOptions {
|
|
|
120
117
|
/**
|
|
121
118
|
*/
|
|
122
119
|
export class ServerCapabilities {
|
|
123
|
-
|
|
124
120
|
public maxBrowseContinuationPoints: number;
|
|
125
121
|
public maxHistoryContinuationPoints: number;
|
|
126
122
|
public maxStringLength: number;
|
|
@@ -135,7 +131,6 @@ export class ServerCapabilities {
|
|
|
135
131
|
public softwareCertificates: SignedSoftwareCertificate[];
|
|
136
132
|
|
|
137
133
|
constructor(options: ServerCapabilitiesOptions) {
|
|
138
|
-
|
|
139
134
|
options = options || {};
|
|
140
135
|
options.operationLimits = options.operationLimits || {};
|
|
141
136
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @module node-opcua-server
|
|
3
3
|
*/
|
|
4
4
|
// tslint:disable:no-console
|
|
5
|
-
import * as async from "async";
|
|
6
|
-
import * as chalk from "chalk";
|
|
7
5
|
import { EventEmitter } from "events";
|
|
8
6
|
import * as net from "net";
|
|
9
7
|
import { Server, Socket } from "net";
|
|
8
|
+
import * as chalk from "chalk";
|
|
9
|
+
import * as async from "async";
|
|
10
10
|
|
|
11
11
|
import { assert } from "node-opcua-assert";
|
|
12
12
|
import { ICertificateManager, OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
@@ -213,16 +213,16 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
213
213
|
private _channels: { [key: string]: ServerSecureChannelLayer };
|
|
214
214
|
private _server?: Server;
|
|
215
215
|
private _endpoints: EndpointDescription[];
|
|
216
|
-
private _listen_callback
|
|
217
|
-
private _started
|
|
216
|
+
private _listen_callback?: (err?: Error) => void;
|
|
217
|
+
private _started = false;
|
|
218
218
|
private _counter = OPCUAServerEndPointCounter++;
|
|
219
219
|
private _policy_deduplicator: { [key: string]: number } = {};
|
|
220
220
|
constructor(options: OPCUAServerEndPointOptions) {
|
|
221
221
|
super();
|
|
222
222
|
|
|
223
|
-
assert(!Object.prototype.hasOwnProperty.call(options,"certificate"), "expecting a certificateChain instead");
|
|
224
|
-
assert(Object.prototype.hasOwnProperty.call(options,"certificateChain"), "expecting a certificateChain");
|
|
225
|
-
assert(Object.prototype.hasOwnProperty.call(options,"privateKey"));
|
|
223
|
+
assert(!Object.prototype.hasOwnProperty.call(options, "certificate"), "expecting a certificateChain instead");
|
|
224
|
+
assert(Object.prototype.hasOwnProperty.call(options, "certificateChain"), "expecting a certificateChain");
|
|
225
|
+
assert(Object.prototype.hasOwnProperty.call(options, "privateKey"));
|
|
226
226
|
|
|
227
227
|
this.certificateManager = options.certificateManager;
|
|
228
228
|
|
|
@@ -259,7 +259,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
259
259
|
assert(this.serverInfo !== null && typeof this.serverInfo === "object");
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
public dispose() {
|
|
262
|
+
public dispose(): void {
|
|
263
263
|
this._certificateChain = emptyCertificate;
|
|
264
264
|
this._privateKey = emptyPrivateKeyPEM;
|
|
265
265
|
|
|
@@ -272,7 +272,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
272
272
|
this._endpoints = [];
|
|
273
273
|
|
|
274
274
|
this._server = undefined;
|
|
275
|
-
this._listen_callback =
|
|
275
|
+
this._listen_callback = undefined;
|
|
276
276
|
|
|
277
277
|
this.removeAllListeners();
|
|
278
278
|
}
|
|
@@ -353,7 +353,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
353
353
|
securityMode: MessageSecurityMode,
|
|
354
354
|
securityPolicy: SecurityPolicy,
|
|
355
355
|
options?: EndpointDescriptionParams
|
|
356
|
-
) {
|
|
356
|
+
): void {
|
|
357
357
|
if (!options) {
|
|
358
358
|
options = {
|
|
359
359
|
hostname: getFullyQualifiedDomainName(),
|
|
@@ -414,13 +414,13 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
414
414
|
);
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
public addRestrictedEndpointDescription(options: EndpointDescriptionParams) {
|
|
417
|
+
public addRestrictedEndpointDescription(options: EndpointDescriptionParams): void {
|
|
418
418
|
options = { ...options };
|
|
419
419
|
options.restricted = true;
|
|
420
420
|
return this.addEndpointDescription(MessageSecurityMode.None, SecurityPolicy.None, options);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
-
public addStandardEndpointDescriptions(options?: AddStandardEndpointDescriptionsParam) {
|
|
423
|
+
public addStandardEndpointDescriptions(options?: AddStandardEndpointDescriptionsParam): void {
|
|
424
424
|
options = options || {};
|
|
425
425
|
|
|
426
426
|
options.securityModes = options.securityModes || defaultSecurityModes;
|
|
@@ -473,7 +473,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
473
473
|
* @method listen
|
|
474
474
|
* @async
|
|
475
475
|
*/
|
|
476
|
-
public listen(callback: (err?: Error) => void) {
|
|
476
|
+
public listen(callback: (err?: Error) => void): void {
|
|
477
477
|
assert(typeof callback === "function");
|
|
478
478
|
assert(!this._started, "OPCUAServerEndPoint is already listening");
|
|
479
479
|
|
|
@@ -499,7 +499,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
499
499
|
);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
public killClientSockets(callback: (err?: Error) => void) {
|
|
502
|
+
public killClientSockets(callback: (err?: Error) => void): void {
|
|
503
503
|
for (const channel of this.getChannels()) {
|
|
504
504
|
const hacked_channel = channel as any;
|
|
505
505
|
if (hacked_channel.transport && hacked_channel.transport._socket) {
|
|
@@ -511,7 +511,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
511
511
|
callback();
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
public suspendConnection(callback: (err?: Error) => void) {
|
|
514
|
+
public suspendConnection(callback: (err?: Error) => void): void {
|
|
515
515
|
if (!this._started) {
|
|
516
516
|
return callback(new Error("Connection already suspended !!"));
|
|
517
517
|
}
|
|
@@ -530,11 +530,11 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
530
530
|
callback();
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
public restoreConnection(callback: (err?: Error) => void) {
|
|
533
|
+
public restoreConnection(callback: (err?: Error) => void): void {
|
|
534
534
|
this.listen(callback);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
-
public abruptlyInterruptChannels() {
|
|
537
|
+
public abruptlyInterruptChannels(): void {
|
|
538
538
|
for (const channel of Object.values(this._channels)) {
|
|
539
539
|
channel.abruptlyInterrupt();
|
|
540
540
|
}
|
|
@@ -544,7 +544,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
544
544
|
* @method shutdown
|
|
545
545
|
* @async
|
|
546
546
|
*/
|
|
547
|
-
public shutdown(callback: (err?: Error) => void) {
|
|
547
|
+
public shutdown(callback: (err?: Error) => void): void {
|
|
548
548
|
debugLog("OPCUAServerEndPoint#shutdown ");
|
|
549
549
|
|
|
550
550
|
if (this._started) {
|
|
@@ -627,12 +627,10 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
627
627
|
}
|
|
628
628
|
|
|
629
629
|
private _dump_statistics() {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
self._server!.getConnections((err: Error | null, count: number) => {
|
|
630
|
+
this._server!.getConnections((err: Error | null, count: number) => {
|
|
633
631
|
debugLog(chalk.cyan("CONCURRENT CONNECTION = "), count);
|
|
634
632
|
});
|
|
635
|
-
debugLog(chalk.cyan("MAX CONNECTIONS = "),
|
|
633
|
+
debugLog(chalk.cyan("MAX CONNECTIONS = "), this._server!.maxConnections);
|
|
636
634
|
}
|
|
637
635
|
|
|
638
636
|
private _setup_server() {
|
|
@@ -642,7 +640,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
642
640
|
// xx console.log(" Server with max connections ", self.maxConnections);
|
|
643
641
|
this._server.maxConnections = this.maxConnections + 1; // plus one extra
|
|
644
642
|
|
|
645
|
-
this._listen_callback =
|
|
643
|
+
this._listen_callback = undefined;
|
|
646
644
|
this._server
|
|
647
645
|
.on("connection", (socket: NodeJS.Socket) => {
|
|
648
646
|
// istanbul ignore next
|
|
@@ -750,7 +748,7 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
750
748
|
// as they will need to be interrupted when OPCUAServerEndPoint is closed
|
|
751
749
|
assert(this._started, "OPCUAServerEndPoint must be started");
|
|
752
750
|
|
|
753
|
-
assert(!
|
|
751
|
+
assert(!Object.prototype.hasOwnProperty.call(this._channels, channel.hashKey), " channel already preregistered!");
|
|
754
752
|
|
|
755
753
|
this._channels[channel.hashKey] = channel;
|
|
756
754
|
|
|
@@ -810,11 +808,11 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
810
808
|
*/
|
|
811
809
|
private _unregisterChannel(channel: ServerSecureChannelLayer): void {
|
|
812
810
|
debugLog("_un-registerChannel channel.hashKey", channel.hashKey);
|
|
813
|
-
if (!
|
|
811
|
+
if (!Object.prototype.hasOwnProperty.call(this._channels, channel.hashKey)) {
|
|
814
812
|
return;
|
|
815
813
|
}
|
|
816
814
|
|
|
817
|
-
assert(
|
|
815
|
+
assert(Object.prototype.hasOwnProperty.call(this._channels, channel.hashKey), "channel is not registered");
|
|
818
816
|
|
|
819
817
|
/**
|
|
820
818
|
* @event closeChannel
|
|
@@ -839,8 +837,8 @@ export class OPCUAServerEndPoint extends EventEmitter implements ServerSecureCha
|
|
|
839
837
|
|
|
840
838
|
private _end_listen(err?: Error) {
|
|
841
839
|
assert(typeof this._listen_callback === "function");
|
|
842
|
-
this._listen_callback(err);
|
|
843
|
-
this._listen_callback =
|
|
840
|
+
this._listen_callback!(err);
|
|
841
|
+
this._listen_callback = undefined;
|
|
844
842
|
}
|
|
845
843
|
|
|
846
844
|
/**
|
|
@@ -999,8 +997,8 @@ function estimateSecurityLevel(securityMode: MessageSecurityMode, securityPolicy
|
|
|
999
997
|
*/
|
|
1000
998
|
function _makeEndpointDescription(options: MakeEndpointDescriptionOptions): EndpointDescriptionEx {
|
|
1001
999
|
assert(isFinite(options.port), "expecting a valid port number");
|
|
1002
|
-
assert(Object.prototype.hasOwnProperty.call(options,"serverCertificateChain"));
|
|
1003
|
-
assert(!Object.prototype.hasOwnProperty.call(options,"serverCertificate"));
|
|
1000
|
+
assert(Object.prototype.hasOwnProperty.call(options, "serverCertificateChain"));
|
|
1001
|
+
assert(!Object.prototype.hasOwnProperty.call(options, "serverCertificate"));
|
|
1004
1002
|
assert(!!options.securityMode); // s.MessageSecurityMode
|
|
1005
1003
|
assert(!!options.securityPolicy);
|
|
1006
1004
|
assert(options.server !== null && typeof options.server === "object");
|