Stop() public method

public Stop ( ) : void
return void
Example #1
0
 private void BtnStartStop_Click(object sender, EventArgs e)
 {
     if (((Button)sender).Text == "Start")
     {
         _prox = new Proxy();
         _prox.SessionStarted += _prox_SessionStarted;
         if (chkAdvanced.Checked)
         {
             _prox.setCientport(TxtCientPort.Text).setServerport(TxtHostPort.Text);
         }
         else
         {
             _prox.setCientport("8080").setServerport("22");
         }
         _prox.sethost(TxtHostName.Text).TurnOffShell(ChkHideShell.Checked).AutoStoreSshkey(ChkSaveKey.Checked).sethost(TxtHostName.Text).Verbose(ChkVerbose.Checked).setlogin(TxtUserName.Text, TxtPassword.Text);
         _prox.SessionTerminated += _prox_SessionTerminated;
         _prox.Start();
         this.Text    = "Connecting";
         button1.Text = "Stop";
     }
     else if (((Button)sender).Text == "Stop")
     {
         button1.Text = "Closing";
         this.Text    = "Disconnecting";
         _prox.Stop();
     }
 }
Example #2
0
        private void StopBtn_OnClick(object sender, RoutedEventArgs e)
        {
            if (_isProxyRunning)
            {
                return;
            }

            PlayBtn.IsEnabled             = true;
            StatusRunning.IsIndeterminate = false;
            _snifferProxy?.Stop();
            _isProxyRunning = false;
        }
Example #3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            try
            {
                _logger.LogInformation("XPub/XSub starting...");
                using var _publisher = new XPublisherSocket($"@tcp://127.0.0.1:4444");
                _logger.LogInformation($"XPub at 127.0.0.1:4444.");
                using var _subscriber = new XSubscriberSocket($"@tcp://127.0.0.1:5555");
                _logger.LogInformation($"XSub at 127.0.0.1:5555.");
                var proxy = new Proxy(_subscriber, _publisher);
                var t     = Task.Factory.StartNew(_ => {
                    try
                    {
                        proxy.Start();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, "ERROR in Proxy Task");
                    }
                }, TaskCreationOptions.LongRunning);
                await Task.Delay(-1, stoppingToken).ContinueWith(_ => { });

                proxy.Stop();
                await t; // to avoid proxy accessing disposed objects
            }
            catch (Exception e)
            {
                _logger.LogError(e, "ERROR in Worker");
            }
            finally
            {
                _logger.LogInformation("XPub/XSub terminating");
            }
        }
Example #4
0
        public void StartAndStopStateValidation()
        {
            using (var front = new RouterSocket())
                using (var back = new DealerSocket())
                {
                    front.Bind("inproc://frontend");
                    back.Bind("inproc://backend");

                    var proxy = new Proxy(front, back);
                    Task.Factory.StartNew(proxy.Start);

                    // Send a message through to ensure the proxy has started
                    using (var client = new RequestSocket())
                        using (var server = new ResponseSocket())
                        {
                            client.Connect("inproc://frontend");
                            server.Connect("inproc://backend");
                            client.SendFrame("hello");
                            Assert.AreEqual("hello", server.ReceiveFrameString());
                            server.SendFrame("reply");
                            Assert.AreEqual("reply", client.ReceiveFrameString());
                        }

                    Assert.Throws <InvalidOperationException>(proxy.Start);
                    Assert.Throws <InvalidOperationException>(proxy.Start);
                    Assert.Throws <InvalidOperationException>(proxy.Start);

                    proxy.Stop(); // blocks until stopped

                    Assert.Throws <InvalidOperationException>(proxy.Stop);
                }
        }
Example #5
0
        public void Stop()
        {
            _proxy.Stop();
            try
            {
                _fromSocket.Unbind(_fromAddress);
            }
            catch (ObjectDisposedException)
            {
                // Ignored
            }
            _fromSocket.Close();
            _fromSocket.Dispose();

            try
            {
                _toSocket.Unbind(_toAddress);
            }
            catch (ObjectDisposedException)
            {
                // Ignored
            }
            _toSocket.Close();
            _toSocket.Dispose();
        }
