Skip to content

Commit

Permalink
本地地址。在本地有多个IP时,可以指定使用哪一个IP地址
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Apr 25, 2024
1 parent 30df6ef commit 91e5375
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Doc/srmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ do

-- https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Proto.html#lua_class_ProtoField
local FF_flag = {
[7] = "[Reply]",
[6] = "[Error/Oneway]"
}

-- local f_flag = ProtoField.uint8("SRMP.flag", "标记", base.HEX, FF_flag, 0xFF)
local f_flag = ProtoField.uint8("SRMP.flag", "标记", base.HEX)
[0x80] = "[Reply]",
[0x81] = "[Reply]",
[8] = "[Reply]",
[7] = "[Error/Oneway]",
[2] = "[Json]",
[1] = "[Binary]"
}

local f_flag = ProtoField.uint8("SRMP.flag", "标记", base.HEX, FF_flag, 0xFF)
-- local f_flag = ProtoField.uint8("SRMP.flag", "标记", base.HEX)
local f_seq = ProtoField.uint8("SRMP.seq", "序列号", base.DEC)
local f_length = ProtoField.uint16("SRMP.length", "长度", base.DEC)
local f_action = ProtoField.string("SRMP.action", "动作", base.ASCII)
Expand Down Expand Up @@ -77,7 +81,7 @@ do
end
end

local udp_encap_table = DissectorTable.get("udp.port")
local udp_encap_table = DissectorTable.get("newlife")
udp_encap_table:add(5500, p_srmp)
udp_encap_table:add(9999, p_srmp)
udp_encap_table:add(3500, p_srmp)
Expand Down
5 changes: 5 additions & 0 deletions NewLife.Remoting/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ApiClient : ApiHost, IApiClient
/// <summary>服务端地址集合。负载均衡</summary>
public String[]? Servers { get; set; }

/// <summary>本地地址。在本地有多个IP时,可以指定使用哪一个IP地址</summary>
public NetUri Local { get; set; }

/// <summary>客户端连接集群</summary>
public ICluster<String, ISocketClient>? Cluster { get; set; }

Expand Down Expand Up @@ -397,6 +400,8 @@ protected virtual ISocketClient OnCreate(String svr)
client.Timeout = Timeout;
client.Tracer = Tracer;

if (Local != null) client.Local = Local;

client.Add(GetMessageCodec());

client.Opened += (s, e) => OnNewSession((s as ISocketClient)!);
Expand Down
1 change: 1 addition & 0 deletions NewLife.Remoting/Clients/HttpClientBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.Net.Http;
using System.Net.NetworkInformation;
using NewLife;
using NewLife.Caching;
Expand Down

0 comments on commit 91e5375

Please sign in to comment.