From adba9165b8fac7a17dcda4fd2dc792549bf51784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=A1=BA=E6=98=8E?= Date: Mon, 8 Apr 2024 08:31:38 +0800 Subject: [PATCH] Syslog --- Bridge/HttpBridgeActivity.cs | 3 +++ Mime/HttpMimeServier.cs | 11 ++++++++++- Proxy/DataFactory.cs | 10 +++++----- Proxy/HttpProxy.cs | 2 +- Proxy/LogSetting.cs | 11 ++++++++--- Proxy/SiteServerActivity.cs | 7 ++----- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Bridge/HttpBridgeActivity.cs b/Bridge/HttpBridgeActivity.cs index 9bb29c5..42e7d52 100644 --- a/Bridge/HttpBridgeActivity.cs +++ b/Bridge/HttpBridgeActivity.cs @@ -22,7 +22,10 @@ namespace UMC.ITME switch (model) { case "Reload": + WebServlet.DomainUnion = (UMC.Data.WebResource.Instance().Provider["union"] ?? ".")[0]; + WebServlet.MainDomain = UMC.Data.WebResource.Instance().Provider["domain"] ?? "localhost"; var msg = HttpMimeServier.Load(UMC.Data.Reflection.Configuration("host")); + NetSubscribe.Publish("Servier", "Reload"); if (msg.Length > 0) { this.Prompt("提示", msg); diff --git a/Mime/HttpMimeServier.cs b/Mime/HttpMimeServier.cs index f775cf7..5bfad83 100644 --- a/Mime/HttpMimeServier.cs +++ b/Mime/HttpMimeServier.cs @@ -258,7 +258,7 @@ namespace UMC.ITME } - public class HttpMimeServier : IDoWorker + public class HttpMimeServier : IDoWorker, IStringSubscribe { static String _Server = Dns.GetHostName(); public static String Server => _Server; @@ -826,6 +826,7 @@ namespace UMC.ITME HotCache.LoadFile(); + NetSubscribe.Subscribe("Servier", this); UMC.Web.WebResource.Instance(new UMC.ITME.WebResource(), UMC.Web.WebResource.Instance().Provider); var hosts = Reflection.Configuration("host");//?? new ProviderConfiguration(); @@ -1557,6 +1558,14 @@ namespace UMC.ITME Register(3600, this); } + public void Subscribe(string message) + { + + WebServlet.DomainUnion = (UMC.Data.WebResource.Instance().Provider["union"] ?? ".")[0]; + WebServlet.MainDomain = UMC.Data.WebResource.Instance().Provider["domain"] ?? "localhost"; + Load(UMC.Data.Reflection.Configuration("host")); + // throw new NotImplementedException(); + } internal static ConcurrentDictionary httpMimes = new ConcurrentDictionary(); diff --git a/Proxy/DataFactory.cs b/Proxy/DataFactory.cs index 41bf6f7..2fe0a09 100644 --- a/Proxy/DataFactory.cs +++ b/Proxy/DataFactory.cs @@ -30,11 +30,11 @@ namespace UMC.ITME return _Instance; } static DataFactory _Instance;// = new DataFactory(); - public static void Instance(DataFactory dataFactory) - { - _Instance = dataFactory; - NetSubscribe.Subscribe("SiteConfig", _Instance); - } + // public static void Instance(DataFactory dataFactory) + // { + // _Instance = dataFactory; + // NetSubscribe.Subscribe("SiteConfig", _Instance); + // } public virtual Site[] Site() diff --git a/Proxy/HttpProxy.cs b/Proxy/HttpProxy.cs index 27d94f1..086948a 100644 --- a/Proxy/HttpProxy.cs +++ b/Proxy/HttpProxy.cs @@ -3671,7 +3671,7 @@ namespace UMC.ITME if (this.StaticModel >= 0) { - var pmd5Key = $"{this.Site.Site.Version}{_RootKey}{WebServlet.MainDomain}"; + var pmd5Key = $"{this.Site.Site.Version}{_RootKey}{WebServlet.MainDomain}{WebServlet.DomainUnion}"; switch (this.StaticModel) { case 0: diff --git a/Proxy/LogSetting.cs b/Proxy/LogSetting.cs index 5d42609..2e91922 100644 --- a/Proxy/LogSetting.cs +++ b/Proxy/LogSetting.cs @@ -107,9 +107,14 @@ namespace UMC.ITME break; } } - await this.client.SendAsync(buffers.AsMemory(0, index)); - }else{ - + try + { + await this.client.SendAsync(buffers.AsMemory(0, index)); + } + catch (Exception ex) + { + Utility.Error("Syslog", ex.ToString()); + } } } System.Buffers.ArrayPool.Shared.Return(buffers); diff --git a/Proxy/SiteServerActivity.cs b/Proxy/SiteServerActivity.cs index fb4d0ea..34221bc 100644 --- a/Proxy/SiteServerActivity.cs +++ b/Proxy/SiteServerActivity.cs @@ -38,9 +38,6 @@ namespace UMC.ITME.Activities ui.NewSection().AddCell("日志服务", new UIClick(request, "Log")); - - - var http = hosts.Providers.Where(r => r.Type == "http"); var httpUI = ui.NewSection(); @@ -207,7 +204,7 @@ namespace UMC.ITME.Activities fm.AddText("主域名", "domain", provider["domain"]); var union = provider["union"] ?? "."; var scheme = provider["scheme"] ?? "http"; - fm.AddRadio("连接符", "union").Put(".", ".", union == ".").Put("-", "-", union == "-"); + // fm.AddRadio("连接符", "union").Put(".", ".", union == ".").Put("-", "-", union == "-"); fm.AddRadio("主协议", "scheme").Put("http", "http", scheme == "http").Put("https", "https", scheme == "https"); fm.Submit("确认", $"{request.Model}.{request.Command}"); return fm; @@ -215,7 +212,7 @@ namespace UMC.ITME.Activities provider.Attributes["scheme"] = Domains["scheme"]; provider.Attributes["domain"] = Domains["domain"]; - provider.Attributes["union"] = Domains["union"]; + // provider.Attributes["union"] = Domains["union"]; var pc = UMC.Data.Reflection.Configuration("assembly") ?? new ProviderConfiguration();