node-opcua-local-discovery-server 2.51.0 → 2.55.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/Dockerfile CHANGED
@@ -1,14 +1,14 @@
1
- FROM node:alpine
2
- RUN apk add openssl
3
- WORKDIR /root
4
- COPY package.json .
5
- RUN npm init -y && npm install
6
- ENV HOSTNAME=%fqdn%
7
- EXPOSE 4840/tcp
8
- # expose mDNS bonjour port for zero conf
9
- EXPOSE 5353/udp
10
- COPY ./bin/local-discovery-server.js .
11
- RUN which node
12
- ENTRYPOINT ["/usr/local/bin/node" , "/root/local-discovery-server.js"]
13
- CMD [""]
1
+ FROM node:alpine
2
+ RUN apk add openssl
3
+ WORKDIR /root
4
+ COPY package.json .
5
+ RUN npm init -y && npm install
6
+ ENV HOSTNAME=%fqdn%
7
+ EXPOSE 4840/tcp
8
+ # expose mDNS bonjour port for zero conf
9
+ EXPOSE 5353/udp
10
+ COPY ./bin/local-discovery-server.js .
11
+ RUN which node
12
+ ENTRYPOINT ["/usr/local/bin/node" , "/root/local-discovery-server.js"]
13
+ CMD [""]
14
14
  # docker run -it -p 4840:4840 -v c:\temp\_config:/root/.config lds
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014-2021 Etienne Rossignon
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2021 Etienne Rossignon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/NOTES.md CHANGED
@@ -1,30 +1,30 @@
1
- ## Notes
2
-
3
- ### updating the docker image to hub.docker.com
4
-
5
- - login to docker
6
-
7
- ```
8
- $ docker login --username=_your_hub_username --email=youremail@company.com
9
- ```
10
-
11
- - check docker image id
12
-
13
- ```
14
- $ docker images list
15
-
16
- ```
17
-
18
- - build docker image (with tag lds)
19
-
20
- ```
21
- $ npm run docker-build
22
-
23
- ```
24
-
25
- - push image
26
-
27
- ```
28
- $ docker tag lds sterfive/lds:1.0
29
- $ docker push sterfive/lds:1.0
30
- ```
1
+ ## Notes
2
+
3
+ ### updating the docker image to hub.docker.com
4
+
5
+ - login to docker
6
+
7
+ ```
8
+ $ docker login --username=_your_hub_username --email=youremail@company.com
9
+ ```
10
+
11
+ - check docker image id
12
+
13
+ ```
14
+ $ docker images list
15
+
16
+ ```
17
+
18
+ - build docker image (with tag lds)
19
+
20
+ ```
21
+ $ npm run docker-build
22
+
23
+ ```
24
+
25
+ - push image
26
+
27
+ ```
28
+ $ docker tag lds sterfive/lds:1.0
29
+ $ docker push sterfive/lds:1.0
30
+ ```
package/README.md CHANGED
@@ -1,84 +1,84 @@
1
- # node-opcua-local-discovery-server
2
-
3
- A local discovery server made with node-opcua that you can easily deploy using npm or docker
4
-
5
- ## installing the LDS using npm
6
-
7
- ```
8
- $ npm install -g node-opcua-local-discovery-server
9
- $ lds --version
10
- ```
11
-
12
- ## running from NPX
13
-
14
- ```
15
- $npx node-opcua-local-discovery-server --help
16
- ```
17
-
18
- | Command | type | alias | default | comment |
19
- | ------------------- | ------- | ----- | ------- | --------------------------------------------------------------------------------- |
20
- | --help | | | | display help message |
21
- | --version | | | | display the node-opcua version used by the lds |
22
- | --alternateHostname | | | | alternate compute name used when certificate is created (see note) |
23
- | --force | boolean | -f | false | force the creation of the certificate (overwrite existing certificate) (see note) |
24
- | --port | number | -p | 4840 | the LDS tcp listening port |
25
- | --tolerant | boolean | -t | true | if set, the LDS will automatically accept as valid any new server certificate |
26
-
27
- notes!
28
-
29
- - LDS certificate is only created the first time he LDS program is run or if the certificate file cannot be found or if the `--force` argument is passed to the command line.
30
-
31
- - `alternateHostname` must be set appropriately when certificate is created.
32
-
33
- - it is recommended to use `--tolerant false` in production environment for extra security
34
-
35
- - if `--tolerant false` is set to false, your server may fail to register itself to the LDS,as LDS will reject the connection because the certificate is not known. You will have to make sure that your server certificate file existing the trusted folder ( and is not present in the rejected folder of the lds pki).
36
- - the LDS display in the console the location of the `trusted` certificate folders,
37
- - you can manually move rejected certificate file from the rejected folder to the trusted/cert folder to trust them.
38
- - if `--tolerant true` or not specified, then the LDS accept secure connection from any server, unless server certificate appears in the `rejected` folder already.
39
-
40
- ```
41
- # docker run sterfive/lds:latest --help
42
- Options:
43
- --version Show version number [boolean]
44
- --alternateHostname
45
- --help Show help [boolean]
46
- -n, --applicationName the application name [string]
47
- -p, --port port to listen to (default: 4840) [number]
48
- -f, --force force recreation of LDS self-signed certification (taking into account alternateHostname) [boolean]
49
- -t, --tolerant automatically accept unknown registering server certificate [boolean]
50
- ```
51
-
52
- ## running LDS in a docker container
53
-
54
- ### in the background
55
-
56
- #### under linux
57
-
58
- ```
59
- $ docker run -d -p 4840:4840 -v /temp/lds-config:/root/.config -e HOSTNAME=`hostname --fqdn` sterfive/lds:latest
60
- ```
61
-
62
- #### on windows
63
-
64
- ```
65
- $ docker run -d -p 4840:4840 -v C:\temp\lds-config:/root/.config -e HOSTNAME=%COMPUTERNAME% sterfive/lds:latest
66
- ```
67
-
68
- ### interactively
69
-
70
- if you want to run the lds interactively use `-it` instead of `-d` in the above commands.
71
-
72
- #### passing argument
73
-
74
- You can pass some command arguments to the LDS when you run it with docker. Simply add them after `lds`
75
-
76
- #### checking the discovery server certificate
77
-
78
- - By using the `-v` command the generated certificate will be in a permanent drive of your docker host machine.
79
- - Next time you run the LDS the certificate will not be recreated if it exists already unless you use the `-f` command.
80
- - you can check that the certificate with openssl using this command:
81
-
82
- ```
83
- openssl x509 -in c:\sterfive_config\node-opcua-local-discovery-server-nodejs\pki\local_discovery_server_certificate.pem -text
84
- ```
1
+ # node-opcua-local-discovery-server
2
+
3
+ A local discovery server made with node-opcua that you can easily deploy using npm or docker
4
+
5
+ ## installing the LDS using npm
6
+
7
+ ```
8
+ $ npm install -g node-opcua-local-discovery-server
9
+ $ lds --version
10
+ ```
11
+
12
+ ## running from NPX
13
+
14
+ ```
15
+ $npx node-opcua-local-discovery-server --help
16
+ ```
17
+
18
+ | Command | type | alias | default | comment |
19
+ | ------------------- | ------- | ----- | ------- | --------------------------------------------------------------------------------- |
20
+ | --help | | | | display help message |
21
+ | --version | | | | display the node-opcua version used by the lds |
22
+ | --alternateHostname | | | | alternate compute name used when certificate is created (see note) |
23
+ | --force | boolean | -f | false | force the creation of the certificate (overwrite existing certificate) (see note) |
24
+ | --port | number | -p | 4840 | the LDS tcp listening port |
25
+ | --tolerant | boolean | -t | true | if set, the LDS will automatically accept as valid any new server certificate |
26
+
27
+ notes!
28
+
29
+ - LDS certificate is only created the first time he LDS program is run or if the certificate file cannot be found or if the `--force` argument is passed to the command line.
30
+
31
+ - `alternateHostname` must be set appropriately when certificate is created.
32
+
33
+ - it is recommended to use `--tolerant false` in production environment for extra security
34
+
35
+ - if `--tolerant false` is set to false, your server may fail to register itself to the LDS,as LDS will reject the connection because the certificate is not known. You will have to make sure that your server certificate file existing the trusted folder ( and is not present in the rejected folder of the lds pki).
36
+ - the LDS display in the console the location of the `trusted` certificate folders,
37
+ - you can manually move rejected certificate file from the rejected folder to the trusted/cert folder to trust them.
38
+ - if `--tolerant true` or not specified, then the LDS accept secure connection from any server, unless server certificate appears in the `rejected` folder already.
39
+
40
+ ```
41
+ # docker run sterfive/lds:latest --help
42
+ Options:
43
+ --version Show version number [boolean]
44
+ --alternateHostname
45
+ --help Show help [boolean]
46
+ -n, --applicationName the application name [string]
47
+ -p, --port port to listen to (default: 4840) [number]
48
+ -f, --force force recreation of LDS self-signed certification (taking into account alternateHostname) [boolean]
49
+ -t, --tolerant automatically accept unknown registering server certificate [boolean]
50
+ ```
51
+
52
+ ## running LDS in a docker container
53
+
54
+ ### in the background
55
+
56
+ #### under linux
57
+
58
+ ```
59
+ $ docker run -d -p 4840:4840 -v /temp/lds-config:/root/.config -e HOSTNAME=`hostname --fqdn` sterfive/lds:latest
60
+ ```
61
+
62
+ #### on windows
63
+
64
+ ```
65
+ $ docker run -d -p 4840:4840 -v C:\temp\lds-config:/root/.config -e HOSTNAME=%COMPUTERNAME% sterfive/lds:latest
66
+ ```
67
+
68
+ ### interactively
69
+
70
+ if you want to run the lds interactively use `-it` instead of `-d` in the above commands.
71
+
72
+ #### passing argument
73
+
74
+ You can pass some command arguments to the LDS when you run it with docker. Simply add them after `lds`
75
+
76
+ #### checking the discovery server certificate
77
+
78
+ - By using the `-v` command the generated certificate will be in a permanent drive of your docker host machine.
79
+ - Next time you run the LDS the certificate will not be recreated if it exists already unless you use the `-f` command.
80
+ - you can check that the certificate with openssl using this command:
81
+
82
+ ```
83
+ openssl x509 -in c:\sterfive_config\node-opcua-local-discovery-server-nodejs\pki\local_discovery_server_certificate.pem -text
84
+ ```
@@ -1,197 +1,197 @@
1
- #!/usr/bin/env node
2
- const os = require("os");
3
- const path = require("path");
4
- const fs = require("fs");
5
- const yargs = require("yargs/yargs");
6
-
7
- const {
8
- assert,
9
- OPCUACertificateManager,
10
- OPCUADiscoveryServer,
11
- extractFullyQualifiedDomainName,
12
- makeApplicationUrn
13
- } = require("node-opcua");
14
-
15
- // Create a new instance of vantage.
16
- const Vorpal = require("vorpal");
17
- const vorpal_repl = require("vorpal-repl");
18
- const envPaths = require("env-paths");
19
-
20
-
21
- const paths = envPaths("node-opcua-local-discovery-server");
22
- const configFolder = paths.config;
23
- const pkiFolder = path.join(configFolder, "PKI");
24
- const serverCertificateManager = new OPCUACertificateManager({
25
- automaticallyAcceptUnknownCertificate: true,
26
- rootFolder: pkiFolder,
27
- name: "PKI"
28
- });
29
-
30
- async function getIpAddresses() {
31
-
32
- const ipAddresses = [];
33
- const interfaces = os.networkInterfaces();
34
- Object.keys(interfaces).forEach(function(interfaceName) {
35
- let alias = 0;
36
-
37
- interfaces[interfaceName].forEach((iFace) => {
38
- if ('IPv4' !== iFace.family || iFace.internal !== false) {
39
- // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
40
- return;
41
- }
42
- if (alias >= 1) {
43
- // this single interface has multiple ipv4 addresses
44
- console.log(interfaceName + ':' + alias, iFace.address);
45
- ipAddresses.push(iFace.address);
46
- } else {
47
- // this interface has only one ipv4 address
48
- console.log(interfaceName, iFace.address);
49
- ipAddresses.push(iFace.address);
50
- }
51
- ++alias;
52
- });
53
- });
54
- return ipAddresses;
55
- }
56
- const applicationUri = "";
57
-
58
-
59
- const argv = yargs(process.argv)
60
- .wrap(132)
61
-
62
-
63
- .number("port")
64
- .describe("port", "port to listen to (default: 4840)")
65
- .default("port", 4840)
66
-
67
- .boolean("tolerant")
68
- .describe("tolerant", "automatically accept unknown registering server certificate")
69
- .default("tolerant", true)
70
-
71
- .boolean("force")
72
- .describe("force", "force recreation of LDS self-signed certification (taking into account alternateHostname) ")
73
- .default("force", false)
74
-
75
-
76
- .string("alternateHostname")
77
- .describe("alternateHostname ")
78
-
79
- .string("applicationName")
80
- .describe("applicationName", "the application name")
81
- .default("applicationName", "NodeOPCUA-DiscoveryServer")
82
-
83
-
84
- .alias("a", "alternateHostname")
85
- .alias("n", "applicationName")
86
- .alias("p", "port")
87
- .alias("f", "force")
88
- .alias("t", "tolerant")
89
-
90
- .help(true)
91
- .argv;
92
-
93
- const port = argv.port;
94
- const automaticallyAcceptUnknownCertificate = argv.tolerant;
95
- const force = argv.force;
96
- const applicationName = argv.applicationName;
97
- console.log("port ", port);
98
- console.log("automatically accept unknown certificate", automaticallyAcceptUnknownCertificate);
99
- console.log("applicationName ", applicationName);
100
-
101
- (async () => {
102
- try {
103
-
104
- const fqdn = process.env.HOSTNAME || await extractFullyQualifiedDomainName();
105
-
106
- console.log("fqdn ", fqdn);
107
- const applicationUri = makeApplicationUrn(fqdn, argv.applicationName);
108
-
109
- await serverCertificateManager.initialize();
110
-
111
- const certificateFile = path.join(pkiFolder, "local_discovery_server_certificate.pem");
112
- const privateKeyFile = serverCertificateManager.privateKey;
113
- assert(fs.existsSync(privateKeyFile), "expecting private key");
114
-
115
- if (!fs.existsSync(certificateFile) || force) {
116
-
117
- console.log("Creating self-signed certificate", certificateFile);
118
-
119
- await serverCertificateManager.createSelfSignedCertificate({
120
- applicationUri,
121
- dns: argv.alternateHostname ? [argv.alternateHostname, fqdn] : [fqdn],
122
- ip: await getIpAddresses(),
123
- outputFile: certificateFile,
124
- subject: "/CN=Sterfive/DC=NodeOPCUA-LocalDiscoveryServer",
125
- startDate: new Date(),
126
- validity: 365 * 10,
127
- })
128
- }
129
- assert(fs.existsSync(certificateFile));
130
-
131
-
132
- const discoveryServer = new OPCUADiscoveryServer({
133
- // register
134
- port,
135
- certificateFile,
136
- privateKeyFile,
137
- serverCertificateManager,
138
- automaticallyAcceptUnknownCertificate,
139
- serverInfo: {
140
- applicationUri
141
- }
142
- });
143
-
144
- try {
145
- await discoveryServer.start();
146
- } catch (err) {
147
- console.log("Error , cannot start LDS ", err.message);
148
- console.log("Make sure that a LocalDiscoveryServer is not already running on port 4840");
149
- return;
150
- }
151
- console.log(discoveryServer.serverInfo.toString());
152
- console.log("discovery server started on port ", discoveryServer.endpoints[0].port);
153
- console.log("CTRL+C to stop");
154
- console.log("rejected Folder ", discoveryServer.serverCertificateManager.rejectedFolder);
155
- console.log("trusted Folder ", discoveryServer.serverCertificateManager.trustedFolder);
156
-
157
-
158
- const vorpal = new Vorpal();
159
- vorpal
160
- .command("info")
161
- .description("display list of registered servers.")
162
- .action(function(args, callback) {
163
-
164
- this.log(discoveryServer.serverInfo.toString());
165
- // xx this.log(discoveryServer.endpoints[0]);
166
-
167
- {
168
- const servers = Object.keys(discoveryServer.registeredServers);
169
- this.log("number of registered servers : ", servers.length);
170
-
171
- for (const serverKey of servers) {
172
- const server = discoveryServer.registeredServers[serverKey];
173
- this.log("key =", serverKey);
174
- this.log(server.toString());
175
- }
176
- }
177
- {
178
- const server2 = Object.keys(discoveryServer.mDnsResponder.registeredServers);
179
- this.log("number of mNDS registered servers : ", server2.length);
180
- for (const serverKey of server2) {
181
- const server = discoveryServer.mDnsResponder.registeredServers[serverKey];
182
- this.log("key =", serverKey);
183
- this.log(server.toString());
184
- }
185
- }
186
-
187
- callback();
188
- });
189
- vorpal.delimiter("local-discovery-server$").use(vorpal_repl).show();
190
-
191
- }
192
- catch (err) {
193
- console.log(err.message);
194
- console.log(err);
195
- }
196
- })();
197
-
1
+ #!/usr/bin/env node
2
+ const os = require("os");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+ const yargs = require("yargs/yargs");
6
+
7
+ const {
8
+ assert,
9
+ OPCUACertificateManager,
10
+ OPCUADiscoveryServer,
11
+ extractFullyQualifiedDomainName,
12
+ makeApplicationUrn
13
+ } = require("node-opcua");
14
+
15
+ // Create a new instance of vantage.
16
+ const Vorpal = require("vorpal");
17
+ const vorpal_repl = require("vorpal-repl");
18
+ const envPaths = require("env-paths");
19
+
20
+
21
+ const paths = envPaths("node-opcua-local-discovery-server");
22
+ const configFolder = paths.config;
23
+ const pkiFolder = path.join(configFolder, "PKI");
24
+ const serverCertificateManager = new OPCUACertificateManager({
25
+ automaticallyAcceptUnknownCertificate: true,
26
+ rootFolder: pkiFolder,
27
+ name: "PKI"
28
+ });
29
+
30
+ async function getIpAddresses() {
31
+
32
+ const ipAddresses = [];
33
+ const interfaces = os.networkInterfaces();
34
+ Object.keys(interfaces).forEach(function(interfaceName) {
35
+ let alias = 0;
36
+
37
+ interfaces[interfaceName].forEach((iFace) => {
38
+ if ('IPv4' !== iFace.family || iFace.internal !== false) {
39
+ // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
40
+ return;
41
+ }
42
+ if (alias >= 1) {
43
+ // this single interface has multiple ipv4 addresses
44
+ console.log(interfaceName + ':' + alias, iFace.address);
45
+ ipAddresses.push(iFace.address);
46
+ } else {
47
+ // this interface has only one ipv4 address
48
+ console.log(interfaceName, iFace.address);
49
+ ipAddresses.push(iFace.address);
50
+ }
51
+ ++alias;
52
+ });
53
+ });
54
+ return ipAddresses;
55
+ }
56
+ const applicationUri = "";
57
+
58
+
59
+ const argv = yargs(process.argv)
60
+ .wrap(132)
61
+
62
+
63
+ .number("port")
64
+ .describe("port", "port to listen to (default: 4840)")
65
+ .default("port", 4840)
66
+
67
+ .boolean("tolerant")
68
+ .describe("tolerant", "automatically accept unknown registering server certificate")
69
+ .default("tolerant", true)
70
+
71
+ .boolean("force")
72
+ .describe("force", "force recreation of LDS self-signed certification (taking into account alternateHostname) ")
73
+ .default("force", false)
74
+
75
+
76
+ .string("alternateHostname")
77
+ .describe("alternateHostname ")
78
+
79
+ .string("applicationName")
80
+ .describe("applicationName", "the application name")
81
+ .default("applicationName", "NodeOPCUA-DiscoveryServer")
82
+
83
+
84
+ .alias("a", "alternateHostname")
85
+ .alias("n", "applicationName")
86
+ .alias("p", "port")
87
+ .alias("f", "force")
88
+ .alias("t", "tolerant")
89
+
90
+ .help(true)
91
+ .argv;
92
+
93
+ const port = argv.port;
94
+ const automaticallyAcceptUnknownCertificate = argv.tolerant;
95
+ const force = argv.force;
96
+ const applicationName = argv.applicationName;
97
+ console.log("port ", port);
98
+ console.log("automatically accept unknown certificate", automaticallyAcceptUnknownCertificate);
99
+ console.log("applicationName ", applicationName);
100
+
101
+ (async () => {
102
+ try {
103
+
104
+ const fqdn = process.env.HOSTNAME || await extractFullyQualifiedDomainName();
105
+
106
+ console.log("fqdn ", fqdn);
107
+ const applicationUri = makeApplicationUrn(fqdn, argv.applicationName);
108
+
109
+ await serverCertificateManager.initialize();
110
+
111
+ const certificateFile = path.join(pkiFolder, "local_discovery_server_certificate.pem");
112
+ const privateKeyFile = serverCertificateManager.privateKey;
113
+ assert(fs.existsSync(privateKeyFile), "expecting private key");
114
+
115
+ if (!fs.existsSync(certificateFile) || force) {
116
+
117
+ console.log("Creating self-signed certificate", certificateFile);
118
+
119
+ await serverCertificateManager.createSelfSignedCertificate({
120
+ applicationUri,
121
+ dns: argv.alternateHostname ? [argv.alternateHostname, fqdn] : [fqdn],
122
+ ip: await getIpAddresses(),
123
+ outputFile: certificateFile,
124
+ subject: "/CN=Sterfive/DC=NodeOPCUA-LocalDiscoveryServer",
125
+ startDate: new Date(),
126
+ validity: 365 * 10,
127
+ })
128
+ }
129
+ assert(fs.existsSync(certificateFile));
130
+
131
+
132
+ const discoveryServer = new OPCUADiscoveryServer({
133
+ // register
134
+ port,
135
+ certificateFile,
136
+ privateKeyFile,
137
+ serverCertificateManager,
138
+ automaticallyAcceptUnknownCertificate,
139
+ serverInfo: {
140
+ applicationUri
141
+ }
142
+ });
143
+
144
+ try {
145
+ await discoveryServer.start();
146
+ } catch (err) {
147
+ console.log("Error , cannot start LDS ", err.message);
148
+ console.log("Make sure that a LocalDiscoveryServer is not already running on port 4840");
149
+ return;
150
+ }
151
+ console.log(discoveryServer.serverInfo.toString());
152
+ console.log("discovery server started on port ", discoveryServer.endpoints[0].port);
153
+ console.log("CTRL+C to stop");
154
+ console.log("rejected Folder ", discoveryServer.serverCertificateManager.rejectedFolder);
155
+ console.log("trusted Folder ", discoveryServer.serverCertificateManager.trustedFolder);
156
+
157
+
158
+ const vorpal = new Vorpal();
159
+ vorpal
160
+ .command("info")
161
+ .description("display list of registered servers.")
162
+ .action(function(args, callback) {
163
+
164
+ this.log(discoveryServer.serverInfo.toString());
165
+ // xx this.log(discoveryServer.endpoints[0]);
166
+
167
+ {
168
+ const servers = Object.keys(discoveryServer.registeredServers);
169
+ this.log("number of registered servers : ", servers.length);
170
+
171
+ for (const serverKey of servers) {
172
+ const server = discoveryServer.registeredServers[serverKey];
173
+ this.log("key =", serverKey);
174
+ this.log(server.toString());
175
+ }
176
+ }
177
+ {
178
+ const server2 = Object.keys(discoveryServer.mDnsResponder.registeredServers);
179
+ this.log("number of mNDS registered servers : ", server2.length);
180
+ for (const serverKey of server2) {
181
+ const server = discoveryServer.mDnsResponder.registeredServers[serverKey];
182
+ this.log("key =", serverKey);
183
+ this.log(server.toString());
184
+ }
185
+ }
186
+
187
+ callback();
188
+ });
189
+ vorpal.delimiter("local-discovery-server$").use(vorpal_repl).show();
190
+
191
+ }
192
+ catch (err) {
193
+ console.log(err.message);
194
+ console.log(err);
195
+ }
196
+ })();
197
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-local-discovery-server",
3
- "version": "2.51.0",
3
+ "version": "2.55.0",
4
4
  "description": "pure nodejs OPCUA SDK - local-discovery-server",
5
5
  "bin": {
6
6
  "lds": "./bin/local-discovery-server.js",
@@ -8,14 +8,14 @@
8
8
  "node-opcua-local-discovery-server": "./bin/local-discovery-server.js"
9
9
  },
10
10
  "scripts": {
11
- "lint": "tslint source/**/*.ts",
11
+ "lint": "eslint source/**/*.ts",
12
12
  "test": "echo no test",
13
13
  "build-docker": "docker build . -t lds"
14
14
  },
15
15
  "dependencies": {
16
16
  "bonjour": "^3.5.0",
17
17
  "env-paths": "2.2.1",
18
- "node-opcua": "2.51.0",
18
+ "node-opcua": "2.55.0",
19
19
  "vorpal": "^1.12.0",
20
20
  "vorpal-repl": "^1.1.8",
21
21
  "yargs": "15.4.1"
@@ -35,5 +35,5 @@
35
35
  "internet of things"
36
36
  ],
37
37
  "homepage": "http://node-opcua.github.io/",
38
- "gitHead": "75feb111daf7ec65fa0111e4fa5beb8987fd4945"
38
+ "gitHead": "28fdbfe1c5306fd0e69758ccacfa2c6d1722115c"
39
39
  }