规范配置

This commit is contained in:
sin365 2024-06-25 18:29:17 +08:00
parent 6339c18de7
commit cd1809587b
3 changed files with 8 additions and 9 deletions

View File

@ -5,11 +5,10 @@ namespace NoSugarNet.ClientCore.Common
public struct TunnelClientData
{
public byte TunnelId;
public string ServerLocalTargetIP;
public ushort ServerLocalTargetPort;
public ushort ClientLocalPort;
public string LocalTargetIP;
public ushort LocalTargetPort;
public ushort RemoteLocalPort;
}
public static class Config
{
public static Dictionary<byte, TunnelClientData> cfgs = new Dictionary<byte, TunnelClientData>();

View File

@ -49,7 +49,7 @@ namespace ServerCore.Manager
_Protobuf_Cfgs.Cfgs.Clear();
foreach (var cfg in Config.cfgs)
{
_Protobuf_Cfgs.Cfgs.Add(new Protobuf_Cfgs_Single() { Port = cfg.Value.ClientLocalPort, TunnelID = cfg.Value.TunnelId });
_Protobuf_Cfgs.Cfgs.Add(new Protobuf_Cfgs_Single() { Port = cfg.Value.RemoteLocalPort, TunnelID = cfg.Value.TunnelId });
}
AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdClientCfgs, ProtoBufHelper.Serizlize(_Protobuf_Cfgs));
}
@ -101,7 +101,7 @@ namespace ServerCore.Manager
BackwardLocalClient serverLocalClient = new BackwardLocalClient(AppNoSugarNet.user.userdata.UID, tunnelId, (byte)Idx);
serverLocalClient.BandEvent(AppNoSugarNet.log.Log, OnClientLocalConnect, OnClientLocalDisconnect, OnClientLocalDataCallBack);
//连接成功
if (!serverLocalClient.Init(tunnelDataCfg.ServerLocalTargetIP, tunnelDataCfg.ServerLocalTargetPort))
if (!serverLocalClient.Init(tunnelDataCfg.LocalTargetIP, tunnelDataCfg.LocalTargetPort))
{
//TODO告知客户端连接失败

View File

@ -23,9 +23,9 @@ namespace NoSugarNet.ClientCli
dictTunnel[(byte)i] = new TunnelClientData()
{
TunnelId = (byte)i,
ServerLocalTargetIP = cfgSingle.LocalTargetIP,
ServerLocalTargetPort = (ushort)cfgSingle.LocalTargetPort,
ClientLocalPort = (ushort)cfgSingle.ClientLocalPort,
LocalTargetIP = cfgSingle.LocalTargetIP,
LocalTargetPort = (ushort)cfgSingle.LocalTargetPort,
RemoteLocalPort = (ushort)cfgSingle.RemoteLocalPort,
};
}