From 3025771eb7bcf09650d4fe333ea772be8c6173bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Tue, 17 Sep 2024 08:12:23 +0800 Subject: [PATCH] =?UTF-8?q?v3.1=20=E4=BD=BF=E7=94=A8v11=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E5=BA=93=E7=9A=84IPacket=E6=95=B0=E6=8D=AE=E5=8C=85=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ClientTest/ClientTest.csproj | 2 +- Samples/TestA/TestA.csproj | 2 +- Samples/TestB/TestB.csproj | 2 +- StarAgent/StarAgent.csproj | 4 +-- StarGateway/Proxy/HttpReverseProxy.cs | 28 +++++++++---------- StarGateway/Proxy/ProxySession.cs | 2 +- StarGateway/StarGateway.csproj | 8 ++++++ .../Stardust.Extensions.csproj | 2 +- Stardust.Server/Stardust.Server.csproj | 2 +- Stardust.Web/Stardust.Web.csproj | 2 +- Stardust/LocalStarClient.cs | 9 ++++-- Stardust/Stardust.csproj | 13 ++++----- Test/Program.cs | 5 ++-- Test/Test.csproj | 2 +- 14 files changed, 45 insertions(+), 38 deletions(-) diff --git a/ClientTest/ClientTest.csproj b/ClientTest/ClientTest.csproj index 0cc83209..997b4d30 100644 --- a/ClientTest/ClientTest.csproj +++ b/ClientTest/ClientTest.csproj @@ -21,7 +21,7 @@ - + diff --git a/Samples/TestA/TestA.csproj b/Samples/TestA/TestA.csproj index bff0f203..f1f61246 100644 --- a/Samples/TestA/TestA.csproj +++ b/Samples/TestA/TestA.csproj @@ -18,7 +18,7 @@ - + diff --git a/Samples/TestB/TestB.csproj b/Samples/TestB/TestB.csproj index 338911c8..89100ea0 100644 --- a/Samples/TestB/TestB.csproj +++ b/Samples/TestB/TestB.csproj @@ -18,7 +18,7 @@ - + diff --git a/StarAgent/StarAgent.csproj b/StarAgent/StarAgent.csproj index 8346e582..8f890ddf 100644 --- a/StarAgent/StarAgent.csproj +++ b/StarAgent/StarAgent.csproj @@ -2,12 +2,12 @@ Exe - netcoreapp3.1;net5.0;net6.0;net40;net45;net461;net7.0;net8.0 + netcoreapp3.1;net5.0;net6.0;net45;net461;net7.0;net8.0 星尘代理 星尘,分布式资源调度,部署于每一个节点,连接服务端,支持节点监控、远程发布。 新生命开发团队 ©2002-2024 NewLife - 3.0 + 3.1 $([System.DateTime]::Now.ToString(`yyyy.MMdd`)) $(VersionPrefix).$(VersionSuffix) $(Version) diff --git a/StarGateway/Proxy/HttpReverseProxy.cs b/StarGateway/Proxy/HttpReverseProxy.cs index 91df8b55..4fe50392 100644 --- a/StarGateway/Proxy/HttpReverseProxy.cs +++ b/StarGateway/Proxy/HttpReverseProxy.cs @@ -1,8 +1,6 @@ -using System; -using System.IO; -using NewLife; +using NewLife; +using NewLife.Http; using NewLife.Net; -using StarGateway.Http; namespace StarGateway.Proxy { @@ -72,19 +70,19 @@ protected override void OnReceive(ReceivedEventArgs e) // 请求头 var request = new HttpRequest(); - if (request.Read(e.Packet)) + if (request.Parse(e.Packet)) { e.Message = request; - // 解码请求头,准备修改细节 - request.DecodeHeaders(); + //// 解码请求头,准备修改细节 + //request.DecodeHeaders(); - if (OnRequest(request, e)) - { - // 重新生成Http请求头 - request.EncodeHeaders(); - e.Packet = request.ToPacket(); - } + //if (OnRequest(request, e)) + //{ + // // 重新生成Http请求头 + // request.EncodeHeaders(); + // e.Packet = request.ToPacket(); + //} //var uri = new NetUri(NetType.Http, RawHost, Session.Local.Port); WriteDebugLog(LocalUri + ""); @@ -98,12 +96,12 @@ protected virtual Boolean OnRequest(HttpRequest request, ReceivedEventArgs e) // 修改Host var host = request.Headers["Host"]; - LocalUri = new Uri($"http://{host}:{Session.Local.Port}{request.Uri}"); + LocalUri = new Uri($"http://{host}:{Session.Local.Port}{request.RequestUri}"); host = GetHost(host); if (host.IsNullOrEmpty()) return false; - RemoteUri = new Uri($"http://{host}:{RemoteServerUri.Port}{request.Uri}"); + RemoteUri = new Uri($"http://{host}:{RemoteServerUri.Port}{request.RequestUri}"); request.Headers["Host"] = host; diff --git a/StarGateway/Proxy/ProxySession.cs b/StarGateway/Proxy/ProxySession.cs index ce77c395..f7b3d0c4 100644 --- a/StarGateway/Proxy/ProxySession.cs +++ b/StarGateway/Proxy/ProxySession.cs @@ -195,7 +195,7 @@ protected virtual void OnReceiveRemote(ReceivedEventArgs e) #region 发送 /// 发送数据 /// 缓冲区 - public virtual Int32 SendRemote(Packet pk) + public virtual Int32 SendRemote(IPacket pk) { try { diff --git a/StarGateway/StarGateway.csproj b/StarGateway/StarGateway.csproj index 2c395072..247e7909 100644 --- a/StarGateway/StarGateway.csproj +++ b/StarGateway/StarGateway.csproj @@ -27,9 +27,17 @@ false + + + + + + + + diff --git a/Stardust.Extensions/Stardust.Extensions.csproj b/Stardust.Extensions/Stardust.Extensions.csproj index 9e673d0e..939af0e3 100644 --- a/Stardust.Extensions/Stardust.Extensions.csproj +++ b/Stardust.Extensions/Stardust.Extensions.csproj @@ -7,7 +7,7 @@ 星尘,分布式服务框架扩展。节点管理,监控中心,配置中心,发布中心,注册中心 新生命开发团队 ©2002-2024 NewLife - 3.0 + 3.1 $([System.DateTime]::Now.ToString(`yyyy.MMdd`)) $(VersionPrefix).$(VersionSuffix) $(Version) diff --git a/Stardust.Server/Stardust.Server.csproj b/Stardust.Server/Stardust.Server.csproj index cdc26839..16902fa2 100644 --- a/Stardust.Server/Stardust.Server.csproj +++ b/Stardust.Server/Stardust.Server.csproj @@ -45,7 +45,7 @@ - + diff --git a/Stardust.Web/Stardust.Web.csproj b/Stardust.Web/Stardust.Web.csproj index 52942fc9..38f073a6 100644 --- a/Stardust.Web/Stardust.Web.csproj +++ b/Stardust.Web/Stardust.Web.csproj @@ -52,7 +52,7 @@ - + diff --git a/Stardust/LocalStarClient.cs b/Stardust/LocalStarClient.cs index d887739d..1ea6af97 100644 --- a/Stardust/LocalStarClient.cs +++ b/Stardust/LocalStarClient.cs @@ -5,6 +5,7 @@ using System.Net.NetworkInformation; using System.Net.Sockets; using NewLife; +using NewLife.Data; using NewLife.Http; using NewLife.Log; using NewLife.Messaging; @@ -470,8 +471,10 @@ public static Task ProbeAsync(String? url = null, String? version = null, String //}; //var buf = msg.ToPacket().ToArray(); - var buf = encoder.CreateRequest("Info", null).ToPacket()?.ToArray(); - if (buf == null) yield break; + var pk = encoder.CreateRequest("Info", null).ToPacket(); + if (pk == null) yield break; + + var buf = pk.ToArray(); // 在局域网中广播消息 var udp = new UdpClient(); @@ -483,7 +486,7 @@ public static Task ProbeAsync(String? url = null, String? version = null, String var rs = new DefaultMessage(); IPEndPoint? ep = null; buf = udp.Receive(ref ep); - if (buf != null && rs.Read(buf)) + if (buf != null && rs.Read((ArrayPacket)buf)) { var msg = encoder.Decode(rs); if (msg != null && msg.Data != null) diff --git a/Stardust/Stardust.csproj b/Stardust/Stardust.csproj index 8e8b3ae7..d3609a31 100644 --- a/Stardust/Stardust.csproj +++ b/Stardust/Stardust.csproj @@ -1,13 +1,13 @@  - net40;net45;net461;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net6.0-windows;net7.0;net7.0-windows;net8.0;net8.0-windows + net45;net461;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net6.0-windows;net7.0;net7.0-windows;net8.0;net8.0-windows Stardust 星尘分布式服务核心 星尘,分布式服务框架。节点管理,监控中心,配置中心,发布中心,注册中心 新生命开发团队 ©2002-2024 NewLife - 3.0 + 3.1 $([System.DateTime]::Now.ToString(`yyyy.MMdd`)) $(VersionPrefix).$(VersionSuffix) $(Version) @@ -112,13 +112,10 @@ - + - - - - - + + diff --git a/Test/Program.cs b/Test/Program.cs index b78bc67f..9566b85a 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -7,6 +7,7 @@ using System.Net.Sockets; using System.Threading; using NewLife; +using NewLife.Data; using NewLife.IO; using NewLife.Log; using NewLife.Messaging; @@ -57,7 +58,7 @@ static async void Test1() // Thread.Sleep(1000); //} - await io.Put("aa.txt", "学无先后达者为师!".GetBytes()); + await io.Put("aa.txt", (ArrayPacket)"学无先后达者为师!".GetBytes()); var rs = await io.Get("aa.txt"); XTrace.WriteLine(rs.Data.ToStr()); @@ -157,7 +158,7 @@ static void Test4() writer.Write(0); var msg = new DefaultMessage(); - msg.Payload = ms.ToArray(); + msg.Payload = (ArrayPacket)ms.ToArray(); var buf = msg.ToPacket().ToArray(); XTrace.WriteLine(buf.ToHex()); diff --git a/Test/Test.csproj b/Test/Test.csproj index f45a0fbe..1107307e 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -30,7 +30,7 @@ - +