diff --git a/Shadowsocks.WPF/Models/NlogConfig.cs b/Shadowsocks.WPF/Models/NlogConfig.cs deleted file mode 100644 index 61353793..00000000 --- a/Shadowsocks.WPF/Models/NlogConfig.cs +++ /dev/null @@ -1,137 +0,0 @@ -using NLog; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; - -namespace Shadowsocks.WPF.Models -{ - public class NLogConfig - { - public enum LogLevel - { - Fatal, - Error, - Warn, - Info, - Debug, - Trace, - } - private static string _NLOG_CONFIG_FILE_NAME=string.Empty; - public static string NLOG_CONFIG_FILE_NAME - { - get - { - if (string.IsNullOrEmpty(_NLOG_CONFIG_FILE_NAME)) - { - _NLOG_CONFIG_FILE_NAME = Path.Combine(Environment.CurrentDirectory, "NLog.config"); - } - return _NLOG_CONFIG_FILE_NAME; - } - } - const string TARGET_MIN_LEVEL_ATTRIBUTE = "minlevel"; - const string LOGGER_FILE_NAME_ATTRIBUTE = "fileName"; - - XmlDocument doc = new XmlDocument(); - XmlElement? logFileNameElement; - XmlElement? logLevelElement; - - /// - /// Load the NLog config xml file content - /// - public static NLogConfig LoadXML() - { - NLogConfig config = new NLogConfig(); - config.doc.Load(NLOG_CONFIG_FILE_NAME); - config.logLevelElement = (XmlElement?)SelectSingleNode(config.doc, "//nlog:logger[@name='*']"); - config.logFileNameElement = (XmlElement?)SelectSingleNode(config.doc, "//nlog:target[@name='file']"); - return config; - } - - /// - /// Save the content to NLog config xml file - /// - public static void SaveXML(NLogConfig nLogConfig) - { - nLogConfig.doc.Save(NLOG_CONFIG_FILE_NAME); - } - - - /// - /// Get the current minLogLevel from xml file - /// - /// - public LogLevel GetLogLevel() - { - LogLevel level = LogLevel.Warn; - string levelStr = logLevelElement.GetAttribute(TARGET_MIN_LEVEL_ATTRIBUTE); - Enum.TryParse(levelStr, out level); - return level; - } - - /// - /// Get the target fileName from xml file - /// - /// - public string GetLogFileName() - { - return logFileNameElement.GetAttribute(LOGGER_FILE_NAME_ATTRIBUTE); - } - - /// - /// Set the minLogLevel to xml file - /// - /// - public void SetLogLevel(LogLevel logLevel) - { - logLevelElement.SetAttribute(TARGET_MIN_LEVEL_ATTRIBUTE, logLevel.ToString("G")); - } - - /// - /// Set the target fileName to xml file - /// - /// - public void SetLogFileName(string fileName) - { - logFileNameElement.SetAttribute(LOGGER_FILE_NAME_ATTRIBUTE, fileName); - } - - /// - /// Select a single XML node/elemant - /// - /// - /// - /// - private static XmlNode? SelectSingleNode(XmlDocument doc, string xpath) - { - XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable); - manager.AddNamespace("nlog", "http://www.nlog-project.org/schemas/NLog.xsd"); - //return doc.SelectSingleNode("//nlog:logger[(@shadowsocks='managed') and (@name='*')]", manager); - return doc.SelectSingleNode(xpath, manager); - } - - /// - /// Extract the pre-defined NLog configuration file is does not exist. Then reload the Nlog configuration. - /// - public static void TouchAndApplyNLogConfig() - { - - if (!File.Exists(NLOG_CONFIG_FILE_NAME)) - { - File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog); - LogManager.LoadConfiguration(NLOG_CONFIG_FILE_NAME); - } - } - - /// - /// NLog reload the config file and apply to current LogManager - /// - public static void LoadConfiguration() - { - LogManager.LoadConfiguration(NLOG_CONFIG_FILE_NAME); - } - } -} diff --git a/Shadowsocks.WPF/Properties/Resources.Designer.cs b/Shadowsocks.WPF/Properties/Resources.Designer.cs index 839e0ab0..9f3cc43f 100644 --- a/Shadowsocks.WPF/Properties/Resources.Designer.cs +++ b/Shadowsocks.WPF/Properties/Resources.Designer.cs @@ -60,21 +60,6 @@ namespace Shadowsocks.WPF.Properties { } } - /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?> - ///<!-- Warning: Configuration may reset after shadowsocks upgrade. --> - ///<!-- If you messed it up, delete this file and Shadowsocks will create a new one. --> - ///<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - /// <targets> - /// <!-- This line is managed by Shadowsocks. Do not modify it unless you know what you are doing.--> - /// <target name="file" xsi:type="File" fileName="ss_win_temp\shadowsocks [rest of string was truncated]";. - /// - internal static string NLog { - get { - return ResourceManager.GetString("NLog", resourceCulture); - } - } - /// /// Looks up a localized string similar to listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__ ///toggle 0 diff --git a/Shadowsocks.WPF/Properties/Resources.resx b/Shadowsocks.WPF/Properties/Resources.resx index 63ba1758..54016944 100644 --- a/Shadowsocks.WPF/Properties/Resources.resx +++ b/Shadowsocks.WPF/Properties/Resources.resx @@ -112,15 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\NLog.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - + ..\Resources\privoxy_conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 diff --git a/Shadowsocks.WPF/Resources/NLog.config b/Shadowsocks.WPF/Resources/NLog.config deleted file mode 100644 index d955c871..00000000 --- a/Shadowsocks.WPF/Resources/NLog.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Shadowsocks.WPF/Shadowsocks.WPF.csproj b/Shadowsocks.WPF/Shadowsocks.WPF.csproj index 9d886785..f58d85a4 100644 --- a/Shadowsocks.WPF/Shadowsocks.WPF.csproj +++ b/Shadowsocks.WPF/Shadowsocks.WPF.csproj @@ -19,7 +19,6 @@ - @@ -96,7 +95,6 @@ -