Example #6
0
        public void HandleProxy()
        {
            if (_proxyThread != null && _proxyThread.IsAlive)
            {
                _proxyProccess.Stop();
                _proxyProccess = null;
                _proxyThread.Abort();
            }

            PacketListWaiting.Clear();
            PacketListFound.Clear();

            _proxyThread = new Thread(() => {
                _proxyProccess = new Proxy {
                    IpAddress = IPAddress.Any, Port = 8080
                };
                _proxyProccess.Start();
                while (true)
                {
                    Thread.Sleep(100);
                }
            })
            {
                IsBackground = true
            };
            _proxyThread.Start();
        }
Example #7
0
        public void SendAndReceive()
        {
            using (var front = new RouterSocket())
                using (var back = new DealerSocket())
                {
                    front.Bind("inproc://frontend");
                    back.Bind("inproc://backend");

                    var proxy = new Proxy(front, back);
                    Task.Factory.StartNew(proxy.Start);

                    using (var client = new RequestSocket())
                        using (var server = new ResponseSocket())
                        {
                            client.Connect("inproc://frontend");
                            server.Connect("inproc://backend");

                            client.SendFrame("hello");
                            Assert.AreEqual("hello", server.ReceiveFrameString());
                            server.SendFrame("reply");
                            Assert.AreEqual("reply", client.ReceiveFrameString());
                        }

                    proxy.Stop();
                }
        }
Example #8
0
        protected override void OnStop()
        {
            _proxy.Stop();
            _proxy.Dispose();

            AddLogInfo("Service was stopped");
        }
Example #9
0
File: test.cs Project: mono/gert
	static void Main (string [] args)
	{
		Server http = new Server ();
		Proxy proxy = new Proxy ();

		new Thread (http.Run).Start ();
		new Thread (proxy.Run).Start ();

		IPAddress ip = GetIPv4Address (Dns.GetHostName ());

		HttpWebRequest request = (HttpWebRequest) WebRequest.Create ("http://" + ip.ToString () + ":8080/default.htm");
		request.Proxy = new WebProxy (ip.ToString (), 8081);

		try {
			HttpWebResponse response = (HttpWebResponse) request.GetResponse ();
			Assert.IsNull (response.CharacterSet, "#A1");
			Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#A2");
			Assert.AreEqual (string.Empty, response.ContentEncoding, "#A3");
			Assert.AreEqual (string.Empty, response.ContentType, "#A4");

			using (StreamReader sr = new StreamReader (response.GetResponseStream ())) {
				string body = sr.ReadToEnd ();
				Assert.AreEqual ("<html><body>ok</body></html>", body, "#A5");
			}
		} catch (WebException ex) {
			if (ex.Response != null) {
				StreamReader sr = new StreamReader (ex.Response.GetResponseStream ());
				Console.WriteLine (sr.ReadToEnd ());
			}
			throw;
		} finally {
			http.Stop ();
			proxy.Stop ();
		}
	}
 private void killServerThr()
 {
     try
     {
         poller.Cancel();
         proxy.Stop();
     }
     catch { }
 }
Example #11
0
        public void StartAgainAfterStop()
        {
            using (var context = NetMQContext.Create())
            using (var front = context.CreateRouterSocket())
            using (var back = context.CreateDealerSocket())
            {
                front.Bind("inproc://frontend");
                back.Bind("inproc://backend");

                var proxy = new Proxy(front, back);
                Task.Factory.StartNew(proxy.Start);

                // Send a message through to ensure the proxy has started
                using (var client = context.CreateRequestSocket())
                using (var server = context.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");
                    client.SendFrame("hello");
                    Assert.AreEqual("hello", server.ReceiveFrameString());
                    server.SendFrame("reply");
                    Assert.AreEqual("reply", client.ReceiveFrameString());
                }

                proxy.Stop(); // blocks until stopped

                // Start it again
                Task.Factory.StartNew(proxy.Start);

                // Send a message through to ensure the proxy has started
                using (var client = context.CreateRequestSocket())
                using (var server = context.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");
                    client.SendFrame("hello");
                    Assert.AreEqual("hello", server.ReceiveFrameString());
                    server.SendFrame("reply");
                    Assert.AreEqual("reply", client.ReceiveFrameString());
                }

                proxy.Stop(); // blocks until stopped
            }
        }
Example #12
0
        public virtual void Stop()
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug("ActorNetService Stopping...");
            }

            _c_token.Cancel();
            _broker?.Stop();
            _actorService.Stop();
        }
Example #13
0
        public override void OnStop()
        {
            Trace.TraceInformation("HostWorkerRole is stopping");

            this.cancellationTokenSource.Cancel();
            this.runCompleteEvent.WaitOne();

            Proxy.Stop();
            base.OnStop();

            Trace.TraceInformation("HostWorkerRole has stopped");
        }
