Nodevisor Docs
Packages

@nodevisor/endpoint

Network endpoint definitions — protocol enum and pre-built port presets for firewall and service configuration.

Install

npm install @nodevisor/endpoint

Provides the Endpoint type, Protocol enum, and a set of common endpoint presets. Used by firewall modules like @nodevisor/ufw and cluster node configuration to define which ports and protocols to allow.


Protocol

The network protocol for an endpoint.

import { Protocol } from '@nodevisor/endpoint';

Protocol.TCP  // 'tcp'
Protocol.UDP  // 'udp'

Endpoint Type

An endpoint describes a named network port with its protocol:

type Endpoint = {
  name?: string;
  port: number;
  protocol: Protocol;
};

Create custom endpoints:

import { Protocol } from '@nodevisor/endpoint';

const dns: Endpoint = {
  name: 'dns',
  port: 53,
  protocol: Protocol.UDP,
};

const customApi: Endpoint = {
  name: 'api',
  port: 8080,
  protocol: Protocol.TCP,
};

Built-in Presets

Import common endpoints from the endpoints namespace:

import { endpoints } from '@nodevisor/endpoint';
PresetPortProtocolUse case
endpoints.ssh22TCPSSH access
endpoints.web80TCPHTTP traffic
endpoints.webSecure443TCPHTTPS traffic
endpoints.dockerSwarmManagement2377TCPDocker Swarm cluster management

Usage with UFW

Endpoints are used directly with the firewall module:

import $ from '@nodevisor/shell';
import UFW from '@nodevisor/ufw';
import { endpoints } from '@nodevisor/endpoint';

const $server = $.connect({ host: '10.0.0.10', username: 'root' });
const ufw = $server(UFW);

// Allow standard web traffic
await ufw.allow(endpoints.web);
await ufw.allow(endpoints.webSecure);
await ufw.allow(endpoints.ssh);

// Allow Docker Swarm management
await ufw.allow(endpoints.dockerSwarmManagement);

Usage with ClusterNode

Endpoints define which ports a cluster node exposes:

import { DockerNode } from '@nodevisor/docker';
import { endpoints } from '@nodevisor/endpoint';

const node = new DockerNode({
  host: '10.0.0.10',
  endpoints: [
    endpoints.ssh,
    endpoints.web,
    endpoints.webSecure,
    endpoints.dockerSwarmManagement,
  ],
});

On this page