public static void SetConfiguration(BabaluConfiguration config) { _configLock.EnterWriteLock(); try { bool running = ProxyListener.StopAll(); _configuration = config; if (running && _configuration == null) _configuration = LoadConfiguration(); if ( running ) ProxyListener.StartAll(); } finally { _configLock.ExitWriteLock(); } }
private void _startBtn_Click(object sender, EventArgs e) { if (_started == false) { try { BabaluConfiguration babaluServerConfiguration = new BabaluConfiguration() { LogsLocation = _logsLocationTxt.Text, EnableEventLog = _eventLogChk.Checked, EnablePerfmon = _enablePerfmonChk.Checked, LogDebug = _logDebugChk.Checked, LogErrors = _logErrorsChk.Checked, LogInformation = _logInformationChk.Checked, LogRequests = _logRequestsChk.Checked, ProxiedServers = new List<BabaluProxiedServer>() }; babaluServerConfiguration.ProxiedServers.Add( new BabaluProxiedServer() { ProxyIP = _proxyIPTxt.Text, ProxyPorts = LoadProxyPorts(_proxyPortsTxt.Text), ProxiedServers = LoadProxiedServers(_proxiedServerTxt.Text), SupportGZip = _supportsGzipChk.Checked, CacheContent = _cacheContentChk.Checked, MaxQueueLength = Convert.ToInt32(_maxQueueLengthCtrl.Value) } ); ExtensionConfig.SetConfiguration(babaluServerConfiguration); } catch (Exception excp) { MessageBox.Show(this, excp.Message, "Exception setting config"); } try { ExtensionConfig.StartBabalu(null); _started = true; _startBtn.Text = "Stop"; } catch (Exception excp) { MessageBox.Show(this, excp.Message, "Exception Starting config"); } } else { StopBabalu(); } }
private static BabaluConfiguration LoadConfiguration() { BabaluConfiguration configuration = new BabaluConfiguration() { LogsLocation = LoadLogsLocation(), LogRequests = BoolConfigKey(_logRequestsKey, null, true), LogErrors = BoolConfigKey(_logErrorsKey, null, true), LogInformation = BoolConfigKey(_logInformationKey, null, true), LogDebug = BoolConfigKey(_logDebugKey, null, false), EnablePerfmon = BoolConfigKey(_enablePerfmonLogKey, null, true), EnableEventLog = BoolConfigKey(_enableEventLogKey, null, false), BypassProcessing = BoolConfigKey(_bypassProcessingKey, null, false) }; configuration.ProxiedServers = new List<BabaluProxiedServer>(); string proxyIP; for (int i = 1; (proxyIP = StringConfigKey(_proxyIPKey, i, null)) != null; i++) { configuration.ProxiedServers.Add(new BabaluProxiedServer() { ProxyIP = proxyIP, ProxyPorts = LoadProxyPorts(i), SupportGZip = BoolConfigKey(_supportGZipKey, i, true), CacheContent = BoolConfigKey(_cacheContentKey, i, true), MaxQueueLength = IntConfigKey(_maxQueueLengthKey, i, 0), ProxiedServers = LoadProxiedServers(i), ServerType = StringConfigKey(_serverTypeKey, i, null) } ); } return configuration; }
/// <summary> /// set this as the configuration /// </summary> /// <param name="config"></param> public static void SetConfiguration(BabaluConfiguration config) { BabaluConfigurationFactory.SetConfiguration(config); }