public TcpActor(ITcpClientActor tcpClientActor, IEnumerable <RedirectRule> redirectInfos) { RedirectRuleManager.RedirectRuleRemovedEvent += RedirectRuleManager_RedirectRuleRemovedEvent; _tcpClientActor = tcpClientActor; _redirectRules = redirectInfos; }
public TcpActor(ITcpClientActor tcpClientActor, IEnumerable<RedirectRule> redirectInfos) { RedirectRuleManager.RedirectRuleRemovedEvent += RedirectRuleManager_RedirectRuleRemovedEvent; _tcpClientActor = tcpClientActor; _redirectRules = redirectInfos; }
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); }
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; }
public TelnetActor(ITcpClientActor tcpClientActor) { _tcpClientActor = tcpClientActor; _rootPage = CreatePages(tcpClientActor); }
public TelnetMonitorPage(char key, ITcpClientActor tcpClientActor) : base(key, "Event Monitor") { _tcpClientActor = tcpClientActor; }
public AddRoutingRuleCommand(ITcpClientActor tcpClientActor) : base(tcpClientActor, 'A', "Add") { }
public DeleteRoutingRuleCommand(ITcpClientActor tcpClientActor) : base(tcpClientActor, 'D', "Delete") { }
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; }
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") { }
protected TelnetCommand(ITcpClientActor tcpClientActor, char key, string name) { _tcpClientActor = tcpClientActor; Key = key; Name = name; }
public TelnetActor(ITcpClientActor tcpClientActor) { _tcpClientActor = tcpClientActor; _rootPage = CreatePages(tcpClientActor); }
public DeleteRoutingRuleCommand(ITcpClientActor tcpClientActor) : base(tcpClientActor, 'D', "Delete") { }
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)); } }
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)); }