diff --git a/NoSugarNet.ClientCore/AppNoSugarNet.cs b/NoSugarNet.ClientCore/AppNoSugarNet.cs index 0ea2f24..3b4e4b1 100644 --- a/NoSugarNet.ClientCore/AppNoSugarNet.cs +++ b/NoSugarNet.ClientCore/AppNoSugarNet.cs @@ -15,7 +15,7 @@ namespace NoSugarNet.ClientCore public static NetworkHelper networkHelper; public static AppLogin login; public static AppChat chat; - public static AppLocalClient local; + public static AppForwardLocalClient forwardlocal; public static UserDataManager user; public static System.Timers.Timer _SpeedCheckTimeTimer;//速度检测计时器 public static int TimerInterval = 1000;//计时器间隔 @@ -34,7 +34,7 @@ namespace NoSugarNet.ClientCore networkHelper = new NetworkHelper(); login = new AppLogin(); chat = new AppChat(); - local = new AppLocalClient(); + forwardlocal = new AppForwardLocalClient(); user = new UserDataManager(); netStatus = new NetStatus(); _SpeedCheckTimeTimer = new System.Timers.Timer(); @@ -53,7 +53,7 @@ namespace NoSugarNet.ClientCore public static void Close() { - local.StopAll(); + forwardlocal.StopAll(); networkHelper.CloseConntect(); AppNoSugarNet.log.Info("停止"); _SpeedCheckTimeTimer.Enabled = false; @@ -61,8 +61,8 @@ namespace NoSugarNet.ClientCore static void Checktimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - local.GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght); - local.GetClientCount(out int ClientUserCount, out int TunnelCount); + forwardlocal.GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght); + forwardlocal.GetClientCount(out int ClientUserCount, out int TunnelCount); NetStatus resutnetStatus = new NetStatus() { @@ -72,10 +72,10 @@ namespace NoSugarNet.ClientCore srcReciveAllLenght = resultReciveAllLenght, srcReciveSecSpeed = (resultReciveAllLenght - netStatus.srcReciveAllLenght) / (TimerInterval / 1000), srcSendSecSpeed = (resultSendAllLenght - netStatus.srcSendAllLenght) / (TimerInterval / 1000), - tSendAllLenght = local.tSendAllLenght, - tReciveAllLenght = local.tReciveAllLenght, - tSendSecSpeed = (local.tSendAllLenght - netStatus.tSendAllLenght) / (TimerInterval / 1000), - tReciveSecSpeed = (local.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), + tSendAllLenght = forwardlocal.tSendAllLenght, + tReciveAllLenght = forwardlocal.tReciveAllLenght, + tSendSecSpeed = (forwardlocal.tSendAllLenght - netStatus.tSendAllLenght) / (TimerInterval / 1000), + tReciveSecSpeed = (forwardlocal.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), }; netStatus = resutnetStatus; OnUpdateStatus?.Invoke(resutnetStatus); diff --git a/NoSugarNet.ClientCore/Manager/AppLocalClient.cs b/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs similarity index 97% rename from NoSugarNet.ClientCore/Manager/AppLocalClient.cs rename to NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs index 2434df5..770cf8b 100644 --- a/NoSugarNet.ClientCore/Manager/AppLocalClient.cs +++ b/NoSugarNet.ClientCore/Manager/AppForwardLocalClient.cs @@ -11,7 +11,7 @@ using System.Net; namespace ServerCore.Manager { - public class AppLocalClient + public class AppForwardLocalClient { Dictionary mDictTunnelID2Cfg = new Dictionary(); Dictionary mDictTunnelID2Listeners = new Dictionary(); @@ -22,13 +22,13 @@ namespace ServerCore.Manager public long tReciveAllLenght { get; private set; } public long tSendAllLenght { get; private set; } - public AppLocalClient() + public AppForwardLocalClient() { //注册网络消息 NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdCfgs, Recive_CmdCfgs); - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CConnect, Recive_TunnelS2CConnect); - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CDisconnect, Recive_TunnelS2CDisconnect); - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CData, Recive_TunnelS2CData); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardConnect, Recive_TunnelS2CConnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardDisconnect, Recive_TunnelS2CDisconnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CForwardData, Recive_TunnelS2CData); } public void GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght) @@ -202,7 +202,7 @@ namespace ServerCore.Manager }); //告知给服务端,来自客户端本地的连接建立 - AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SConnect, respData); + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SForwardConnect, respData); } /// /// 当客户端本地端口连接断开 @@ -223,7 +223,7 @@ namespace ServerCore.Manager }); //告知给服务端,来自客户端本地的连接断开 - AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SDisconnect, respData); + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SForwardDisconnect, respData); } /// @@ -243,7 +243,7 @@ namespace ServerCore.Manager { IdxWithMsg msg = msglist[i]; //投递给服务端,来自客户端本地的连接数据 - AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SData, msg.data); + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SForwardData, msg.data); //发送后回收 LocalMsgQueuePool._localMsgPool.Enqueue(msg); } @@ -343,7 +343,7 @@ namespace ServerCore.Manager return; } //投递给服务端,来自客户端本地的连接数据 - AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SData, respData); + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SForwardData, respData); } #endregion diff --git a/NoSugarNet.ClientCore/Network/NetworkHelper.cs b/NoSugarNet.ClientCore/Network/NetworkHelper.cs index df64c5c..618649b 100644 --- a/NoSugarNet.ClientCore/Network/NetworkHelper.cs +++ b/NoSugarNet.ClientCore/Network/NetworkHelper.cs @@ -57,7 +57,7 @@ namespace NoSugarNet.ClientCore.Network NetworkDeBugLog("连接失败!"); //停止所有 - AppNoSugarNet.local.StopAll(); + AppNoSugarNet.forwardlocal.StopAll(); //自动重连开关 if (bAutoReConnect) @@ -100,7 +100,7 @@ namespace NoSugarNet.ClientCore.Network NetworkDeBugLog("OnConnectClose"); //停止所有 - AppNoSugarNet.local.StopAll(); + AppNoSugarNet.forwardlocal.StopAll(); //自动重连开关 if (bAutoReConnect) diff --git a/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs b/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs index dce38be..4eb46f0 100644 --- a/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs +++ b/NoSugarNet.ClientCore/Protobuf/ProtobufNoSugar.cs @@ -45,13 +45,19 @@ namespace AxibugProtobuf { "IAEoDRILCgNJZHgYAiABKA0iTgoRUHJvdG9idWZfQzJTX0RBVEESEAoIVHVu", "bmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhoKEkh1bnRlck5ldENvcmVfRGF0", "YRgDIAEoDCJOChFQcm90b2J1Zl9TMkNfREFUQRIQCghUdW5uZWxJRBgBIAEo", - "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKvoB", + "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKogE", "CglDb21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN", - "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM", - "X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS", - "HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM", - "X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS", - "GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS", + "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIjCh5DTURfVFVOTkVM", + "X0MyU19GT1JXQVJEX0NPTk5FQ1QQiCcSIwoeQ01EX1RVTk5FTF9TMkNfRk9S", + "V0FSRF9DT05ORUNUEIknEiYKIUNNRF9UVU5ORUxfQzJTX0ZPUldBUkRfRElT", + "Q09OTkVDVBCKJxImCiFDTURfVFVOTkVMX1MyQ19GT1JXQVJEX0RJU0NPTk5F", + "Q1QQiycSIAobQ01EX1RVTk5FTF9DMlNfRk9SV0FSRF9EQVRBEIwnEiAKG0NN", + "RF9UVU5ORUxfUzJDX0ZPUldBUkRfREFUQRCNJxIjCh5DTURfVFVOTkVMX0My", + "U19SRVZFUlNFX0NPTk5FQ1QQ8C4SIwoeQ01EX1RVTk5FTF9TMkNfUkVWRVJT", + "RV9DT05ORUNUEPEuEiYKIUNNRF9UVU5ORUxfQzJTX1JFVkVSU0VfRElTQ09O", + "TkVDVBDyLhImCiFDTURfVFVOTkVMX1MyQ19SRVZFUlNFX0RJU0NPTk5FQ1QQ", + "8y4SIAobQ01EX1RVTk5FTF9DMlNfUkVWRVJTRV9EQVRBEPQuEiAKG0NNRF9U", + "VU5ORUxfUzJDX1JFVkVSU0VfREFUQRD1LiorCglFcnJvckNvZGUSEAoMRVJS", "T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz", "ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq", "SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB", @@ -97,29 +103,53 @@ namespace AxibugProtobuf { /// [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, /// - ///客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + ///正向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_CONNECT")] CmdTunnelC2SConnect = 5000, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_CONNECT")] CmdTunnelC2SForwardConnect = 5000, /// - ///服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + ///正向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_CONNECT")] CmdTunnelS2CConnect = 5001, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_CONNECT")] CmdTunnelS2CForwardConnect = 5001, /// - ///客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + ///正向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DISCONNECT")] CmdTunnelC2SDisconnect = 5002, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DISCONNECT")] CmdTunnelC2SForwardDisconnect = 5002, /// - ///服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + ///正向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DISCONNECT")] CmdTunnelS2CDisconnect = 5003, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DISCONNECT")] CmdTunnelS2CForwardDisconnect = 5003, /// - ///客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + ///正向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DATA")] CmdTunnelC2SData = 5004, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DATA")] CmdTunnelC2SForwardData = 5004, /// - ///服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + ///正向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DATA")] CmdTunnelS2CData = 5005, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DATA")] CmdTunnelS2CForwardData = 5005, + /// + ///反向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_CONNECT")] CmdTunnelC2SReverseConnect = 6000, + /// + ///反向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_CONNECT")] CmdTunnelS2CReverseConnect = 6001, + /// + ///反向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DISCONNECT")] CmdTunnelC2SReverseDisconnect = 6002, + /// + ///反向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DISCONNECT")] CmdTunnelS2CReverseDisconnect = 6003, + /// + ///反向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DATA")] CmdTunnelC2SReverseData = 6004, + /// + ///反向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DATA")] CmdTunnelS2CReverseData = 6005, } public enum ErrorCode { diff --git a/NoSugarNet.ServerCore/Manager/ClientManager.cs b/NoSugarNet.ServerCore/Manager/ClientManager.cs index 7ffbd32..548381b 100644 --- a/NoSugarNet.ServerCore/Manager/ClientManager.cs +++ b/NoSugarNet.ServerCore/Manager/ClientManager.cs @@ -174,7 +174,7 @@ namespace ServerCore.Manager cinfo.IsOffline = true; cinfo.LogOutDT = DateTime.Now; //断开所有连接 - ServerManager.g_Local.StopAll(cinfo.UID); + ServerManager.g_ForwardLocal.StopAll(cinfo.UID); } public void RemoveClientForSocket(Socket sk) diff --git a/NoSugarNet.ServerCore/Manager/LocalClientManager.cs b/NoSugarNet.ServerCore/Manager/ForwardLocalClientManager.cs similarity index 96% rename from NoSugarNet.ServerCore/Manager/LocalClientManager.cs rename to NoSugarNet.ServerCore/Manager/ForwardLocalClientManager.cs index 074eba6..1041d8a 100644 --- a/NoSugarNet.ServerCore/Manager/LocalClientManager.cs +++ b/NoSugarNet.ServerCore/Manager/ForwardLocalClientManager.cs @@ -9,7 +9,7 @@ using System.Net.Sockets; namespace ServerCore.Manager { - public class LocalClientManager + public class ForwardLocalClientManager { Dictionary mDictCommKey2ServerLocalClients = new Dictionary(); CompressAdapter mCompressAdapter; @@ -27,15 +27,15 @@ namespace ServerCore.Manager return CommKey / 10000000; } - public LocalClientManager(E_CompressAdapter compressAdapterType) + public ForwardLocalClientManager(E_CompressAdapter compressAdapterType) { ServerManager.g_Log.Debug("初始化压缩适配器" + compressAdapterType); //初始化压缩适配器,暂时使用0,代表压缩类型 mCompressAdapter = new CompressAdapter(compressAdapterType); //注册网络消息 - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SConnect, Recive_TunnelC2SConnect); - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SDisconnect, Recive_TunnelC2SDisconnect); - NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SData, Recive_TunnelC2SData); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SForwardConnect, Recive_TunnelC2SConnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SForwardDisconnect, Recive_TunnelC2SDisconnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SForwardData, Recive_TunnelC2SData); } public void GetCurrLenght(out long resultReciveAllLenght,out long resultSendAllLenght) @@ -204,7 +204,7 @@ namespace ServerCore.Manager Connected = 0//失败 }); //发送给客户端,指定服务端本地端口已连接 - ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CConnect, (int)ErrorCode.ErrorOk, respData); + ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CForwardConnect, (int)ErrorCode.ErrorOk, respData); } }); thread.Start(); @@ -248,7 +248,7 @@ namespace ServerCore.Manager Connected = 1 }); //发送给客户端,指定服务端本地端口已连接 - ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CConnect, (int)ErrorCode.ErrorOk, respData); + ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CForwardConnect, (int)ErrorCode.ErrorOk, respData); } /// /// 当服务端本地端口连接断开 @@ -269,7 +269,7 @@ namespace ServerCore.Manager Idx= Idx, }); //发送给客户端,指定服务端本地端口连接已断开 - ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CDisconnect, (int)ErrorCode.ErrorOk, respData); + ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CForwardDisconnect, (int)ErrorCode.ErrorOk, respData); } #endregion @@ -351,7 +351,7 @@ namespace ServerCore.Manager }); //发送给客户端,指定客户端本地隧道ID - ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CData, (int)ErrorCode.ErrorOk, respData); + ServerManager.g_ClientMgr.ClientSend(client, (int)CommandID.CmdTunnelS2CForwardData, (int)ErrorCode.ErrorOk, respData); } #endregion } diff --git a/NoSugarNet.ServerCore/Manager/ServerManager.cs b/NoSugarNet.ServerCore/Manager/ServerManager.cs index 2f49e39..ad5888f 100644 --- a/NoSugarNet.ServerCore/Manager/ServerManager.cs +++ b/NoSugarNet.ServerCore/Manager/ServerManager.cs @@ -13,7 +13,7 @@ namespace ServerCore.Manager public static LogManager g_Log; public static LoginManager g_Login; public static ChatManager g_Chat; - public static LocalClientManager g_Local; + public static ForwardLocalClientManager g_ForwardLocal; public static IOCPNetWork g_SocketMgr; public static System.Timers.Timer _SpeedCheckTimeTimer;//速度检测计时器 public static int TimerInterval = 1000;//计时器间隔 @@ -34,7 +34,7 @@ namespace ServerCore.Manager g_Log = new LogManager(); g_Login = new LoginManager(); g_Chat = new ChatManager(); - g_Local = new LocalClientManager((E_CompressAdapter)compressAdapterType); + g_ForwardLocal = new ForwardLocalClientManager((E_CompressAdapter)compressAdapterType); //g_SocketMgr = new IOCPNetWork(1024, 1024); g_SocketMgr = new IOCPNetWork(1024, 4096); @@ -53,8 +53,8 @@ namespace ServerCore.Manager static void Checktimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - g_Local.GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght); - g_Local.GetClientCount(out int ClientUserCount, out int TunnelCount); + g_ForwardLocal.GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght); + g_ForwardLocal.GetClientCount(out int ClientUserCount, out int TunnelCount); NetStatus resutnetStatus = new NetStatus() { TunnelCount = TunnelCount, @@ -63,10 +63,10 @@ namespace ServerCore.Manager srcReciveAllLenght = resultReciveAllLenght, srcReciveSecSpeed = (resultReciveAllLenght - netStatus.srcReciveAllLenght) / (TimerInterval / 1000), srcSendSecSpeed = (resultSendAllLenght - netStatus.srcSendAllLenght) / (TimerInterval / 1000), - tSendAllLenght = g_Local.tSendAllLenght, - tReciveAllLenght = g_Local.tReciveAllLenght, - tSendSecSpeed = (g_Local.tSendAllLenght - netStatus.tSendAllLenght) / (TimerInterval / 1000), - tReciveSecSpeed = (g_Local.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), + tSendAllLenght = g_ForwardLocal.tSendAllLenght, + tReciveAllLenght = g_ForwardLocal.tReciveAllLenght, + tSendSecSpeed = (g_ForwardLocal.tSendAllLenght - netStatus.tSendAllLenght) / (TimerInterval / 1000), + tReciveSecSpeed = (g_ForwardLocal.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), }; netStatus = resutnetStatus; OnUpdateStatus?.Invoke(resutnetStatus); diff --git a/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs b/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs index dce38be..4eb46f0 100644 --- a/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs +++ b/NoSugarNet.ServerCore/Protobuf/ProtobufNoSugar.cs @@ -45,13 +45,19 @@ namespace AxibugProtobuf { "IAEoDRILCgNJZHgYAiABKA0iTgoRUHJvdG9idWZfQzJTX0RBVEESEAoIVHVu", "bmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhoKEkh1bnRlck5ldENvcmVfRGF0", "YRgDIAEoDCJOChFQcm90b2J1Zl9TMkNfREFUQRIQCghUdW5uZWxJRBgBIAEo", - "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKvoB", + "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKogE", "CglDb21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN", - "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM", - "X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS", - "HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM", - "X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS", - "GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS", + "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIjCh5DTURfVFVOTkVM", + "X0MyU19GT1JXQVJEX0NPTk5FQ1QQiCcSIwoeQ01EX1RVTk5FTF9TMkNfRk9S", + "V0FSRF9DT05ORUNUEIknEiYKIUNNRF9UVU5ORUxfQzJTX0ZPUldBUkRfRElT", + "Q09OTkVDVBCKJxImCiFDTURfVFVOTkVMX1MyQ19GT1JXQVJEX0RJU0NPTk5F", + "Q1QQiycSIAobQ01EX1RVTk5FTF9DMlNfRk9SV0FSRF9EQVRBEIwnEiAKG0NN", + "RF9UVU5ORUxfUzJDX0ZPUldBUkRfREFUQRCNJxIjCh5DTURfVFVOTkVMX0My", + "U19SRVZFUlNFX0NPTk5FQ1QQ8C4SIwoeQ01EX1RVTk5FTF9TMkNfUkVWRVJT", + "RV9DT05ORUNUEPEuEiYKIUNNRF9UVU5ORUxfQzJTX1JFVkVSU0VfRElTQ09O", + "TkVDVBDyLhImCiFDTURfVFVOTkVMX1MyQ19SRVZFUlNFX0RJU0NPTk5FQ1QQ", + "8y4SIAobQ01EX1RVTk5FTF9DMlNfUkVWRVJTRV9EQVRBEPQuEiAKG0NNRF9U", + "VU5ORUxfUzJDX1JFVkVSU0VfREFUQRD1LiorCglFcnJvckNvZGUSEAoMRVJS", "T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz", "ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq", "SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB", @@ -97,29 +103,53 @@ namespace AxibugProtobuf { /// [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, /// - ///客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + ///正向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_CONNECT")] CmdTunnelC2SConnect = 5000, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_CONNECT")] CmdTunnelC2SForwardConnect = 5000, /// - ///服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + ///正向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_CONNECT")] CmdTunnelS2CConnect = 5001, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_CONNECT")] CmdTunnelS2CForwardConnect = 5001, /// - ///客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + ///正向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DISCONNECT")] CmdTunnelC2SDisconnect = 5002, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DISCONNECT")] CmdTunnelC2SForwardDisconnect = 5002, /// - ///服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + ///正向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DISCONNECT")] CmdTunnelS2CDisconnect = 5003, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DISCONNECT")] CmdTunnelS2CForwardDisconnect = 5003, /// - ///客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + ///正向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DATA")] CmdTunnelC2SData = 5004, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DATA")] CmdTunnelC2SForwardData = 5004, /// - ///服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + ///正向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DATA")] CmdTunnelS2CData = 5005, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DATA")] CmdTunnelS2CForwardData = 5005, + /// + ///反向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_CONNECT")] CmdTunnelC2SReverseConnect = 6000, + /// + ///反向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_CONNECT")] CmdTunnelS2CReverseConnect = 6001, + /// + ///反向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DISCONNECT")] CmdTunnelC2SReverseDisconnect = 6002, + /// + ///反向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DISCONNECT")] CmdTunnelS2CReverseDisconnect = 6003, + /// + ///反向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DATA")] CmdTunnelC2SReverseData = 6004, + /// + ///反向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DATA")] CmdTunnelS2CReverseData = 6005, } public enum ErrorCode { diff --git a/ProtobufCore/out/CS/ProtobufNoSugar.cs b/ProtobufCore/out/CS/ProtobufNoSugar.cs index dce38be..4eb46f0 100644 --- a/ProtobufCore/out/CS/ProtobufNoSugar.cs +++ b/ProtobufCore/out/CS/ProtobufNoSugar.cs @@ -45,13 +45,19 @@ namespace AxibugProtobuf { "IAEoDRILCgNJZHgYAiABKA0iTgoRUHJvdG9idWZfQzJTX0RBVEESEAoIVHVu", "bmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhoKEkh1bnRlck5ldENvcmVfRGF0", "YRgDIAEoDCJOChFQcm90b2J1Zl9TMkNfREFUQRIQCghUdW5uZWxJRBgBIAEo", - "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKvoB", + "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKogE", "CglDb21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN", - "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM", - "X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS", - "HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM", - "X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS", - "GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS", + "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIjCh5DTURfVFVOTkVM", + "X0MyU19GT1JXQVJEX0NPTk5FQ1QQiCcSIwoeQ01EX1RVTk5FTF9TMkNfRk9S", + "V0FSRF9DT05ORUNUEIknEiYKIUNNRF9UVU5ORUxfQzJTX0ZPUldBUkRfRElT", + "Q09OTkVDVBCKJxImCiFDTURfVFVOTkVMX1MyQ19GT1JXQVJEX0RJU0NPTk5F", + "Q1QQiycSIAobQ01EX1RVTk5FTF9DMlNfRk9SV0FSRF9EQVRBEIwnEiAKG0NN", + "RF9UVU5ORUxfUzJDX0ZPUldBUkRfREFUQRCNJxIjCh5DTURfVFVOTkVMX0My", + "U19SRVZFUlNFX0NPTk5FQ1QQ8C4SIwoeQ01EX1RVTk5FTF9TMkNfUkVWRVJT", + "RV9DT05ORUNUEPEuEiYKIUNNRF9UVU5ORUxfQzJTX1JFVkVSU0VfRElTQ09O", + "TkVDVBDyLhImCiFDTURfVFVOTkVMX1MyQ19SRVZFUlNFX0RJU0NPTk5FQ1QQ", + "8y4SIAobQ01EX1RVTk5FTF9DMlNfUkVWRVJTRV9EQVRBEPQuEiAKG0NNRF9U", + "VU5ORUxfUzJDX1JFVkVSU0VfREFUQRD1LiorCglFcnJvckNvZGUSEAoMRVJS", "T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz", "ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq", "SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB", @@ -97,29 +103,53 @@ namespace AxibugProtobuf { /// [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, /// - ///客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + ///正向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_CONNECT")] CmdTunnelC2SConnect = 5000, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_CONNECT")] CmdTunnelC2SForwardConnect = 5000, /// - ///服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + ///正向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_CONNECT")] CmdTunnelS2CConnect = 5001, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_CONNECT")] CmdTunnelS2CForwardConnect = 5001, /// - ///客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + ///正向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DISCONNECT")] CmdTunnelC2SDisconnect = 5002, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DISCONNECT")] CmdTunnelC2SForwardDisconnect = 5002, /// - ///服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + ///正向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DISCONNECT")] CmdTunnelS2CDisconnect = 5003, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DISCONNECT")] CmdTunnelS2CForwardDisconnect = 5003, /// - ///客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + ///正向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA /// - [pbr::OriginalName("CMD_TUNNEL_C2S_DATA")] CmdTunnelC2SData = 5004, + [pbr::OriginalName("CMD_TUNNEL_C2S_FORWARD_DATA")] CmdTunnelC2SForwardData = 5004, /// - ///服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + ///正向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA /// - [pbr::OriginalName("CMD_TUNNEL_S2C_DATA")] CmdTunnelS2CData = 5005, + [pbr::OriginalName("CMD_TUNNEL_S2C_FORWARD_DATA")] CmdTunnelS2CForwardData = 5005, + /// + ///反向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_CONNECT")] CmdTunnelC2SReverseConnect = 6000, + /// + ///反向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_CONNECT")] CmdTunnelS2CReverseConnect = 6001, + /// + ///反向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DISCONNECT")] CmdTunnelC2SReverseDisconnect = 6002, + /// + ///反向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DISCONNECT")] CmdTunnelS2CReverseDisconnect = 6003, + /// + ///反向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_REVERSE_DATA")] CmdTunnelC2SReverseData = 6004, + /// + ///反向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_REVERSE_DATA")] CmdTunnelS2CReverseData = 6005, } public enum ErrorCode { diff --git a/ProtobufCore/proto/protobuf_NoSugar.proto b/ProtobufCore/proto/protobuf_NoSugar.proto index 7599774..ffea597 100644 --- a/ProtobufCore/proto/protobuf_NoSugar.proto +++ b/ProtobufCore/proto/protobuf_NoSugar.proto @@ -13,12 +13,19 @@ enum CommandID CMD_CHATMSG = 4001; //广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP - CMD_TUNNEL_C2S_CONNECT = 5000; //客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect - CMD_TUNNEL_S2C_CONNECT = 5001; //服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect - CMD_TUNNEL_C2S_DISCONNECT = 5002; //客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect - CMD_TUNNEL_S2C_DISCONNECT = 5003; //服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect - CMD_TUNNEL_C2S_DATA = 5004; //客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA - CMD_TUNNEL_S2C_DATA = 5005; //服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + CMD_TUNNEL_C2S_FORWARD_CONNECT = 5000; //正向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + CMD_TUNNEL_S2C_FORWARD_CONNECT = 5001; //正向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + CMD_TUNNEL_C2S_FORWARD_DISCONNECT = 5002; //正向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + CMD_TUNNEL_S2C_FORWARD_DISCONNECT = 5003; //正向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + CMD_TUNNEL_C2S_FORWARD_DATA = 5004; //正向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + CMD_TUNNEL_S2C_FORWARD_DATA = 5005; //正向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + + CMD_TUNNEL_C2S_REVERSE_CONNECT = 6000; //反向代理,客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + CMD_TUNNEL_S2C_REVERSE_CONNECT = 6001; //反向代理,服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + CMD_TUNNEL_C2S_REVERSE_DISCONNECT = 6002; //反向代理,客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + CMD_TUNNEL_S2C_REVERSE_DISCONNECT = 6003; //反向代理,服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + CMD_TUNNEL_C2S_REVERSE_DATA = 6004; //反向代理,客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + CMD_TUNNEL_S2C_REVERSE_DATA = 6005; //反向代理,服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA } enum ErrorCode diff --git a/Sample/NoSugarNet.ClientCli/Program.cs b/Sample/NoSugarNet.ClientCli/Program.cs index 68d698d..90c8960 100644 --- a/Sample/NoSugarNet.ClientCli/Program.cs +++ b/Sample/NoSugarNet.ClientCli/Program.cs @@ -28,10 +28,10 @@ namespace NoSugarNet.ClientCli AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort); break; case "tlist": - AppNoSugarNet.local.GetClientCount(out int ClientUserCount, out int TunnelCount); + AppNoSugarNet.forwardlocal.GetClientCount(out int ClientUserCount, out int TunnelCount); Console.WriteLine($"GetClientCount->{ClientUserCount} TunnelCount->{TunnelCount}"); - AppNoSugarNet.local.GetClientDebugInfo(); + AppNoSugarNet.forwardlocal.GetClientDebugInfo(); break; case "stop": AppNoSugarNet.Close();