Example #14
0
        /// <summary>
        /// Stops a capture.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control is not capturing a video stream.</exception>
        /// <exception cref="DirectShowException">Failed to stop a video capture graph.</exception>
        public void StopCapture()
        {
            if (!_isCapturing)
            {
                throw new InvalidOperationException();
            }

            Proxy.Stop();
            _isCapturing = false;

            Proxy.ResetCaptureGraph();
            _currentCamera = null;
        }
Example #15
0
        protected override void OnStop()
        {
            try
            {
                _proxy.Stop();
                _proxy.Dispose();

                LogInfo("Service stopped successfully");
            }
            catch (Exception e)
            {
                LogError(e);
            }
        }
Example #16
0
        static void Main(string[] args) /* Console entry point */
        {
            // Need lots of outgoing connections and hang on to them
            ServicePointManager.DefaultConnectionLimit  = 20;
            ServicePointManager.MaxServicePointIdleTime = 10000;
            //send packets as soon as you get them
            ServicePointManager.UseNagleAlgorithm = false;
            //send both header and body together
            ServicePointManager.Expect100Continue = false;

            Proxy.Start(proxyAddress);
            Console.ReadLine();
            Proxy.Stop();
        }
Example #17
0
        private void btnToggleProxy_Click(object sender, EventArgs e)
        {
            if (btnToggleProxy.Text == "Start Proxy")
            {
                btnToggleProxy.Text = "Stop Proxy";
                SetStatus("Starting...", Color.Black);

                _proxy.Start();
            }
            else
            {
                btnToggleProxy.Text = "Start Proxy";
                SetStatus("Stopping...", Color.Black);
                _proxy.Stop();
            }
        }
Example #18
0
 /// <summary>
 /// Entry point of the application.
 /// </summary>
 static void Main(string[] args)
 {
     try
     {
         IProxy prx = new Proxy();
         var    cli = new CommandLine(prx);
         prx.LoadData();
         cli.StartLoop();
         prx.Stop();
     }
     catch (Exception ex)
     {
         Console.WriteLine("The program ended abnormally!");
         Console.WriteLine(ex);
         Console.ReadLine();
     }
 }
Example #19
0
        public IMessageBroker Shutdown()
        {
            if (!_cancellationTokenSource.IsCancellationRequested)
            {
                _cancellationTokenSource.Cancel();
            }
            try
            {
                _proxy?.Stop();
                _proxy = null;
            }
            catch
            {
            }

            return(this);
        }
Example #20
0
        public void SeparateControlSocketsObservedMessages()
        {
            using (var context = NetMQContext.Create())
            using (var front = context.CreateRouterSocket())
            using (var back = context.CreateDealerSocket())
            using (var controlInPush = context.CreatePushSocket())
            using (var controlInPull = context.CreatePullSocket())
            using (var controlOutPush = context.CreatePushSocket())
            using (var controlOutPull = context.CreatePullSocket())
            {
                front.Bind("inproc://frontend");
                back.Bind("inproc://backend");

                controlInPush.Bind("inproc://controlIn");
                controlInPull.Connect("inproc://controlIn");
                controlOutPush.Bind("inproc://controlOut");
                controlOutPull.Connect("inproc://controlOut");

                var proxy = new Proxy(front, back, controlInPush, controlOutPush);
                Task.Factory.StartNew(proxy.Start);

                using (var client = context.CreateRequestSocket())
                using (var server = context.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");

                    client.Send("hello");
                    Assert.AreEqual("hello", server.ReceiveFrameString());
                    server.Send("reply");
                    Assert.AreEqual("reply", client.ReceiveFrameString());
                }

                Assert.IsNotNull(controlInPull.ReceiveFrameBytes());     // receive identity
                Assert.IsEmpty(controlInPull.ReceiveFrameString()); // pull terminator
                Assert.AreEqual("hello", controlInPull.ReceiveFrameString());

                Assert.IsNotNull(controlOutPull.ReceiveFrameBytes());     // receive identity
                Assert.IsEmpty(controlOutPull.ReceiveFrameString()); // pull terminator
                Assert.AreEqual("reply", controlOutPull.ReceiveFrameString());

                proxy.Stop();
            }
        }
