Skip to content

Commit

Permalink
Local模式只是代理给后端的健康检测包,不需要处理
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 4, 2024
1 parent 595ebe2 commit a1f06f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion NewLife.MQTT/ProxyProtocol/ProxyCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public class ProxyCodec : Handler
var rs = msg.Read(data);
if (rs > 0)
{
if (context is IExtend ext)
// Local模式只是代理给后端的健康检测包,不需要处理
if (msg.Command != 0x01) return msg;

if (context is IExtend ext && msg.Command == 0x01 && msg.Client != null)
{
ext["Proxy"] = msg;

Expand Down
16 changes: 16 additions & 0 deletions XUnitTestClient/ProxyProtocolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public void TestPPv2()
Assert.Equal("tcp://192.168.1.24:1883", msg.Proxy + "");
}

[Fact]
public void TestPPv2Local()
{
var str = "0D0A0D0A000D0A515549540A20000000";
var buf = str.ToHex();
var msg = new ProxyMessageV2();
var rs = msg.Read(buf);

Assert.True(rs > 0);
Assert.Equal(16, rs);
Assert.Equal(0x02, msg.Version);
Assert.Equal(0x00, msg.Command);
Assert.Null(msg.Client);
Assert.Null(msg.Proxy);
}

[Fact]
public async Task TestProxyProtocol()
{
Expand Down

0 comments on commit a1f06f3

Please sign in to comment.