Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _isValidServerType(serverType: ApplicationType): boolean {
switch (serverType) {
case ApplicationType.Client:
return false;
case ApplicationType.Server:
case ApplicationType.ClientAndServer:
case ApplicationType.DiscoveryServer:
return true;
}
return false;
}
constructor(options: OPCUADiscoveryServerOptions) {
const default_certificate_file = constructFilename("certificates/server_selfsigned_cert_2048.pem");
options.certificateFile = options.certificateFile || default_certificate_file;
assert(fs.existsSync(options.certificateFile));
const default_private_key_file = constructFilename("certificates/PKI/own/private/private_key.pem");
options.privateKeyFile = options.privateKeyFile || default_private_key_file;
assert(fs.existsSync(options.certificateFile));
const defaultApplicationUri = makeApplicationUrn("%FQDN%", "NodeOPCUA-DiscoveryServer");
options.serverInfo = options.serverInfo || {};
const serverInfo = options.serverInfo;
serverInfo.applicationType = ApplicationType.DiscoveryServer;
serverInfo.applicationUri = serverInfo.applicationUri || defaultApplicationUri;
serverInfo.productUri = serverInfo.productUri || "NodeOPCUA-DiscoveryServer";
serverInfo.applicationName = serverInfo.applicationName || { text: "NodeOPCUA-DiscoveryServer", locale: null };
serverInfo.gatewayServerUri = serverInfo.gatewayServerUri || "";
serverInfo.discoveryProfileUri = serverInfo.discoveryProfileUri || "";
serverInfo.discoveryUrls = serverInfo.discoveryUrls || [];
super(options);
this.bonjourHolder = new BonjourHolder();
const port = options.port || 4840;
this.capabilitiesForMDNS = ["LDS"];
this.registeredServers = {};