Example #21
0
        static void Main()
        {
            Trace.Listeners.Add(new ConsoleTraceListener());
            var configuration = SimpleProxyConfigurationSection.GetConfigSection();

            var proxy = new Proxy(
                new HttpListenerFactory(),
                new WebRequestFactory(),
                configuration.Listeners.Cast <ListenerElement>().Select(t => t.Prefix),
                AuthenticationSchemes.Anonymous);

            foreach (RequestFilterElement requestFilter in configuration.RequestFilters)
            {
                var filter = PluginLoader.LoadRequestFilter(requestFilter.Type);

                if (filter is BlacklistFilter)
                {
                    var blackListFilter = (BlacklistFilter)filter;
                    foreach (RegexElement regex in configuration.Blacklist)
                    {
                        blackListFilter.HostRegExs.Add(regex.Regex);
                    }
                }
                if (filter is WhitelistFilter)
                {
                    var whitelistFilter = (WhitelistFilter)filter;
                    foreach (RegexElement regex in configuration.Whitelist)
                    {
                        whitelistFilter.HostRegExs.Add(regex.Regex);
                    }
                }
                proxy.AddRequestFilter(filter);
            }
            Trace.TraceInformation("Starting proxy server...");
            proxy.Start();

            System.Console.WriteLine("Press any key to quit...");
            System.Console.ReadKey();

            Trace.TraceInformation("Stopping proxy server...");
            proxy.Stop();
        }
        public void Stop()
        {
            if (mViewerConfig.UseThread)
            {
                CameraThread.Stop();
            }

            if (mProxy != null)
            {
                ThisLogger.Debug("Closing");
                mProxy.Stop();
                mProxy = null;
            }
            ThisLogger.Info("Closed");
            stopping = true;
            if (mCanncelTockenSource != null)
            {
                mCanncelTockenSource.Cancel();
            }
        }
Example #23
0
 /// <summary>
 /// stop the proxy and free up resources
 /// </summary>
 /// <returns></returns>
 public async Task <bool> Stop()
 {
     return(await Task.Run(() =>
     {
         try
         {
             Proxy.Stop();
             OnUpdateStatus?.Invoke(this, new ProxyStatusEventsArguments()
             {
                 Status = ProxyStatus.Stopped
             });
             return true;
         }
         catch (Exception e)
         {
             Helpers.YTrackLogger.Log("Could not stop Titanium : " + e.Message + "\n\n" + e.StackTrace);
             return false;
         }
     }));
 }
Example #24
0
        protected void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _proxy.Stop();
                    _proxy = null;

                    _poller.Dispose();
                    _poller = null;

                    _backendSocket.Dispose();
                    _backendSocket = null;

                    _frontendSocket.Dispose();
                    _frontendSocket = null;
                }

                _disposedValue = true;
            }
        }
Example #25
0
        public void StoppingProxyDisengagesFunctionality()
        {
            using (var context = NetMQContext.Create())
            using (var front = context.CreateRouterSocket())
            using (var back = context.CreateDealerSocket())
            {
                front.Bind("inproc://frontend");
                back.Bind("inproc://backend");

                var proxy = new Proxy(front, back);
                Task.Factory.StartNew(proxy.Start);

                // Send a message through to ensure the proxy has started
                using (var client = context.CreateRequestSocket())
                using (var server = context.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");
                    client.SendFrame("hello");
                    Assert.AreEqual("hello", server.ReceiveFrameString());
                    server.SendFrame("reply");
                    Assert.AreEqual("reply", client.ReceiveFrameString());

                    proxy.Stop(); // blocks until stopped

                    using (var poller = new Poller(front, back))
                    {
                        poller.PollTillCancelledNonBlocking();

                        client.SendFrame("anyone there?");

                        // Should no longer receive any messages
                        Assert.IsFalse(server.TrySkipFrame(TimeSpan.FromMilliseconds(50)));

                        poller.CancelAndJoin();
                    }
                }
            }
        }
Example #26
0
 private void PlayBtn_OnClick(object sender, RoutedEventArgs e)
 {
     if (!_isProxyRunning)
     {
         PlayBtn.IsEnabled = false;
         PacketsListView.Items.Clear();
         PacketsListView.SelectedIndex = -1;
         PacketParseListView.Items.Clear();
         PacketParseListView.SelectedIndex = -1;
         _packets.Clear();
         StatusRunning.IsIndeterminate = true;
         var action = new Action <List <ListViewModel> >(UpdateWithParsedPacket);
         _snifferProxy = new Proxy(action);
         _snifferProxy.Start();
     }
     else
     {
         PlayBtn.IsEnabled             = true;
         StatusRunning.IsIndeterminate = false;
         _snifferProxy.Stop();
         _isProxyRunning = false;
     }
 }
