Exemplo n.º 1
0
        public TcpActor(ITcpClientActor tcpClientActor, IEnumerable <RedirectRule> redirectInfos)
        {
            RedirectRuleManager.RedirectRuleRemovedEvent += RedirectRuleManager_RedirectRuleRemovedEvent;

            _tcpClientActor = tcpClientActor;
            _redirectRules  = redirectInfos;
        }
Exemplo n.º 2
0
        public TcpActor(ITcpClientActor tcpClientActor, IEnumerable<RedirectRule> redirectInfos)
        {
            RedirectRuleManager.RedirectRuleRemovedEvent += RedirectRuleManager_RedirectRuleRemovedEvent;

            _tcpClientActor = tcpClientActor;
            _redirectRules = redirectInfos;
        }
Exemplo n.º 3
0
        private TelnetPage CreatePages(ITcpClientActor tcpClientActor)
        {
            //Add telnet pages here
            var page = new TelnetMainMenuPage();

            page.Add(new TelnetRouteListPage('1', tcpClientActor));
            page.Add(new TelnetMonitorPage('2', tcpClientActor));

            return(page);
        }
Exemplo n.º 4
0
        private TelnetPage CreatePages(ITcpClientActor tcpClientActor)
        {
            //Add telnet pages here
            var page = new TelnetMainMenuPage();

            page.Add(new TelnetRouteListPage('1', tcpClientActor));
            page.Add(new TelnetMonitorPage('2', tcpClientActor));

            return page;
        }
Exemplo n.º 5
0
 public TelnetActor(ITcpClientActor tcpClientActor)
 {
     _tcpClientActor = tcpClientActor;
     _rootPage       = CreatePages(tcpClientActor);
 }
 public TelnetMonitorPage(char key, ITcpClientActor tcpClientActor)
     : base(key, "Event Monitor")
 {
     _tcpClientActor = tcpClientActor;
 }
Exemplo n.º 7
0
 public AddRoutingRuleCommand(ITcpClientActor tcpClientActor)
     : base(tcpClientActor, 'A', "Add")
 {
 }
 public DeleteRoutingRuleCommand(ITcpClientActor tcpClientActor)
     : base(tcpClientActor, 'D', "Delete")
 {
 }
Exemplo n.º 9
0
        private void FromClientToTarget()
        {
            try
            {
                LogHelper.ShowMessage(string.Format("Connection {0} started to read.", _connectionIndex));
                var messageChunk = new byte[MessageChunkSize];

                while (_state == TcpActorState.Running)
                {
                    var bytesRead = _tcpClientActor.Read(messageChunk, 0, messageChunk.Length);
                    PerformaceCounters.Instance.Rx(bytesRead);
                    _totalRx += bytesRead;

                    //If there is no _tcpTargetActor, try to get one.
                    if (_tcpTargetActor == null)
                    {
                        _currentRedirectRule = GetTargetInfo(messageChunk, bytesRead);
                        if (_currentRedirectRule != null)
                        {
                            _tcpTargetActor = new TcpClientActor(new TcpClient(_currentRedirectRule.InternalTargetAddress.ToString(), _currentRedirectRule.InternalTargetPort));
                        }
                        _targetRecievedEvent.Set();
                    }

                    if (_tcpTargetActor == null)
                    {
                        //If there still is no target actor, exit the loop.
                        LogHelper.LogMessage("The reader could not find a target actor to forward the traffic to.", Issue.IssueLevel.Warning);
                        break;
                    }

                    _tcpTargetActor.Write(messageChunk, 0, bytesRead);

                    //TODO: Here is the place to log throughput from client to server. At this point data has been transferred from the client to the target.
                }
            }
            catch (System.IO.IOException exp)
            {
                //Expected when the client closes.
                //exp = {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.InformationException);
            }
            catch (ObjectDisposedException exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
            }
            catch (InvalidOperationException exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
            }
            catch (SocketException exp)
            {
                //Expected when there is no server listening.
                LogHelper.LogException(exp, true, LogHelper.ExceptionSeverity.WarningException);
                _staticResponse = exp.Message; //This message is sent back as response to the client
                _targetRecievedEvent.Set();
            }
            catch (Exception exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
                throw;
            }
            finally
            {
                _state = TcpActorState.RequestStop;
                LogHelper.ShowMessage(string.Format("Connection {0} stopped to read. (Rx: {1})", _connectionIndex, _totalRx));
            }
        }
 public TelnetMonitorPage(char key, ITcpClientActor tcpClientActor)
     : base(key, "Event Monitor")
 {
     _tcpClientActor = tcpClientActor;
 }
