private void PACServerPACUpdateCompleted(object sender, GFWListUpdater.ResultEventArgs e) { if (UpdatePacFromGfwListCompleted != null) UpdatePacFromGfwListCompleted(this, e); }
public void Reload() { // some logic in configuration updated the config when saving, we need to read it again _config = Configuration.Load(); Server server = _config.GetCurrentServer(); if (String.IsNullOrEmpty(server.Host) || (server.Port <= 0 || server.Port > 65535) || String.IsNullOrEmpty(server.Password)) { return; } if (_xsocksRunner == null) { _xsocksRunner = new XsocksRunner(); _xsocksRunner.LogMessageReceived += _xsocksRunner_LogMessageReceived; } if (_polipoRunner == null) { _polipoRunner = new PolipoRunner(); } if (_pacServer == null) { _pacServer = new PACServer(); _pacServer.PACFileChanged += PACServerPACFileChanged; } if (_gfwListUpdater == null) { _gfwListUpdater = new GFWListUpdater(); _gfwListUpdater.UpdateCompleted += PACServerPACUpdateCompleted; _gfwListUpdater.Error += PACServerPACUpdateError; } if (_listener != null) { _listener.Stop(); } // don't put polipoRunner.Start() before pacServer.Stop() // or bind will fail when switching bind address from 0.0.0.0 to 127.0.0.1 // though UseShellExecute is set to true now // http://stackoverflow.com/questions/10235093/socket-doesnt-close-after-application-exits-if-a-launched-process-is-open _xsocksRunner.Stop(); _polipoRunner.Stop(); try { _xsocksRunner.Start(_config); _polipoRunner.Start(_config); _pacServer.HttpProxyPort = _polipoRunner.RunningPort; List<Listener.IService> services = new List<Listener.IService>(); services.Add(_pacServer); _listener = new Listener(services); _listener.Start(_config.PACServerPort, _config.ShareOverLan); } catch (Exception e) { // translate Microsoft language into human language // i.e. An attempt was made to access a socket in a way forbidden by its access permissions => Port already in use if (e is SocketException) { SocketException se = (SocketException)e; if (se.SocketErrorCode == SocketError.AccessDenied) { e = new Exception("Port already in use", e); } } Logging.LogUsefulException(e); ReportError(e); } if (ConfigChanged != null) { ConfigChanged(this, new EventArgs()); } UpdateSystemProxy(); Utils.ReleaseMemory(); }
void ControllerUpdatePACFromGFWListCompleted(object sender, GFWListUpdater.ResultEventArgs e) { string result = e.Success ? "PAC updated" : "No updates found. Please report to GFWList if you have problems with it."; ShowBalloonTip("Xsocks", result, ToolTipIcon.Info, 1000); }