Skip to main content

Signaling Server Architecture

The ErikrafT Drop signaling server facilitates peer discovery and WebRTC connection establishment through WebSocket communication. Built with Node.js and the ws library, it manages room-based peer grouping and message routing.

Server Overview

Main Server Entry Point

The server is initialized in server.js:

Configuration Endpoints

The server provides configuration via HTTP endpoints:

WebSocket Server Implementation

ErikrafTdropWsServer Class

The core WebSocket server is implemented in server/ws-server.js:

Connection Management

Peer Connection Process

1. Connection Validation

2. IP Validation

The server validates local IP addresses for LAN-only mode:

3. Initial Configuration

Room Management

Room Types

The server manages three types of rooms:

1. IP-Based Rooms (Local Network)

2. Secret Rooms (Paired Devices)

3. Public Rooms (Temporary Rooms)

Room Operations

Generic Room Join

Peer Notification

Device Pairing System

Pairing Initiation

Pair Key Generation

Pairing Join Process

Message Handling

Message Router

Signal Relay

Connection Monitoring

Keep-Alive System

Rate Limiting

Security Features

IP Filtering

  • LAN-Only Mode: Restricts connections to local IP addresses
  • IP Validation: Comprehensive IPv4 and IPv6 local address detection
  • Connection Rejection: Automatic termination of non-local connections

Input Validation

  • JSON Parsing: Safe parsing with error handling
  • UUID Validation: Strict peer ID format validation
  • Room Secret Validation: Length and character validation

Rate Limiting

  • Request Throttling: 10 requests per 10 seconds per peer
  • Pairing Limits: Prevents brute force pairing attempts
  • Connection Limits: Configurable maximum connections

Performance Optimization

Memory Management

  • Room Cleanup: Automatic removal of empty rooms
  • Timer Management: Proper cleanup of keep-alive timers
  • Connection Cleanup: Graceful connection termination

Message Efficiency

  • Binary Support: WebSocket binary frame support for file transfers
  • Message Batching: Efficient message routing within rooms
  • Compression: Optional message compression for large payloads
This signaling server provides a robust foundation for peer discovery and WebRTC connection establishment while maintaining security and performance.