RELAYLINK

RelayLink data-plane SDKs

RelayLink SDKs let third-party applications reach private services published through RelayLink using standard TCP or UDP sockets. Per ADR-0036 and DES-010, SDKs never implement the internal NTP1 wire protocol; they connect strictly to exposed entries:

  • Authorized peer entries: Connect to the 127.0.0.1:<port> loopback listener opened by the local caller Agent.
  • Standard proxy entries: Connect directly to the Server's configured proxy listen host and port.

Strict Boundaries (Read First)

  • Zero relay secrets: Client secrets, channel access secrets, bind tokens, and plaintext credentials never enter the SDK process.
  • No internal framing or tunneling: SDKs do not implement NTP1 frames, multiplexing, NAT traversal, or VPN routing; tunneling and path selection stay inside the Agent and Server.
  • Channel config governs transport encryption: Authorized peer channels enforce inner TLS (or encrypted QUIC when preferDirect succeeds) between Agents, and SDKs never disable or downgrade it. Standard proxy entries forward raw bytes unless the target workload itself uses TLS; SDKs never claim standard entries add encryption.
  • No hidden pooling or reconnect loops: Channels enforce connection quotas and real-time revocation, so hidden retries cause quota contention and masked failures. Applications control retry and backoff explicitly.
  • Management-plane scope: This directory and RelayLink.Sdk currently implement the data plane. Under DES-010, the five non-.NET languages adhere to zero external dependencies (unable to access OS keyrings), so Phase-1 limited management-plane support is committed for C#/.NET only (via RelayLink.AutomationClient using CLI-paired credentials).

Entry Discovery vs. Explicit Configuration

  • Auto-discovery for authorized peer mappings: Query the local Agent's read-only v2 API (http://127.0.0.1:<dashboardPort>/api/v2/mappings, default dashboardPort=18081), matching enabled mappings by targetClientId, targetChannelId, and optional profileId (for multi-server Agents) to obtain an EntryDescriptor.
  • Explicit config required for standard proxy entries: AgentChannelView and AgentMappingView report only local loopback localAddress bindings for peer mappings—not Server ListenAddress / ListenPort. Standard proxy entries therefore cannot be auto-discovered and must be configured explicitly.
  • Precedence: An explicitly constructed EntryDescriptor always overrides auto-discovery.

Supported Languages & Verification Matrix

Language Directory Baseline / Target Dependencies Verification Status
C# / .NET src/RelayLink.Sdk netstandard2.0 / net8.0 / net10.0 BCL only Multi-target build + SdkDataPlaneTests passing
Python python Python 3.9+ Standard library only unittest conformance + IPv6/UDP tests (3/3) passing
TypeScript / Node typescript Node.js 20+ Built-in modules only tsc build + node:test conformance tests (3/3) passing
Go go Go 1.22+ Standard library only go vet + go test conformance tests (6/6) passing
Java java JDK 17+ JDK only OpenJDK 17 javac + ConformanceRunner / JUnit 5 passing
Rust rust Rust 1.75+ (2021) Zero external crates (std::net) cargo test conformance suite (4/4) passing

All six implementations compile and pass contract/conformance/data-plane.json plus UDP, IPv6, and TCP half-close extensions on Windows x64 and in GitHub Actions CI (Linux musl and macOS arm64 targets require native verification on those platforms). See TST-014 and TST-015.

Usage Examples Across All Six Languages

Each snippet discovers an authorized peer entry from the local Agent (18081), opens a TCP stream, and performs unidirectional write half-close while keeping the receive path open:

C# / .NET

using RelayLink.Sdk;

var entry = await EntryDiscovery.DiscoverMappingAsync(
    EntryDiscovery.DefaultDashboardPort, "target-client", "sql-1433");
using var client = await TcpEntry.ConnectAsync(entry, TimeSpan.FromSeconds(10));
// Signal end of outbound request while continuing to read the response
TcpEntry.ShutdownWrite(client);

Python

from relaylink_sdk import DEFAULT_DASHBOARD_PORT, TcpEntry, discover_mapping

entry = discover_mapping("target-client", "sql-1433", DEFAULT_DASHBOARD_PORT)
with TcpEntry.connect(entry, connect_timeout=10.0) as sock:
    TcpEntry.shutdown_write(sock)

TypeScript / Node

import { DEFAULT_DASHBOARD_PORT, connectTcp, discoverMapping, shutdownWrite } from "./dist/dataPlane.js";

const entry = await discoverMapping("target-client", "sql-1433", DEFAULT_DASHBOARD_PORT);
const socket = await connectTcp(entry, 10_000);
shutdownWrite(socket);

Go

entry, err := relaylink.DiscoverMapping("target-client", "sql-1433", relaylink.DefaultDashboardPort)
if err != nil {
    return err
}
conn, err := relaylink.ConnectTCP(entry, 10*time.Second)
if err != nil {
    return err
}
defer conn.Close()
_ = relaylink.ShutdownWrite(conn)

Java

import com.relaylink.sdk.EntryDescriptor;
import com.relaylink.sdk.EntryDiscovery;
import com.relaylink.sdk.TcpEntry;
import java.net.Socket;

EntryDescriptor entry = EntryDiscovery.discoverMapping(
    "target-client", "sql-1433", EntryDescriptor.DEFAULT_DASHBOARD_PORT);
try (Socket socket = TcpEntry.connect(entry, 10_000)) {
    TcpEntry.shutdownWrite(socket);
}

Rust

use std::time::Duration;
use relaylink_sdk::{connect_tcp, discover_mapping, shutdown_write, DEFAULT_DASHBOARD_PORT};

let entry = discover_mapping("target-client", "sql-1433", DEFAULT_DASHBOARD_PORT)?;
let stream = connect_tcp(&entry, Duration::from_secs(10))?;
shutdown_write(&stream)?;

For standard proxy channels or UDP datagrams, construct EntryDescriptor explicitly (e.g., transport = "udp") and use the language's bindUdp / sendUdp helpers (enforcing the 65507-byte datagram cap).

Shared Contracts & Conformance Commands

All six SDKs share the repository-level contracts:

Every language surfaces idiomatic errors carrying the seven stable code strings: entry_unavailable, entry_not_found, tunnel_rejected, target_connect_failed, timeout, configuration_drift, and invalid_usage.

Run conformance suites from the repository root:

  • C# / .NET: dotnet build src/RelayLink.Sdk/RelayLink.Sdk.csproj -c Release && dotnet test tests/RelayLink.UnitTests/RelayLink.UnitTests.csproj -c Release --filter SdkDataPlaneTests
  • Python: python3 -m unittest discover -s sdk/python/tests -v (python on Windows)
  • TypeScript / Node: npm --prefix sdk/typescript ci && npm --prefix sdk/typescript test
  • Go: (cd sdk/go && go vet ./... && go test -v ./...)
  • Java: Compile sources and ConformanceRunner with javac -encoding UTF-8 and run java ... com.relaylink.sdk.ConformanceRunner (or run ConformanceTest via sdk/java/pom.xml when Maven/JUnit is available)
  • Rust: cargo test --manifest-path sdk/rust/Cargo.toml

Checklist for New Implementations

  1. Match every error code string in contract/errors.json verbatim.
  2. Reject empty hosts and ports outside 1–65535 in EntryDescriptor with invalid_usage.
  3. Support unidirectional TCP half-close (closing the write side while reading remaining responses).
  4. Reject UDP payloads exceeding 65507 bytes with an explicit error—never truncate silently.
  5. Never embed relay secrets, client secrets, or NTP1 wire framing.

Repository source