diff --git a/NoSugarNet.ClientCore/AppNoSugarNet.cs b/NoSugarNet.ClientCore/AppNoSugarNet.cs index 3b4e4b1..1fd678d 100644 --- a/NoSugarNet.ClientCore/AppNoSugarNet.cs +++ b/NoSugarNet.ClientCore/AppNoSugarNet.cs @@ -1,4 +1,6 @@ -using NoSugarNet.ClientCore.Manager; +using NoSugarNet.Adapter.DataHelper; +using NoSugarNet.ClientCore.Common; +using NoSugarNet.ClientCore.Manager; using NoSugarNet.ClientCore.Network; using ServerCore.Manager; using static NoSugarNet.ClientCore.Manager.LogManager; @@ -16,6 +18,7 @@ namespace NoSugarNet.ClientCore public static AppLogin login; public static AppChat chat; public static AppForwardLocalClient forwardlocal; + public static AppReverseLocalClient reverselocal; public static UserDataManager user; public static System.Timers.Timer _SpeedCheckTimeTimer;//速度检测计时器 public static int TimerInterval = 1000;//计时器间隔 @@ -26,8 +29,11 @@ namespace NoSugarNet.ClientCore public static event OnUpdateStatusHandler OnUpdateStatus; #endregion - public static void Init(OnLogHandler onLog = null) + public static void Init(Dictionary cfgs, int compressAdapterType = 0,OnLogHandler onLog = null) { + Config.cfgs = cfgs; + Config.compressAdapterType = (E_CompressAdapter)compressAdapterType; + log = new LogManager(); if(onLog != null) LogManager.OnLog += onLog; @@ -35,6 +41,7 @@ namespace NoSugarNet.ClientCore login = new AppLogin(); chat = new AppChat(); forwardlocal = new AppForwardLocalClient(); + reverselocal = new AppReverseLocalClient(Config.compressAdapterType); user = new UserDataManager(); netStatus = new NetStatus(); _SpeedCheckTimeTimer = new System.Timers.Timer(); diff --git a/NoSugarNet.ClientCore/Common/Config.cs b/NoSugarNet.ClientCore/Common/Config.cs new file mode 100644 index 0000000..5a13f72 --- /dev/null +++ b/NoSugarNet.ClientCore/Common/Config.cs @@ -0,0 +1,18 @@ +using NoSugarNet.Adapter.DataHelper; + +namespace NoSugarNet.ClientCore.Common +{ + public struct TunnelClientData + { + public byte TunnelId; + public string ServerLocalTargetIP; + public ushort ServerLocalTargetPort; + public ushort ClientLocalPort; + } + + public static class Config + { + public static Dictionary cfgs = new Dictionary(); + public static E_CompressAdapter compressAdapterType; + } +} diff --git a/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs b/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs index 770cf8b..2e724ff 100644 --- a/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs +++ b/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs @@ -25,7 +25,7 @@ namespace ServerCore.Manager public AppForwardLocalClient() { //注册网络消息 - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdCfgs, Recive_CmdCfgs); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdServerCfgs, Recive_CmdCfgs); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardConnect, Recive_TunnelS2CConnect); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardDisconnect, Recive_TunnelS2CDisconnect); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardData, Recive_TunnelS2CData); diff --git a/NoSugarNet.ClientCore/Manager/AppLogin.cs b/NoSugarNet.ClientCore/Manager/AppLogin.cs index 20f3768..464ee2f 100644 --- a/NoSugarNet.ClientCore/Manager/AppLogin.cs +++ b/NoSugarNet.ClientCore/Manager/AppLogin.cs @@ -33,13 +33,13 @@ namespace NoSugarNet.ClientCore.Manager if (msg.Status == LoginResultStatus.Ok) { AppNoSugarNet.log.Info("登录成功"); - AppNoSugarNet.user.InitMainUserData(AppNoSugarNet.user.userdata.Account); + AppNoSugarNet.user.InitMainUserData(AppNoSugarNet.user.userdata.Account,msg.UID); + AppNoSugarNet.reverselocal.Send_ClientCfg(); } else { AppNoSugarNet.log.Info("登录失败"); } } - } } diff --git a/NoSugarNet.ClientCore/Manager/AppReverseLocalClient.cs b/NoSugarNet.ClientCore/Manager/AppReverseLocalClient.cs new file mode 100644 index 0000000..ae3bd4a --- /dev/null +++ b/NoSugarNet.ClientCore/Manager/AppReverseLocalClient.cs @@ -0,0 +1,358 @@ +using AxibugProtobuf; +using Google.Protobuf; +using NoSugarNet.Adapter; +using NoSugarNet.Adapter.DataHelper; +using NoSugarNet.ClientCore; +using NoSugarNet.ClientCore.Common; +using NoSugarNet.ClientCore.Network; + +namespace ServerCore.Manager +{ + public class AppReverseLocalClient + { + Dictionary mDictCommKey2LocalClients = new Dictionary(); + NoSugarNet.Adapter.DataHelper.CompressAdapter mCompressAdapter; + //public LocalMsgQueuePool _localMsgPool = new LocalMsgQueuePool(1000); + + public long tReciveAllLenght { get; private set; } + public long tSendAllLenght { get; private set; } + + static long GetCommKey(long Uid, int Tunnel, int Idx) + { + return (Uid * 10000000) + (Tunnel * 10000) + Idx; + } + + static long GetUidForCommKey(long CommKey) + { + return CommKey / 10000000; + } + + public AppReverseLocalClient(NoSugarNet.Adapter.DataHelper.E_CompressAdapter compressAdapterType) + { + AppNoSugarNet.log.Debug("初始化压缩适配器" + compressAdapterType); + //初始化压缩适配器,暂时使用0,代表压缩类型 + mCompressAdapter = new CompressAdapter(compressAdapterType); + + //注册网络消息 + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CReverseConnect, Recive_TunnelS2CConnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CReverseDisconnect, Recive_TunnelS2CDisconnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CReverseData, Recive_TunnelS2CData); + } + + Protobuf_Cfgs _Protobuf_Cfgs = new Protobuf_Cfgs(); + + public void Send_ClientCfg() + { + AppNoSugarNet.log.Debug("-->Send_ClientCfg"); + + _Protobuf_Cfgs.CompressAdapterType = (int)Config.compressAdapterType; + _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 }); + } + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdClientCfgs, ProtoBufHelper.Serizlize(_Protobuf_Cfgs)); + } + + + #region 解析服务端下行数据 + public void Recive_TunnelS2CConnect(byte[] reqData) + { + AppNoSugarNet.log.Debug("Recive_TunnelS2CConnect"); + Protobuf_S2C_Connect msg = ProtoBufHelper.DeSerizlize(reqData); + if (msg.Connected == 1) + OnServerLocalConnect((byte)msg.TunnelID, (byte)msg.Idx); + else + OnServerLocalDisconnect((byte)msg.TunnelID, (byte)msg.Idx); + } + public void Recive_TunnelS2CDisconnect(byte[] reqData) + { + AppNoSugarNet.log.Debug("Recive_TunnelS2CDisconnect"); + Protobuf_S2C_Disconnect msg = ProtoBufHelper.DeSerizlize(reqData); + OnServerLocalDisconnect((byte)msg.TunnelID, (byte)msg.Idx); + } + public void Recive_TunnelS2CData(byte[] reqData) + { + //AppNoSugarNet.log.Debug("Recive_TunnelS2CData"); + Protobuf_S2C_DATA msg = ProtoBufHelper.DeSerizlize(reqData); + OnServerTunnelDataCallBack(AppNoSugarNet.user.userdata.UID, (byte)msg.TunnelID, (byte)msg.Idx, msg.HunterNetCoreData.ToArray()); + } + #endregion + + + #region 两端本地端口连接事件通知 + + /// + /// 当服务端本地端口连接 + /// + /// + public void OnServerLocalConnect(byte tunnelId, byte Idx) + { + AppNoSugarNet.log.Debug($"OnClientLocalConnect!!!!!! {AppNoSugarNet.user.userdata.UID},{tunnelId},{Idx}"); + + if (!Config.cfgs.ContainsKey(tunnelId)) + return; + + //开一个线程去建立连接 + Thread thread = new Thread(() => + { + //服务器本地局域网连接指定端口 + TunnelClientData tunnelDataCfg = Config.cfgs[tunnelId]; + 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)) + { + //TODO告知客户端连接失败 + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_S2C_Connect() + { + TunnelID = tunnelId, + Idx = (uint)Idx, + Connected = 0//失败 + }); + //发送给客户端,指定服务端本地端口已连接 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelS2CForwardConnect, respData); + } + }); + thread.Start(); + } + /// + /// 当服务端本地端口连接断开 + /// + /// + /// + public void OnServerLocalDisconnect(byte tunnelId, byte Idx) + { + AppNoSugarNet.log.Debug($"OnServerLocalDisconnect,收到客户端断开链接!!!!!! {AppNoSugarNet.user.userdata.UID},{tunnelId},{Idx}"); + + //隧道ID定位投递服务端本地连接 + if (!GetClientLocalClient(AppNoSugarNet.user.userdata.UID, tunnelId, Idx, out BackwardLocalClient LocalClient)) + return; + + //断开服务端本地客户端连接 + CloseClientLocalClient(AppNoSugarNet.user.userdata.UID, tunnelId, Idx); + } + + + /// + /// 当服务端本地端口连接 + /// + /// + /// + public void OnClientLocalConnect(long uid, byte tunnelId, byte Idx, BackwardLocalClient serverLocalClient) + { + AppNoSugarNet.log.Debug($"OnServerLocalConnect {uid},{tunnelId},{Idx}"); + + //添加到服务端本地连接列表 + AddClientLocalClient(uid, tunnelId, Idx, serverLocalClient); + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_S2C_Connect() + { + TunnelID = tunnelId, + Idx = Idx, + Connected = 1 + }); + //发送给客户端,指定服务端本地端口已连接 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelS2CForwardConnect, respData); + } + /// + /// 当服务端本地端口连接断开 + /// + /// + /// + public void OnClientLocalDisconnect(long uid, byte tunnelId, byte Idx, BackwardLocalClient serverLocalClient) + { + AppNoSugarNet.log.Debug($"OnServerLocalDisconnect {uid},{tunnelId},{Idx}"); + //移除到服务端本地连接列表 + RemoveClientLocalClient(uid, tunnelId, Idx); + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_S2C_Disconnect() + { + TunnelID = tunnelId, + Idx = Idx, + }); + //发送给客户端,指定服务端本地端口连接已断开 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelS2CForwardDisconnect, respData); + } + #endregion + + #region 连接字典管理 + /// + /// 追加连接 + /// + /// + /// + /// + void AddClientLocalClient(long uid, byte tunnelId, byte Idx, BackwardLocalClient serverClient) + { + long CommKey = GetCommKey(uid, tunnelId, Idx); + lock (mDictCommKey2LocalClients) + { + mDictCommKey2LocalClients[CommKey] = serverClient; + } + } + /// + /// 删除连接 + /// + /// + /// + void RemoveClientLocalClient(long uid, byte tunnelId, byte Idx) + { + lock (mDictCommKey2LocalClients) + { + long CommKey = GetCommKey(uid, tunnelId, Idx); + + if (!mDictCommKey2LocalClients.ContainsKey(CommKey)) + return; + mDictCommKey2LocalClients[CommKey].Release(); + mDictCommKey2LocalClients.Remove(CommKey); + } + } + + bool GetClientLocalClient(long uid, byte tunnelId, byte Idx, out BackwardLocalClient serverLocalClient) + { + serverLocalClient = null; + + long CommKey = GetCommKey(uid, tunnelId, Idx); + + if (!mDictCommKey2LocalClients.ContainsKey(CommKey)) + return false; + + serverLocalClient = mDictCommKey2LocalClients[CommKey]; + return true; + } + + void CloseClientLocalClient(long uid, byte tunnelId, byte Idx) + { + //隧道ID定位投递服务端本地连接 + if (!GetClientLocalClient(uid, tunnelId, Idx, out BackwardLocalClient _LocalClient)) + return; + _LocalClient.CloseConntect(); + RemoveClientLocalClient(uid, tunnelId, Idx); + } + + public void GetClientCount(out int ClientUserCount, out int TunnelCount) + { + TunnelCount = mDictCommKey2LocalClients.Count; + long[] CommIDKeys = mDictCommKey2LocalClients.Keys.ToArray(); + List TempHadLocalConnetList = new List(); + for (int i = 0; i < CommIDKeys.Length; i++) + { + long uid = GetUidForCommKey(CommIDKeys[i]); + if (!TempHadLocalConnetList.Contains(uid)) + TempHadLocalConnetList.Add(uid); + } + ClientUserCount = TempHadLocalConnetList.Count; + } + + public void StopAll(long Uid) + { + List TempRemoveCommIDList = new List(); + lock (mDictCommKey2LocalClients) + { + long[] CommIDKeys = mDictCommKey2LocalClients.Keys.ToArray(); + for (int i = 0; i < CommIDKeys.Length; i++) + { + long CommID = CommIDKeys[i]; + long tempUid = GetUidForCommKey(CommID); + if (tempUid == Uid) + TempRemoveCommIDList.Add(CommID); + } + } + + for (int i = 0; i < TempRemoveCommIDList.Count; i++) + { + long CommID = TempRemoveCommIDList[i]; + if (!mDictCommKey2LocalClients.ContainsKey(CommID)) + continue; + BackwardLocalClient _serverLoackClient = mDictCommKey2LocalClients[CommID]; + _serverLoackClient.CloseConntect(); + } + } + #endregion + + + #region 数据投递 + /// + /// 来自客户端本地连接投递的Tunnel数据 + /// + /// + /// + /// + public void OnServerTunnelDataCallBack(long uid, byte tunnelId, byte Idx, byte[] data) + { + //ServerManager.g_Log.Debug($"OnClientTunnelDataCallBack {uid},{tunnelId},{Idx}"); + //隧道ID定位投递服务端本地连接 + if (!GetClientLocalClient(uid, tunnelId, Idx, out BackwardLocalClient serverLocalClient)) + return; + //记录数据长度 + tReciveAllLenght += data.Length; + //解压 + data = mCompressAdapter.Decompress(data); + //记录数据长度 + serverLocalClient.mSendAllLenght += data.LongLength; + //发送给对应服务端本地连接数据 + serverLocalClient.SendToServer(data); + } + /// + /// 来自服务端本地连接投递的Tunnel数据 + /// + /// + /// + /// + public void OnClientLocalDataCallBack(long uid, byte tunnelId, byte Idx, byte[] data) + { + //ServerManager.g_Log.Debug($"OnServerLocalDataCallBack {uid},{tunnelId},{Idx}"); + //if (!ServerManager.g_ClientMgr.GetClientByUID(uid, out ClientInfo client)) + // return; + + int SlienLenght = 1000; + //判断数据量大时分包 + if (data.Length > SlienLenght) + { + Span tempSpan = data; + Span tempSpanSlien = null; + int PageCount = (int)(data.Length / SlienLenght); + if (data.Length % SlienLenght > 0) + { + PageCount++; + } + + for (int i = 0; i < PageCount; i++) + { + int StartIdx = i * SlienLenght; + if (i != PageCount - 1)//不是最后一个包 + tempSpanSlien = tempSpan.Slice(StartIdx, SlienLenght); + else//最后一个 + tempSpanSlien = tempSpan.Slice(StartIdx); + + SendDataToRemote(uid, tunnelId, Idx, tempSpanSlien.ToArray()); + } + return; + } + SendDataToRemote(uid, tunnelId, Idx, data); + } + void SendDataToRemote(long uid, byte tunnelId, byte Idx, byte[] data) + { + //if (!ServerManager.g_ClientMgr.GetClientByUID(uid, out ClientInfo client)) + // return; + + //压缩 + data = mCompressAdapter.Compress(data); + //记录压缩后数据长度 + tSendAllLenght += data.Length; + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_S2C_DATA() + { + TunnelID = tunnelId, + Idx = Idx, + HunterNetCoreData = ByteString.CopyFrom(data) + }); + + //发送给客户端,指定客户端本地隧道ID + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelS2CForwardData, respData); + } + #endregion + } +} \ No newline at end of file diff --git a/NoSugarNet.ClientCore/Manager/UserDataManager.cs b/NoSugarNet.ClientCore/Manager/UserDataManager.cs index 050452a..795136c 100644 --- a/NoSugarNet.ClientCore/Manager/UserDataManager.cs +++ b/NoSugarNet.ClientCore/Manager/UserDataManager.cs @@ -23,10 +23,11 @@ namespace NoSugarNet.ClientCore.Manager public MainUserDataBase userdata { get;private set; } = new MainUserDataBase(); public bool IsLoggedIn => userdata.IsLoggedIn; - public void InitMainUserData(string UName) + public void InitMainUserData(string UName,long UID) { userdata.Account = UName; userdata.IsLoggedIn = true; + userdata.UID = UID; //以及其他数据初始化 //... } diff --git a/NoSugarNet.ClientCore/Network/NetworkHelper.cs b/NoSugarNet.ClientCore/Network/NetworkHelper.cs index 618649b..5271013 100644 --- a/NoSugarNet.ClientCore/Network/NetworkHelper.cs +++ b/NoSugarNet.ClientCore/Network/NetworkHelper.cs @@ -101,6 +101,7 @@ namespace NoSugarNet.ClientCore.Network //停止所有 AppNoSugarNet.forwardlocal.StopAll(); + AppNoSugarNet.reverselocal.StopAll(AppNoSugarNet.user.userdata.UID); //自动重连开关 if (bAutoReConnect) diff --git a/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs b/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs index 4eb46f0..2dbc0df 100644 --- a/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs +++ b/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs @@ -28,47 +28,48 @@ namespace AxibugProtobuf { "UHJvdG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJv", "dG9idWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUYAiABKA4yGi5BeGlidWdQ", "cm90b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dv", - "cmQYBCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEo", - "CRIVCg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoG", - "U3RhdHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0", - "dXMiYAoNUHJvdG9idWZfQ2ZncxIbChNDb21wcmVzc0FkYXB0ZXJUeXBlGAEg", - "ASgFEjIKBGNmZ3MYAiADKAsyJC5BeGlidWdQcm90b2J1Zi5Qcm90b2J1Zl9D", - "ZmdzX1NpbmdsZSI2ChRQcm90b2J1Zl9DZmdzX1NpbmdsZRIQCghUdW5uZWxJ", - "RBgBIAEoDRIMCgRQb3J0GAIgASgFIiMKEFByb3RvYnVmX0NoYXRNc2cSDwoH", - "Q2hhdE1zZxgBIAEoCSJIChVQcm90b2J1Zl9DaGF0TXNnX1JFU1ASEAoITmlj", - "a05hbWUYASABKAkSDwoHQ2hhdE1zZxgCIAEoCRIMCgREYXRlGAMgASgDIjUK", - "FFByb3RvYnVmX0MyU19Db25uZWN0EhAKCFR1bm5lbElEGAEgASgNEgsKA0lk", - "eBgCIAEoDSJIChRQcm90b2J1Zl9TMkNfQ29ubmVjdBIQCghUdW5uZWxJR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jScSIwoeQ01EX1RVTk5FTF9DMlNf", + "UkVWRVJTRV9DT05ORUNUEPAuEiMKHkNNRF9UVU5ORUxfUzJDX1JFVkVSU0Vf", + "Q09OTkVDVBDxLhImCiFDTURfVFVOTkVMX0MyU19SRVZFUlNFX0RJU0NPTk5F", + "Q1QQ8i4SJgohQ01EX1RVTk5FTF9TMkNfUkVWRVJTRV9ESVNDT05ORUNUEPMu", + "EiAKG0NNRF9UVU5ORUxfQzJTX1JFVkVSU0VfREFUQRD0LhIgChtDTURfVFVO", + "TkVMX1MyQ19SRVZFUlNFX0RBVEEQ9S4qKwoJRXJyb3JDb2RlEhAKDEVSUk9S", + "X0RFRkFVTBAAEgwKCEVSUk9SX09LEAEqPgoJTG9naW5UeXBlEg8KC0Jhc2VE", + "ZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JGMxADEgcKA0JGNBAEKksK", + "CkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZhdWx0EAASBgoCUEMQARIL", + "CgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQqTgoRTG9naW5SZXN1bHRT", + "dGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFzZURlZmF1bHQQABIGCgJP", + "SxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status", "UID" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "CompressAdapterType", "Cfgs" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs_Single), global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser, new[]{ "TunnelID", "Port" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), @@ -97,7 +98,11 @@ namespace AxibugProtobuf { /// ///配置信息 下行 对应 Protobuf_Cfgs /// - [pbr::OriginalName("CMD_CFGS")] CmdCfgs = 3001, + [pbr::OriginalName("CMD_SERVER_CFGS")] CmdServerCfgs = 3001, + /// + ///配置信息 上行 对应 Protobuf_Cfgs + /// + [pbr::OriginalName("CMD_CLIENT_CFGS")] CmdClientCfgs = 3002, /// ///广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP /// @@ -527,6 +532,7 @@ namespace AxibugProtobuf { lastLoginDate_ = other.lastLoginDate_; regDate_ = other.regDate_; status_ = other.status_; + uID_ = other.uID_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -591,6 +597,17 @@ namespace AxibugProtobuf { } } + /// Field number for the "UID" field. + public const int UIDFieldNumber = 5; + private long uID_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long UID { + get { return uID_; } + set { + uID_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Protobuf_Login_RESP); @@ -608,6 +625,7 @@ namespace AxibugProtobuf { if (LastLoginDate != other.LastLoginDate) return false; if (RegDate != other.RegDate) return false; if (Status != other.Status) return false; + if (UID != other.UID) return false; return Equals(_unknownFields, other._unknownFields); } @@ -618,6 +636,7 @@ namespace AxibugProtobuf { if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode(); if (RegDate.Length != 0) hash ^= RegDate.GetHashCode(); if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode(); + if (UID != 0L) hash ^= UID.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -650,6 +669,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -675,6 +698,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -696,6 +723,9 @@ namespace AxibugProtobuf { if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); } + if (UID != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(UID); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -719,6 +749,9 @@ namespace AxibugProtobuf { if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { Status = other.Status; } + if (other.UID != 0L) { + UID = other.UID; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -749,6 +782,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } #endif @@ -779,6 +816,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } } diff --git a/NoSugarNet.ServerCore/Manager/LoginManager.cs b/NoSugarNet.ServerCore/Manager/LoginManager.cs index 569e581..afa7fc8 100644 --- a/NoSugarNet.ServerCore/Manager/LoginManager.cs +++ b/NoSugarNet.ServerCore/Manager/LoginManager.cs @@ -24,7 +24,8 @@ namespace ServerCore.Manager Status = LoginResultStatus.Ok, RegDate = "", LastLoginDate = "", - Token = "" + Token = "", + UID = cinfo.UID }); ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdLogin, (int)ErrorCode.ErrorOk, respData); @@ -39,7 +40,7 @@ namespace ServerCore.Manager cfgsSP.CompressAdapterType = (int)Config.compressAdapterType; byte[] respDataCfg = ProtoBufHelper.Serizlize(cfgsSP); - ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdCfgs, (int)ErrorCode.ErrorOk, respDataCfg); + ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdServerCfgs, (int)ErrorCode.ErrorOk, respDataCfg); } } } \ No newline at end of file diff --git a/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs b/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs index 4eb46f0..2dbc0df 100644 --- a/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs +++ b/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs @@ -28,47 +28,48 @@ namespace AxibugProtobuf { "UHJvdG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJv", "dG9idWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUYAiABKA4yGi5BeGlidWdQ", "cm90b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dv", - "cmQYBCABKAkifwoTU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G9naW5UeXBlEg8KC0Jhc2VE", + "ZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JGMxADEgcKA0JGNBAEKksK", + "CkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZhdWx0EAASBgoCUEMQARIL", + "CgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQqTgoRTG9naW5SZXN1bHRT", + "dGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFzZURlZmF1bHQQABIGCgJP", + "SxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status", "UID" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "CompressAdapterType", "Cfgs" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs_Single), global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser, new[]{ "TunnelID", "Port" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), @@ -97,7 +98,11 @@ namespace AxibugProtobuf { /// ///配置信息 下行 对应 Protobuf_Cfgs /// - [pbr::OriginalName("CMD_CFGS")] CmdCfgs = 3001, + [pbr::OriginalName("CMD_SERVER_CFGS")] CmdServerCfgs = 3001, + /// + ///配置信息 上行 对应 Protobuf_Cfgs + /// + [pbr::OriginalName("CMD_CLIENT_CFGS")] CmdClientCfgs = 3002, /// ///广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP /// @@ -527,6 +532,7 @@ namespace AxibugProtobuf { lastLoginDate_ = other.lastLoginDate_; regDate_ = other.regDate_; status_ = other.status_; + uID_ = other.uID_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -591,6 +597,17 @@ namespace AxibugProtobuf { } } + /// Field number for the "UID" field. + public const int UIDFieldNumber = 5; + private long uID_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long UID { + get { return uID_; } + set { + uID_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Protobuf_Login_RESP); @@ -608,6 +625,7 @@ namespace AxibugProtobuf { if (LastLoginDate != other.LastLoginDate) return false; if (RegDate != other.RegDate) return false; if (Status != other.Status) return false; + if (UID != other.UID) return false; return Equals(_unknownFields, other._unknownFields); } @@ -618,6 +636,7 @@ namespace AxibugProtobuf { if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode(); if (RegDate.Length != 0) hash ^= RegDate.GetHashCode(); if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode(); + if (UID != 0L) hash ^= UID.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -650,6 +669,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -675,6 +698,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -696,6 +723,9 @@ namespace AxibugProtobuf { if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); } + if (UID != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(UID); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -719,6 +749,9 @@ namespace AxibugProtobuf { if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { Status = other.Status; } + if (other.UID != 0L) { + UID = other.UID; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -749,6 +782,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } #endif @@ -779,6 +816,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } } diff --git a/ProtobufCore/out/CS/ProtobufNoSugar.cs b/ProtobufCore/out/CS/ProtobufNoSugar.cs index 4eb46f0..2dbc0df 100644 --- a/ProtobufCore/out/CS/ProtobufNoSugar.cs +++ b/ProtobufCore/out/CS/ProtobufNoSugar.cs @@ -28,47 +28,48 @@ namespace AxibugProtobuf { "UHJvdG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJv", "dG9idWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUY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X1MyQ19SRVZFUlNFX0RBVEEQ9S4qKwoJRXJyb3JDb2RlEhAKDEVSUk9S", + "X0RFRkFVTBAAEgwKCEVSUk9SX09LEAEqPgoJTG9naW5UeXBlEg8KC0Jhc2VE", + "ZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JGMxADEgcKA0JGNBAEKksK", + "CkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZhdWx0EAASBgoCUEMQARIL", + "CgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQqTgoRTG9naW5SZXN1bHRT", + "dGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFzZURlZmF1bHQQABIGCgJP", + "SxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status", "UID" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "CompressAdapterType", "Cfgs" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs_Single), global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser, new[]{ "TunnelID", "Port" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), @@ -97,7 +98,11 @@ namespace AxibugProtobuf { /// ///配置信息 下行 对应 Protobuf_Cfgs /// - [pbr::OriginalName("CMD_CFGS")] CmdCfgs = 3001, + [pbr::OriginalName("CMD_SERVER_CFGS")] CmdServerCfgs = 3001, + /// + ///配置信息 上行 对应 Protobuf_Cfgs + /// + [pbr::OriginalName("CMD_CLIENT_CFGS")] CmdClientCfgs = 3002, /// ///广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP /// @@ -527,6 +532,7 @@ namespace AxibugProtobuf { lastLoginDate_ = other.lastLoginDate_; regDate_ = other.regDate_; status_ = other.status_; + uID_ = other.uID_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -591,6 +597,17 @@ namespace AxibugProtobuf { } } + /// Field number for the "UID" field. + public const int UIDFieldNumber = 5; + private long uID_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long UID { + get { return uID_; } + set { + uID_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Protobuf_Login_RESP); @@ -608,6 +625,7 @@ namespace AxibugProtobuf { if (LastLoginDate != other.LastLoginDate) return false; if (RegDate != other.RegDate) return false; if (Status != other.Status) return false; + if (UID != other.UID) return false; return Equals(_unknownFields, other._unknownFields); } @@ -618,6 +636,7 @@ namespace AxibugProtobuf { if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode(); if (RegDate.Length != 0) hash ^= RegDate.GetHashCode(); if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode(); + if (UID != 0L) hash ^= UID.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -650,6 +669,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -675,6 +698,10 @@ namespace AxibugProtobuf { output.WriteRawTag(32); output.WriteEnum((int) Status); } + if (UID != 0L) { + output.WriteRawTag(40); + output.WriteInt64(UID); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -696,6 +723,9 @@ namespace AxibugProtobuf { if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); } + if (UID != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(UID); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -719,6 +749,9 @@ namespace AxibugProtobuf { if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { Status = other.Status; } + if (other.UID != 0L) { + UID = other.UID; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -749,6 +782,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } #endif @@ -779,6 +816,10 @@ namespace AxibugProtobuf { Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); break; } + case 40: { + UID = input.ReadInt64(); + break; + } } } } diff --git a/ProtobufCore/proto/protobuf_NoSugar.proto b/ProtobufCore/proto/protobuf_NoSugar.proto index ffea597..9d60d85 100644 --- a/ProtobufCore/proto/protobuf_NoSugar.proto +++ b/ProtobufCore/proto/protobuf_NoSugar.proto @@ -9,7 +9,8 @@ enum CommandID CMD_LOGIN = 2001; //自动登录上行 | 下行 对应 Protobuf_Login | Protobuf_Login_RESP - CMD_CFGS = 3001; //配置信息 下行 对应 Protobuf_Cfgs + CMD_SERVER_CFGS = 3001; //配置信息 下行 对应 Protobuf_Cfgs + CMD_CLIENT_CFGS = 3002; //配置信息 上行 对应 Protobuf_Cfgs CMD_CHATMSG = 4001; //广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP @@ -74,6 +75,7 @@ message Protobuf_Login_RESP string LastLoginDate = 2;//上次登录时间(只用于呈现的字符串,若界面需求需要) string RegDate = 3;//注册时间(只用于呈现的字符串,若界面需求需要) LoginResultStatus Status = 4;//账号状态 (预留) [1]正常[0]被禁封 + int64 UID = 5; } //配置下行 diff --git a/Sample/NoSugarNet.ClientCli/Config.cs b/Sample/NoSugarNet.ClientCli/Config.cs index cf2535b..9442e62 100644 --- a/Sample/NoSugarNet.ClientCli/Config.cs +++ b/Sample/NoSugarNet.ClientCli/Config.cs @@ -1,33 +1,64 @@ using System.Text; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Unicode; namespace NoSugarNet.ClientCli { + + public class ConfigDataModel + { + public string ServerIP { get; set; } + public int ServerPort { get; set; } + public int CompressAdapterType { get; set; } + public List TunnelList { get; set; } + } + + public class ConfigDataModel_Single + { + public string LocalTargetIP { get; set; } + public int LocalTargetPort { get; set; } + public int ClientLocalPort { get; set; } + } + public static class Config { - public static string ServerIP; - public static int ServerPort; + public static ConfigDataModel cfg; public static bool LoadConfig() { try { - StreamReader sr = new StreamReader(System.Environment.CurrentDirectory + "//config.cfg", Encoding.Default); - String line; - while (!string.IsNullOrEmpty((line = sr.ReadLine()))) + string path = System.Environment.CurrentDirectory + "//config.cfg"; + if (!File.Exists(path)) { - if (!line.Contains(":")) - continue; - try + ConfigDataModel sampleCfg = new ConfigDataModel { - ServerIP = line.Split(':')[0].Trim(); - ServerPort = Convert.ToInt32(line.Split(':')[1].Trim()); - } - catch + ServerIP = "127.0.0.1", + ServerPort = 1000, + TunnelList = new List() + { + new ConfigDataModel_Single(){ LocalTargetIP = "127.0.0.1",LocalTargetPort=3389,ClientLocalPort = 20001}, + new ConfigDataModel_Single(){ LocalTargetIP = "127.0.0.1",LocalTargetPort=3389,ClientLocalPort = 20002} + } + }; + + string jsonString = JsonSerializer.Serialize(sampleCfg, new JsonSerializerOptions() { - continue; - } + // 整齐打印 + WriteIndented = true, + //重新编码,解决中文乱码问题 + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) + }); + System.IO.File.WriteAllText(path, jsonString, Encoding.UTF8); + + Console.WriteLine("未找到配置,已生成模板,请浏览" + path); + return false; } + StreamReader sr = new StreamReader(path, Encoding.Default); + String jsonstr = sr.ReadToEnd(); + cfg = JsonSerializer.Deserialize(jsonstr); sr.Close(); - if (!string.IsNullOrEmpty(ServerIP)) + if (cfg?.TunnelList.Count > 0) return true; else return false; diff --git a/Sample/NoSugarNet.ClientCli/Program.cs b/Sample/NoSugarNet.ClientCli/Program.cs index 90c8960..55df209 100644 --- a/Sample/NoSugarNet.ClientCli/Program.cs +++ b/Sample/NoSugarNet.ClientCli/Program.cs @@ -1,4 +1,5 @@ using NoSugarNet.ClientCore; +using NoSugarNet.ClientCore.Common; namespace NoSugarNet.ClientCli { @@ -14,8 +15,22 @@ namespace NoSugarNet.ClientCli return; } AppNoSugarNet.OnUpdateStatus += OnUpdateStatus; - AppNoSugarNet.Init(OnNoSugarNetLog); - AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort); + + Dictionary dictTunnel = new Dictionary(); + for (int i = 0; i < Config.cfg.TunnelList.Count; i++) + { + ConfigDataModel_Single cfgSingle = Config.cfg.TunnelList[i]; + dictTunnel[(byte)i] = new TunnelClientData() + { + TunnelId = (byte)i, + ServerLocalTargetIP = cfgSingle.LocalTargetIP, + ServerLocalTargetPort = (ushort)cfgSingle.LocalTargetPort, + ClientLocalPort = (ushort)cfgSingle.ClientLocalPort, + }; + } + + AppNoSugarNet.Init(dictTunnel, Config.cfg.CompressAdapterType, OnNoSugarNetLog); + AppNoSugarNet.Connect(Config.cfg.ServerIP, Config.cfg.ServerPort); while (true) { string CommandStr = Console.ReadLine(); @@ -25,7 +40,7 @@ namespace NoSugarNet.ClientCli switch (Command) { case "con": - AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort); + AppNoSugarNet.Connect(Config.cfg.ServerIP, Config.cfg.ServerPort); break; case "tlist": AppNoSugarNet.forwardlocal.GetClientCount(out int ClientUserCount, out int TunnelCount);