Example #27
0
 public void Kill()
 {
     _proxy.Stop();
 }
Example #28
0
 protected override void OnStop()
 {
     proxy.Stop();
 }
Example #29
0
 public override void OnStop()
 {
     Proxy.Stop();
 }
Example #30
0
        public static void Main(string[] args)
        {
#if !UNIX && !DEBUG
            if (args.Length == 0)
            {
                Console.WriteLine("Arguments:");
                Console.WriteLine("--conf, -c           Path the xml configuration file.");
                return;
            }
#endif

#if !UNIX
            // Setup console
            _styleSheet = new StyleSheet(Color.White);
            _styleSheet.AddStyle(@"[0-9\/]+ [0-9:]+ (?:A|P)M", Color.SlateBlue);
            _styleSheet.AddStyle(@"\[[A-Z]+\]", Color.Gold);
            _styleSheet.AddStyle(@"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)", Color.Purple);
            _styleSheet.AddStyle(@"#[-az0-9_-]", Color.DarkGreen);
            _styleSheet.AddStyle(@"[a-f0-9]{32}", Color.Orange);
            _styleSheet.AddStyle(@"[a-z_-]+\-[0-9]{5}patch[0-9]\.[0-9]\.[0-9]_[A-Za-z]+", Color.Firebrick);
#endif

            _startupArguments = args;

            Console.CancelKeyPress += (s, ea) => {
                WriteLine("[ERROR] Aborting ...");
                foreach (var knownServer in _ircClients)
                {
                    knownServer.Value.Disconnect();
                }

                Proxy?.Stop();

                _token.Cancel();
            };

            #region Load XML configuration file
            var configurationFileName = GetStringParam("--conf", "-c", "conf.xml");
            var serializer            = new XmlSerializer(typeof(Configuration));
            using (var reader = new StreamReader(configurationFileName))
                Configuration = (Configuration)serializer.Deserialize(reader);
            #endregion

            // Read channels from XML
            foreach (var channelInfo in Configuration.Branches)
            {
                var newChannel = new Channel()
                {
                    ChannelName = channelInfo.Name, DisplayName = channelInfo.Description
                };
                newChannel.BuildDeployed += OnBuildDeployed;

                Channels.Add(newChannel);
            }

            #region HTTP Proxy setup

            if (Configuration.Proxy.Enabled)
            {
                WriteLine("[HTTP] Listening on http://{1}:{0}", Configuration.Proxy.PublicDomainName, Configuration.Proxy.BindPort);

                Proxy = new HttpServer(Configuration.Proxy.Endpoint, Configuration.Proxy.PublicDomainName);
                Proxy.Listen(Configuration.Proxy.BindPort, _token);
            }
            #endregion

            // Setup IRC clients
            foreach (var serverInfo in Configuration.Servers)
            {
                WriteLine("[IRC] Connecting to {0}:{1}", serverInfo.Address, serverInfo.Port);

                var client = new IrcClient()
                {
                    SupportNonRfc        = true,
                    ActiveChannelSyncing = true
                };

                client.OnConnected += (sender, eventArgs) => StartThreads();

                client.OnChannelMessage += (sender, eventArgs) => {
                    Dispatcher.Dispatch(eventArgs.Data, client);
                };

                client.Connect(serverInfo.Address, serverInfo.Port);
                client.Login(serverInfo.Username, serverInfo.Username, 0, serverInfo.Username);
                foreach (var channelInfo in serverInfo.Channels)
                {
                    if (string.IsNullOrEmpty(channelInfo.Key))
                    {
                        client.RfcJoin("#" + channelInfo.Name);
                    }
                    else
                    {
                        client.RfcJoin("#" + channelInfo.Name, channelInfo.Key);
                    }
                }

                Task.Run(() => { client.Listen(); });

                _ircClients[serverInfo.Address] = client;
            }

            while (!_token.IsCancellationRequested)
            {
                if (_token.Token.WaitHandle.WaitOne(10000))
                {
                    break;
                }

                RemoteBuildManager.ClearExpiredBuilds();
            }

            RemoteBuildManager.ClearExpiredBuilds();
        }
Example #31
0
 public void Stop()
 {
     _webApp.Dispose();
     _proxy.Stop();
 }