EncryptedTransport
Encrypts client-to-gateway packets over a User Datagram Protocol (UDP) transport.
Nebula · Packages/com.1by3.nebula/Runtime/Transport/EncryptedTransport.cspublic sealed class EncryptedTransport : ITransport, ISecureTransportEncrypts client-to-gateway packets over a User Datagram Protocol (UDP) transport.
ForClient starts a key exchange when the underlying link connects and delays the Connected event until the gateway response is verified. Send application packets after this event. ForGateway answers links that begin with a key exchange and passes other links through without encryption. Worker and gateway peers that use these plaintext links must run on a private network.
A handshake frame is [tag][body]. A data frame is [delivery tag][seq:u32], followed by the ChaCha20-Poly1305 ciphertext and authentication tag, adding 21 bytes to the plaintext size. The sequence is little-endian. The frame header is authenticated as associated data. Sequenced and reliable traffic use separate counters, nonce domains, and replay windows. Tags start at 0xE0, above every MsgId; a gateway with encryption disabled ignores handshake frames.
Properties
Fingerprint
public string Fingerprint { get; }The certificate fingerprint this gateway presents; null on a client.
SecurityError
public string SecurityError { get; } = "";DroppedPackets
public long DroppedPackets { get; }Data packets rejected as malformed, unauthenticated, replayed, or outside the replay window during this transport object's lifetime.
Name
public string Name { get; }IsRunning
public bool IsRunning { get; }LocalPort
public int LocalPort { get; }Methods
ForGateway
public static EncryptedTransport ForGateway(ITransport inner, TransportIdentity identity);Creates a gateway wrapper that answers handshakes with identity and passes plaintext links through.
ForClient
public static EncryptedTransport ForClient(ITransport inner, ClientEncryption settings);Creates a client wrapper that reports a connection only after its encryption handshake succeeds.
IsEncrypted
public bool IsEncrypted(int peerId);Listen
public void Listen(int port);StartClient
public void StartClient();Disconnect
public void Disconnect(int peerId);IsConnected
public bool IsConnected(int peerId);RoundTripMs
public int RoundTripMs(int peerId);Flush
public void Flush();Connect
public int Connect(string host, int port);Send
public void Send(int peerId, Delivery delivery, ArraySegment<byte> payload);Poll
public void Poll(Action<TransportEvent> handler);Stop
public void Stop();Dispose
public void Dispose();