Class ForwardingManager
- Namespace
- VpnHood.Core.Tunneling.Forwarding
- Assembly
- VpnHood.Core.Tunneling.dll
Represents what sends a session's packets on to their destinations through the device's own network: UDP through UDP sockets, pings through pings, and TCP connections through the stream forwarding channels it is given.
public class ForwardingManager : PassthroughPacketTransport, IPacketTransport, IDisposable
- Inheritance
-
ForwardingManager
- Implements
- Inherited Members
Remarks
The replies come back as received packets. A server forwards its sessions' packets so, as a client does what it bypasses.
Constructors
ForwardingManager(ISocketFactory, ForwardingManagerOptions)
Initializes a new instance of the ForwardingManager class.
public ForwardingManager(ISocketFactory socketFactory, ForwardingManagerOptions options)
Parameters
socketFactoryISocketFactoryThe factory that makes its UDP sockets.
optionsForwardingManagerOptionsThe options.
Properties
IsIpV6Supported
Gets or sets a value indicating whether the manager forwards IPv6; otherwise, it drops IPv6 packets. The default is true.
public bool IsIpV6Supported { get; set; }
Property Value
Traffic
Gets what the manager has forwarded: its packets, and the bytes of its stream forwarding channels, the ended ones too.
public Traffic Traffic { get; }
Property Value
UdpClientCount
Gets the number of UDP sockets, closed ones not swept yet among them.
public int UdpClientCount { get; }
Property Value
Methods
AddChannel(StreamForwardingChannel, bool)
Takes a stream forwarding channel and starts it; the manager disposes it at its own end.
public void AddChannel(StreamForwardingChannel channel, bool disposeOnFail)
Parameters
channelStreamForwardingChannelThe channel.
disposeOnFailbooltrue to dispose the channel where it cannot be taken.
Exceptions
- ObjectDisposedException
The manager is disposed.
- InvalidOperationException
The channel is already started.
DisposeManaged()
Releases managed resources; the base detaches the PacketReceived handlers. A derived class must catch its own errors.
protected override void DisposeManaged()
Remarks
It closes its UDP sockets, its pings and its channels at once.
SendPacket(IpPacket)
Hands one packet on, at once. Once handed on, the packet is no longer this transport's; throw only before.
protected override void SendPacket(IpPacket ipPacket)
Parameters
ipPacketIpPacketThe packet.
Remarks
A UDP packet goes to its UDP socket, and an ICMP one to a ping.
Exceptions
- PacketDropException
The packet is IPv6, which the manager does not forward.
- NotSupportedException
The packet is a ping, which the manager does not forward.
- Exception
The packet is neither UDP nor ICMP.