Exemplo n.º 11
0
 public TelnetRouteListPage(char key, ITcpClientActor tcpClientActor)
     : base(key, "Reverse Proxy Routing Rules")
 {
     Commands.Add(new AddRoutingRuleCommand(tcpClientActor));
     Commands.Add(new DeleteRoutingRuleCommand(tcpClientActor));
 }
 public AddRoutingRuleCommand(ITcpClientActor tcpClientActor)
     : base(tcpClientActor, 'A', "Add")
 {
 }
Exemplo n.º 13
0
 protected TelnetCommand(ITcpClientActor tcpClientActor, char key, string name)
 {
     _tcpClientActor = tcpClientActor;
     Key             = key;
     Name            = name;
 }
Exemplo n.º 14
0
 public TelnetActor(ITcpClientActor tcpClientActor)
 {
     _tcpClientActor = tcpClientActor;
     _rootPage = CreatePages(tcpClientActor);
 }
Exemplo n.º 15
0
 public DeleteRoutingRuleCommand(ITcpClientActor tcpClientActor)
     : base(tcpClientActor, 'D', "Delete")
 {
 }
Exemplo n.º 16
0
        private void FromClientToTarget()
        {
            try
            {
                LogHelper.ShowMessage(string.Format("Connection {0} started to read.", _connectionIndex));
                var messageChunk = new byte[MessageChunkSize];

                while (_state == TcpActorState.Running)
                {
                    var bytesRead = _tcpClientActor.Read(messageChunk, 0, messageChunk.Length);
                    PerformaceCounters.Instance.Rx(bytesRead);
                    _totalRx += bytesRead;

                    //If there is no _tcpTargetActor, try to get one.
                    if (_tcpTargetActor == null)
                    {
                        _currentRedirectRule = GetTargetInfo(messageChunk, bytesRead);
                        if (_currentRedirectRule != null)
                            _tcpTargetActor = new TcpClientActor(new TcpClient(_currentRedirectRule.InternalTargetAddress.ToString(), _currentRedirectRule.InternalTargetPort));
                        _targetRecievedEvent.Set();
                    }

                    if (_tcpTargetActor == null)
                    {
                        //If there still is no target actor, exit the loop.
                        LogHelper.LogMessage("The reader could not find a target actor to forward the traffic to.", Issue.IssueLevel.Warning);
                        break;
                    }

                    _tcpTargetActor.Write(messageChunk, 0, bytesRead);

                    //TODO: Here is the place to log throughput from client to server. At this point data has been transferred from the client to the target.
                }
            }
            catch (System.IO.IOException exp)
            {
                //Expected when the client closes.
                //exp = {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.InformationException);
            }
            catch (ObjectDisposedException exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
            }
            catch (InvalidOperationException exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
            }
            catch (SocketException exp)
            {
                //Expected when there is no server listening.
                LogHelper.LogException(exp, true, LogHelper.ExceptionSeverity.WarningException);
                _staticResponse = exp.Message; //This message is sent back as response to the client
                _targetRecievedEvent.Set();
            }
            catch (Exception exp)
            {
                LogHelper.LogException(exp, false, LogHelper.ExceptionSeverity.ErrorException);
                throw;
            }
            finally
            {
                _state = TcpActorState.RequestStop;
                LogHelper.ShowMessage(string.Format("Connection {0} stopped to read. (Rx: {1})", _connectionIndex, _totalRx));
            }
        }
Exemplo n.º 17
0
 protected TelnetCommand(ITcpClientActor tcpClientActor, char key, string name)
 {
     _tcpClientActor = tcpClientActor;
     Key = key;
     Name = name;
 }
 public TelnetRouteListPage(char key, ITcpClientActor tcpClientActor)
     : base(key, "Reverse Proxy Routing Rules")
 {
     Commands.Add(new AddRoutingRuleCommand(tcpClientActor));
     Commands.Add(new DeleteRoutingRuleCommand(tcpClientActor));
 }