Ejemplo n.º 1
0
        public UdpProxy(
            IReadOnlyTcpStream clientStream,
            IUdpClientFactory clientFactory,
            IDatagramInterceptor interceptor,
            ArrayPool <byte> bufferPool,
            ITimerFactory timerFactory,
            ILoggerFactory loggerFactory)
        {
            if (clientFactory == null)
            {
                throw new ArgumentNullException(nameof(clientFactory));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            this._clientStream = clientStream ?? throw new ArgumentNullException(nameof(clientStream));
            this._interceptor  = interceptor ?? throw new ArgumentNullException(nameof(interceptor));
            this._bufferPool   = bufferPool ?? throw new ArgumentNullException(nameof(bufferPool));

            this._boundClient = clientFactory.CreateBoundUdpClient(
                new IPEndPoint(((IPEndPoint)clientStream.LocalEndPoint).Address, 0));
            this._relayClient        = clientFactory.CreateUdpClient();
            this._reassembler        = new DatagramReassembler(timerFactory, this._bufferPool);
            this._clientEndPointTask =
                new TaskCompletionSource <EndPoint>(TaskCreationOptions.RunContinuationsAsynchronously);

            this._clientSessionTerminationSource = new CancellationTokenSource();
            this._log = loggerFactory.CreateLogger(this.GetType().Name);
            this._log.LogInformation("Started UDP listener on {0}", this.BindEndPoint);
        }
Ejemplo n.º 2
0
 public IProxy CreateUdpProxy(IReadOnlyTcpStream clientStream, ArrayPool <byte> bufferPool)
 {
     return(new UdpProxy(
                clientStream,
                this._udpClientFactory,
                this._datagramInterceptor,
                bufferPool,
                this._timerFactory,
                this._loggerFactory));
 }
Ejemplo n.º 3
0
 public IProxy CreateUdpProxy(IReadOnlyTcpStream clientStream, ArrayPool <byte> bufferPool)
 {
     this.UdpProxyCreated = true;
     return(this.NextUdpProxyToReturn ?? new FakeProxy());
 }