const proxy = await StartRelayProxyCore({
logger,
server: { host: "127.0.0.1", port: 0 },
origins: [{ relayServer: {}, host: "127.0.0.1", port: 9090 }],
targets: [{ relayServer: {}, target: { host: "127.0.0.1", port: 5432 } }],
});
// connections to 127.0.0.1:9090 are now proxied to 127.0.0.1:5432
// through the relay server.
Start a relay-mode proxy: a RelayServer (optional), a target RelayClient that dials a destination on demand, and an origin RelayClient whose local listener tunnels accepted TCP connections to that target through the relay server.
At least one of IStartRelayProxyOptions.origin or IStartRelayProxyOptions.target must be provided. When both are, all targets connect first, then each origin waits for its selected target before opening its local listener.
This is the low-level, options-based entry point. Prefer StartRelayProxy (which loads a config file) for command-line style usage, or StartRelayProxyByConfig when you already have an IRelayProxyConfig.