This project is read-only.

Tunnelling software created using the Reactive Extensions SDK!

Rx is not just for events!!!

Source Codehttp://aoa.codeplex.com/releases/view/68178#DownloadId=249102

This is the example of one of the core classes responsible for routing Tcp packets!

This application was written using the early beta of the RX framework, so some functions which are available now were not available then and had to be written from scratch.

The core of the application is expressed in one small class (below)


public class TcpTunnel //: ITunnel SOMETHING THAT TAKES A CHANNEL

{
    private readonly Subject<TcpTunnelRoute> _routes;

    public TcpTunnel(IMessageChannel channel)
    {
        _routes = new Subject<TcpTunnelRoute>();

        channel.Output

            .OfType<TcpConnectionInitiated>()

            .Select(message => new TcpOutboundTunnel(channel, new TcpConnection(message.Host,     message.Port), message.ConnectionId)).Subscribe();

        channel.Output

        .OfType<AcceptTcpConnections>()

        .Select(message => new TcpInboundTunnel(channel, message.SourcePort, message.DestinationHost, message.DestinationPort)).Subscribe();

        _routes.Where(r => r.Direction == TcpTunnelDirection.Inbound)
        .Select(r => new AcceptTcpConnections(r.SourcePort, r.DestinationHost, r.DestinationPort))
        .Do(a => channel.Input.OnNext(a))
        .Subscribe();

        _routes.Where(r => r.Direction == TcpTunnelDirection.Outbound)
        .Select(r => new TcpInboundTunnel(channel, r.SourcePort, r.DestinationHost, r.DestinationPort))
        .Subscribe();
    }

    public IObserver<TcpTunnelRoute> Routes
    {
        get { return _routes; }
    }
}

Last edited Apr 26, 2016 at 12:34 PM by igolovkine, version 18