How to use the node-opcua-hostname.getFullyQualifiedDomainName function in node-opcua-hostname

To help you get started, we’ve selected a few node-opcua-hostname examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
throw new Error(" invalid security ");
        }
        // istanbul ignore next
        if (securityMode !== MessageSecurityMode.None && securityPolicy === SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        //

        const port = this.port;

        // resource Path is a string added at the end of the url such as "/UA/Server"
        const resourcePath = (options.resourcePath || "").replace(/\\/g, "/");

        assert(resourcePath.length === 0 || resourcePath.charAt(0) === "/");

        const hostname = options.hostname || getFullyQualifiedDomainName();
        const endpointUrl = `opc.tcp://${hostname}:${port}${resourcePath}`;

        const endpoint_desc = this.getEndpointDescription(securityMode, securityPolicy, endpointUrl);

        // istanbul ignore next
        if (endpoint_desc) {
            throw new Error(" endpoint already exist");
        }

        // now build endpointUrl
        this._endpoints.push(_makeEndpointDescription({
            endpointUrl,
            hostname,
            port,

            server: this.serverInfo,
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
throw new Error(" invalid security ");
        }
        // istanbul ignore next
        if (securityMode !== MessageSecurityMode.None && securityPolicy === SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        //

        const port = this.port;

        // resource Path is a string added at the end of the url such as "/UA/Server"
        const resourcePath = (options.resourcePath || "").replace(/\\/g, "/");

        assert(resourcePath.length === 0 || resourcePath.charAt(0) === "/", "resourcePath should start with /");

        const hostname = options.hostname || getFullyQualifiedDomainName();
        const endpointUrl = `opc.tcp://${hostname}:${port}${resourcePath}`;

        const endpoint_desc = this.getEndpointDescription(securityMode, securityPolicy, endpointUrl);

        // istanbul ignore next
        if (endpoint_desc) {
            throw new Error(" endpoint already exist");
        }

        // now build endpointUrl
        this._endpoints.push(_makeEndpointDescription({
            endpointUrl,
            hostname,
            port,

            server: this.serverInfo,
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
public addEndpointDescription(
      securityMode: MessageSecurityMode,
      securityPolicy: SecurityPolicy,
      options?: EndpointDescriptionParams
    ) {
        if (!options) {
            options = { hostname: getFullyQualifiedDomainName() };
        }

        options.allowAnonymous = (options.allowAnonymous === undefined) ? true : options.allowAnonymous;

        // istanbul ignore next
        if (securityMode === MessageSecurityMode.None && securityPolicy !== SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        // istanbul ignore next
        if (securityMode !== MessageSecurityMode.None && securityPolicy === SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        //

        const port = this.port;
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / install_push_certitifate_management.ts View on Github external
async function install(this: OPCUAServerPartial): Promise {
    if (!this.$$privateKeyPEM) {
        this.$$privateKeyPEM =
            await promisify(fs.readFile)(this.serverCertificateManager.privateKey, "utf8");
    }

    if (!this.$$certificateChain) {

        const certificateFile = path.join(this.serverCertificateManager.rootDir, "own/certs/certificate.pem");
        const exists = await (promisify(fs.exists)(certificateFile));
        if (!exists) {

            // this is the first time server is launch
            // let's create a default self signed certificate with limited validity

            const fqdn = await getFullyQualifiedDomainName();
            const ipAddresses = await getIpAddresses();

            const applicationUri =
                (this.serverInfo ? this.serverInfo!.applicationUri! : null) || "uri:MISSING";

            const options = {

                applicationUri: this.serverInfo!.applicationUri!,

                dns: [fqdn],
                ip: ipAddresses,

                subject: "/CN=MyCommonName;/L=Paris",

                startDate: new Date(),
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
public addEndpointDescription(
      securityMode: MessageSecurityMode,
      securityPolicy: SecurityPolicy,
      options?: EndpointDescriptionParams
    ) {
        if (!options) {
            options = { hostname: getFullyQualifiedDomainName() };
        }

        options.allowAnonymous = (options.allowAnonymous === undefined) ? true : options.allowAnonymous;

        // istanbul ignore next
        if (securityMode === MessageSecurityMode.None && securityPolicy !== SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        // istanbul ignore next
        if (securityMode !== MessageSecurityMode.None && securityPolicy === SecurityPolicy.None) {
            throw new Error(" invalid security ");
        }
        //

        const port = this.port;
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
public addStandardEndpointDescriptions(options?: AddStandardEndpointDescriptionsParam) {

        options = options || {};

        options.securityModes = options.securityModes || defaultSecurityModes;
        options.securityPolicies = options.securityPolicies || defaultSecurityPolicies;

        const defaultHostname = options.hostname || getFullyQualifiedDomainName();

        let hostnames: string[] = [ defaultHostname ];

        options.alternateHostname =  options.alternateHostname || [];
        if (typeof options.alternateHostname === "string") {
            options.alternateHostname = [ options.alternateHostname];
        }
        hostnames = _.uniq(hostnames.concat(options.alternateHostname as string[]));

        for (const alternateHostname of hostnames ) {

            const optionsE = options as EndpointDescriptionParams;
            optionsE.hostname = alternateHostname;

            if (options.securityModes.indexOf(MessageSecurityMode.None) >= 0) {
                this.addEndpointDescription(MessageSecurityMode.None, SecurityPolicy.None, optionsE);
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
public addStandardEndpointDescriptions(options?: AddStandardEndpointDescriptionsParam) {

        options = options || {};

        options.securityModes = options.securityModes || defaultSecurityModes;
        options.securityPolicies = options.securityPolicies || defaultSecurityPolicies;

        const defaultHostname = options.hostname || getFullyQualifiedDomainName();

        let hostnames: string[] = [ defaultHostname ];

        options.alternateHostname =  options.alternateHostname || [];
        if (typeof options.alternateHostname === "string") {
            options.alternateHostname = [ options.alternateHostname];
        }
        hostnames = _.uniq(hostnames.concat(options.alternateHostname as string[]));


        for (const alternateHostname of hostnames ) {

            const optionsE = options as EndpointDescriptionParams;
            optionsE.hostname = alternateHostname;

            if (options.securityModes.indexOf(MessageSecurityMode.None) >= 0) {

node-opcua-hostname

pure nodejs OPCUA SDK - module hostname

MIT
Latest version published 6 months ago

Package Health Score

80 / 100
Full package analysis