Noble Connect
Add relays and punchthrough to Mirror or UNet
NobleConnect.Bridge Class Reference

Inherits IDisposable.

Public Member Functions

void Dispose ()
 Dispose the sockets More...
 

Public Attributes

Socket socket
 The IPv4 socket that applications can send to / receive from to communicate over the bridge More...
 
Socket socketIPv6
 The IPv6 socket that applications can send to / receive from to communicate over the bridge More...
 
bool isRelay
 Is this a relay bridge More...
 
Stun.Controller stunController
 The stun controller holds the socket that has a route to the peer. More...
 
CandidatePair candidatePair
 The candidate pair from ice that this bridge was created for. More...
 
PaddedBuffer outgoingBufferIPv4 = new PaddedBuffer(new ArraySegment<byte>(new byte[4096]), 4)
 Outgoing IPv4 data is received into this buffer and then sent using the same buffer to avoid copying More...
 
PaddedBuffer outgoingBufferIPv6 = new PaddedBuffer(new ArraySegment<byte>(new byte[4096]), 4)
 Outgoing IPv6 data is received into this buffer and then sent using the same buffer to avoid copying More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Close the sockets More...
 

Member Function Documentation

◆ Dispose() [1/2]

void NobleConnect.Bridge.Dispose ( )

Dispose the sockets

◆ Dispose() [2/2]

virtual void NobleConnect.Bridge.Dispose ( bool  disposing)
protectedvirtual

Close the sockets

Parameters
disposing

Member Data Documentation

◆ candidatePair

CandidatePair NobleConnect.Bridge.candidatePair

The candidate pair from ice that this bridge was created for.

We keep track of the candidate pair so that we can end the ice session after the application has signaled that the connection has succeeded and also so we can revoke the channel when the application is done with the bridge.

◆ isRelay

bool NobleConnect.Bridge.isRelay

Is this a relay bridge

Relay bridges use SendChannelMessage to send data to a relay to be send relayed to the peerEndPoint. Non-relay bridges send the data directly from the stun controller's socket.

◆ outgoingBufferIPv4

PaddedBuffer NobleConnect.Bridge.outgoingBufferIPv4 = new PaddedBuffer(new ArraySegment<byte>(new byte[4096]), 4)

Outgoing IPv4 data is received into this buffer and then sent using the same buffer to avoid copying

This means another receive can't happen until the previous send has completed, but that's fine and normal. We can't receive faster than we can send anyway without infinite space. The buffer has 4 bytes of padding at the front so that the channel message header can be prepended before sending to the relay server. Max UDP size is 65,535 bytes, but no service actually supports packets of this size Unet uses a default of 1,500 bytes but recommends lowering it for release Ignorance looks like 4096 is the max Litenetlib has max of about 1,500 The actual largest packet size that is guaranteed to be not fragmented over the internet is about 500 bytes I'm going to go with 4096 to cover all reasonable values but not waste space when no one is trying to send 64kb packets.

◆ outgoingBufferIPv6

PaddedBuffer NobleConnect.Bridge.outgoingBufferIPv6 = new PaddedBuffer(new ArraySegment<byte>(new byte[4096]), 4)

Outgoing IPv6 data is received into this buffer and then sent using the same buffer to avoid copying

This means another receive can't happen until the previous send has completed, but that's fine and normal. We can't receive faster than we can send anyway without infinite space. The buffer has 4 bytes of padding at the front so that the channel message header can be prepended before sending to the relay server. Max UDP size is 65,535 bytes, but no service actually supports packets of this size Unet uses a default of 1,500 bytes but recommends lowering it for release Ignorance looks like 4096 is the max Litenetlib has max of about 1,500 The actual largest packet size that is guaranteed to be not fragmented over the internet is about 500 bytes I'm going to go with 4096 to cover all reasonable values but not waste space when no one is trying to send 64kb packets.

◆ socket

Socket NobleConnect.Bridge.socket

The IPv4 socket that applications can send to / receive from to communicate over the bridge

◆ socketIPv6

Socket NobleConnect.Bridge.socketIPv6

The IPv6 socket that applications can send to / receive from to communicate over the bridge

◆ stunController

Stun.Controller NobleConnect.Bridge.stunController

The stun controller holds the socket that has a route to the peer.

Data received on either bridge socket is sent to the peer via the stun controller socket.