public override void Start() { _currentTestReqIdx = -1; _currentReqIdx = -1; string filePath = ""; if (ExtraOptions.ContainsKey(TEST_FILE_PATH)) { filePath = ExtraOptions[TEST_FILE_PATH]; if (!String.IsNullOrWhiteSpace(filePath)) { try { CustomTestsFile testFile = new CustomTestsFile(); testFile.Load(filePath); _testFile = testFile; } catch { HttpServerConsole.Instance.WriteLine(LogMessageType.Error, "Could not load custom tests file located at: '{0}'.", filePath); } } } _tester = new Tester(_testController, _testFile); _workList = new Dictionary <int, Queue <TestJob> >(); _patternOfRequestExclusion = _testFile.PatternRequestExclusion; base.Start(); }
/// <summary> /// Start listening for connections /// </summary> /// <exception cref="InvalidOperationException">Proxy was already started</exception> virtual public void Start() { //set network options int clientProxyPort = 0; if (ExtraOptions.ContainsKey(HTTP_CLIENT_PROXY_HOST) && ExtraOptions.ContainsKey(HTTP_CLIENT_PROXY_PORT) && !String.IsNullOrWhiteSpace(ExtraOptions[HTTP_CLIENT_PROXY_HOST]) && !String.IsNullOrWhiteSpace(ExtraOptions[HTTP_CLIENT_PROXY_PORT]) && int.TryParse(ExtraOptions[HTTP_CLIENT_PROXY_PORT], out clientProxyPort)) { //override defaults _networkSettings.WebProxy = new WebProxy(ExtraOptions[HTTP_CLIENT_PROXY_HOST], clientProxyPort); } if (_listening) { throw new InvalidOperationException("Attempted to start proxy when already started"); } _listener = new TcpListener(_localAddress, Port); _secureListener = new TcpListener(_localAddress, SecurePort); //start the unsecure port StartListener(ref _listener, ref _usesDynamicPort); //start the secure port StartListener(ref _secureListener, ref _usesDynamicPortSecure); if (_listener != null && _secureListener != null) { // Expose which port we're using if it was dynamically selected if (_usesDynamicPort) { _port = ((IPEndPoint)_listener.LocalEndpoint).Port; } if (_usesDynamicPortSecure) { _securePort = ((IPEndPoint)_secureListener.LocalEndpoint).Port; } HttpServerConsole.Instance.WriteLine(String.Format("Waiting on Host: {0}, HTTP Port: {1}, Secure Port: {2}", _localAddress, _port, _securePort)); _listener.BeginAcceptTcpClient(new AsyncCallback(OnAccept), _listener); _secureListener.BeginAcceptTcpClient(new AsyncCallback(OnAccept), _secureListener); _listening = true; } }
public override void Start() { if (ExtraOptions.ContainsKey(ReverseProxy.FORWARDING_HOST_OPT) && !String.IsNullOrWhiteSpace(ExtraOptions[ReverseProxy.FORWARDING_HOST_OPT])) { _forwardingHost = ExtraOptions[ReverseProxy.FORWARDING_HOST_OPT]; } else { HttpServerConsole.Instance.WriteLine(LogMessageType.Error, "Need to configure 'ForwardingHost' extra proxy option"); return; } if (ExtraOptions.ContainsKey(ReverseProxy.FORWARDING_PORT_OPT) && !String.IsNullOrWhiteSpace(ExtraOptions[ReverseProxy.FORWARDING_PORT_OPT])) { string fwPortString = ExtraOptions[ReverseProxy.FORWARDING_PORT_OPT]; if (!int.TryParse(fwPortString, out _forwardingPort)) { HttpServerConsole.Instance.WriteLine(LogMessageType.Error, "Invalid value for 'ForwardingPort' extra option"); return; } } else { HttpServerConsole.Instance.WriteLine(LogMessageType.Error, "Need to configure 'ForwardingPort' extra proxy option"); return; } base.Start(); HttpServerConsole.Instance.WriteLine(LogMessageType.Warning, "All binary messages (including attacks) will be forwarded to {0}:{1}", _forwardingHost, _forwardingPort); }