Ejemplo n.º 1
0
        public void Stop()
        {
            try
            {
                if (timer != null)
                {
                    timer.Stop();
                    timer.Dispose();
                    timer = null;
                }
                if (_tcpRelay != null)
                {
                    _tcpRelay.Stop();
                    _tcpRelay = null;
                }
                if (_udpRelay != null)
                {
                    _udpRelay.Stop();
                    _udpRelay = null;
                }
                if (KCPTunnelController.IsRunning)
                {
                    KCPTunnelController.Stop();
                }

                TrafficStatistics.Save(_trafficStatistics);
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }
Ejemplo n.º 2
0
        public MainController()
        {
            ConfigController = new ConfigurationController(this);
            ConfigController.ConfigChanged += OnConfigChanged;

            KCPTunnelController = new KCPTunnelController(this);

            _trafficStatistics = TrafficStatistics.Load();
        }
Ejemplo n.º 3
0
        public void Reload()
        {
            try
            {
                if (timer != null)
                {
                    timer.Stop();
                    timer.Dispose();
                    timer = null;
                }
                if (_ssudpRelay != null)
                {
                    _ssudpRelay.Stop();
                    _ssudpRelay = null;
                }
                if (_tcpRelay != null)
                {
                    _tcpRelay.Stop();
                    _tcpRelay = null;
                }
                if (_udpRelay != null)
                {
                    _udpRelay.Stop();
                    _udpRelay = null;
                }
                if (KCPTunnelController.IsRunning)
                {
                    KCPTunnelController.Stop();
                }
                Configuration config = ConfigController.GetCurrentConfiguration();
                Server        server = config.GetCurrentServer();
                traffic = _trafficStatistics.GetTrafficLog(server);
                if (config.enabled)
                {
                    if (server.ss_relay_udp)
                    {
                        RelaySSUDPData(server);
                    }

                    KCPTunnelController.Server     = server;
                    KCPTunnelController.localaddr  = null;
                    KCPTunnelController.remoteaddr = null;
                    if (config.statistics_enabled)
                    {
                        RegistStatistics();
                        StartTrafficLogger();
                    }
                    KCPTunnelController.Start();
                }
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }