node-opcua-local-discovery-server 2.100.0 → 2.102.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.
@@ -17,7 +17,6 @@ const Vorpal = require("vorpal");
17
17
  const vorpal_repl = require("vorpal-repl");
18
18
  const envPaths = require("env-paths");
19
19
 
20
-
21
20
  const paths = envPaths("node-opcua-local-discovery-server");
22
21
  const configFolder = paths.config;
23
22
  const pkiFolder = path.join(configFolder, "PKI");
@@ -28,20 +27,19 @@ const serverCertificateManager = new OPCUACertificateManager({
28
27
  });
29
28
 
30
29
  async function getIpAddresses() {
31
-
32
30
  const ipAddresses = [];
33
31
  const interfaces = os.networkInterfaces();
34
- Object.keys(interfaces).forEach(function(interfaceName) {
32
+ Object.keys(interfaces).forEach(function (interfaceName) {
35
33
  let alias = 0;
36
34
 
37
35
  interfaces[interfaceName].forEach((iFace) => {
38
- if ('IPv4' !== iFace.family || iFace.internal !== false) {
36
+ if ("IPv4" !== iFace.family || iFace.internal !== false) {
39
37
  // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
40
38
  return;
41
39
  }
42
40
  if (alias >= 1) {
43
41
  // this single interface has multiple ipv4 addresses
44
- console.log(interfaceName + ':' + alias, iFace.address);
42
+ console.log(interfaceName + ":" + alias, iFace.address);
45
43
  ipAddresses.push(iFace.address);
46
44
  } else {
47
45
  // this interface has only one ipv4 address
@@ -55,11 +53,9 @@ async function getIpAddresses() {
55
53
  }
56
54
  const applicationUri = "";
57
55
 
58
-
59
56
  const argv = yargs(process.argv)
60
57
  .wrap(132)
61
58
 
62
-
63
59
  .number("port")
64
60
  .describe("port", "port to listen to (default: 4840)")
65
61
  .default("port", 4840)
@@ -72,23 +68,23 @@ const argv = yargs(process.argv)
72
68
  .describe("force", "force recreation of LDS self-signed certification (taking into account alternateHostname) ")
73
69
  .default("force", false)
74
70
 
75
-
76
71
  .string("alternateHostname")
77
72
  .describe("alternateHostname ")
73
+ .string("hostname")
74
+ .describe("hostname", "the hostname")
78
75
 
79
76
  .string("applicationName")
80
77
  .describe("applicationName", "the application name")
81
78
  .default("applicationName", "NodeOPCUA-DiscoveryServer")
82
79
 
83
-
84
80
  .alias("a", "alternateHostname")
85
81
  .alias("n", "applicationName")
86
82
  .alias("p", "port")
83
+ .alias("h", "hostname")
87
84
  .alias("f", "force")
88
85
  .alias("t", "tolerant")
89
86
 
90
- .help(true)
91
- .argv;
87
+ .help(true).argv;
92
88
 
93
89
  const port = argv.port;
94
90
  const automaticallyAcceptUnknownCertificate = argv.tolerant;
@@ -100,10 +96,13 @@ console.log("applicationName ", applicationName);
100
96
 
101
97
  (async () => {
102
98
  try {
103
-
104
- const fqdn = process.env.HOSTNAME || await extractFullyQualifiedDomainName();
99
+ const fqdn = process.env.HOSTNAME || argv.hostname || (await extractFullyQualifiedDomainName());
100
+ const hostname = argv.hostname || fqdn;
101
+ const alternateHostname = argv.alternateHostname || undefined;
105
102
 
106
103
  console.log("fqdn ", fqdn);
104
+ console.log("hostname ", hostname);
105
+ console.log("alternateHostname ", alternateHostname);
107
106
  const applicationUri = makeApplicationUrn(fqdn, argv.applicationName);
108
107
 
109
108
  await serverCertificateManager.initialize();
@@ -113,7 +112,6 @@ console.log("applicationName ", applicationName);
113
112
  assert(fs.existsSync(privateKeyFile), "expecting private key");
114
113
 
115
114
  if (!fs.existsSync(certificateFile) || force) {
116
-
117
115
  console.log("Creating self-signed certificate", certificateFile);
118
116
 
119
117
  await serverCertificateManager.createSelfSignedCertificate({
@@ -123,12 +121,11 @@ console.log("applicationName ", applicationName);
123
121
  outputFile: certificateFile,
124
122
  subject: "/CN=Sterfive/DC=NodeOPCUA-LocalDiscoveryServer",
125
123
  startDate: new Date(),
126
- validity: 365 * 10,
127
- })
124
+ validity: 365 * 10
125
+ });
128
126
  }
129
127
  assert(fs.existsSync(certificateFile));
130
128
 
131
-
132
129
  const discoveryServer = new OPCUADiscoveryServer({
133
130
  // register
134
131
  port,
@@ -138,7 +135,10 @@ console.log("applicationName ", applicationName);
138
135
  automaticallyAcceptUnknownCertificate,
139
136
  serverInfo: {
140
137
  applicationUri
141
- }
138
+ },
139
+ hostname,
140
+ alternateHostname,
141
+ noUserIdentityTokens: true
142
142
  });
143
143
 
144
144
  try {
@@ -154,13 +154,11 @@ console.log("applicationName ", applicationName);
154
154
  console.log("rejected Folder ", discoveryServer.serverCertificateManager.rejectedFolder);
155
155
  console.log("trusted Folder ", discoveryServer.serverCertificateManager.trustedFolder);
156
156
 
157
-
158
157
  const vorpal = new Vorpal();
159
158
  vorpal
160
159
  .command("info")
161
160
  .description("display list of registered servers.")
162
- .action(function(args, callback) {
163
-
161
+ .action(function (args, callback) {
164
162
  this.log(discoveryServer.serverInfo.toString());
165
163
  // xx this.log(discoveryServer.endpoints[0]);
166
164
 
@@ -187,11 +185,8 @@ console.log("applicationName ", applicationName);
187
185
  callback();
188
186
  });
189
187
  vorpal.delimiter("local-discovery-server$").use(vorpal_repl).show();
190
-
191
- }
192
- catch (err) {
188
+ } catch (err) {
193
189
  console.log(err.message);
194
190
  console.log(err);
195
191
  }
196
192
  })();
197
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-local-discovery-server",
3
- "version": "2.100.0",
3
+ "version": "2.102.0",
4
4
  "description": "pure nodejs OPCUA SDK - module local-discovery-server",
5
5
  "bin": {
6
6
  "lds": "./bin/local-discovery-server.js",
@@ -28,12 +28,12 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "env-paths": "2.2.1",
31
- "node-opcua": "2.100.0",
31
+ "node-opcua": "2.102.0",
32
32
  "vorpal": "^1.12.0",
33
33
  "vorpal-repl": "^1.1.8",
34
34
  "yargs": "15.4.1"
35
35
  },
36
36
  "homepage": "http://node-opcua.github.io/",
37
- "gitHead": "e143ff72418bb3db8c0a2cb8d4b7e54a90521a73",
37
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
38
38
  "files": []
39
39
  }