压缩适配器独立

This commit is contained in:
sin365 2024-01-25 17:17:16 +08:00
parent 6607b3161d
commit 808272ed74
24 changed files with 428 additions and 253 deletions

View File

@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NoSugarNet.ClientCore.Common
{
/// <summary>
/// 压缩适配器
/// </summary>
public class CompressAdapter
{
IDataCompress mIDataCompress;
public CompressAdapter(ushort type)
{
switch (type)
{
//不压缩
case 0:
mIDataCompress = new NoCompress();
break;
//TODO 其他压缩对比
default:
mIDataCompress = new NoCompress();
break;
}
}
public byte[] Compress(byte[] data)
{
return mIDataCompress.Compress(data);
}
public byte[] Decompress(byte[] data)
{
return mIDataCompress.Decompress(data);
}
}
public interface IDataCompress
{
public byte[] Compress(byte[] data);
public byte[] Decompress(byte[] data);
}
public class NoCompress : IDataCompress
{
public byte[] Compress(byte[] data)
{
return data;
}
public byte[] Decompress(byte[] data)
{
return data;
}
}
}

View File

@ -4,9 +4,8 @@ using HaoYueNet.ServerNetwork;
using NoSugarNet.ClientCore;
using NoSugarNet.ClientCore.Common;
using NoSugarNet.ClientCore.Network;
using System.Data;
using NoSugarNet.DataHelper;
using System.Net;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ServerCore.Manager
{
@ -15,12 +14,11 @@ namespace ServerCore.Manager
Dictionary<byte, Protobuf_Cfgs_Single> mDictTunnelID2Cfg = new Dictionary<byte, Protobuf_Cfgs_Single>();
Dictionary<byte, LocalListener> mDictTunnelID2Listeners = new Dictionary<byte, LocalListener>();
CompressAdapter mCompressAdapter;
E_CompressAdapter compressAdapterType;
public LocalMsgQueuePool _localMsgPool = new LocalMsgQueuePool(1000);
public AppLocalClient()
{
//初始化压缩适配器暂时使用0代表压缩类型
mCompressAdapter = new CompressAdapter(0);
//注册网络消息
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdCfgs, Recive_CmdCfgs);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CConnect, Recive_TunnelS2CConnect);
@ -45,6 +43,9 @@ namespace ServerCore.Manager
/// </summary>
void InitListenerMode()
{
AppNoSugarNet.log.Debug("初始化压缩适配器" + compressAdapterType);
//初始化压缩适配器,代表压缩类型
mCompressAdapter = new CompressAdapter(compressAdapterType);
foreach (var cfg in mDictTunnelID2Cfg)
{
LocalListener listener = new LocalListener(256, 1024, cfg.Key);
@ -120,6 +121,7 @@ namespace ServerCore.Manager
Protobuf_Cfgs_Single cfg = msg.Cfgs[i];
mDictTunnelID2Cfg[(byte)cfg.TunnelID] = cfg;
}
compressAdapterType = (E_CompressAdapter)msg.CompressAdapterType;
InitListenerMode();
}
public void Recive_TunnelS2CConnect(byte[] reqData)
@ -279,7 +281,6 @@ namespace ServerCore.Manager
SendDataToRemote(tunnelId, Idx, data);
}
void SendDataToRemote(byte tunnelId, byte Idx, byte[] data)
{
//压缩

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Google.Protobuf">
<HintPath>..\Lib\Google.Protobuf.dll</HintPath>

View File

@ -31,39 +31,39 @@ namespace AxibugProtobuf {
"cmQYBCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEo",
"CRIVCg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoG",
"U3RhdHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0",
"dXMiQwoNUHJvdG9idWZfQ2ZncxIyCgRjZmdzGAEgAygLMiQuQXhpYnVnUHJv",
"dG9idWYuUHJvdG9idWZfQ2Znc19TaW5nbGUiNgoUUHJvdG9idWZfQ2Znc19T",
"aW5nbGUSEAoIVHVubmVsSUQYASABKA0SDAoEUG9ydBgCIAEoBSIjChBQcm90",
"b2J1Zl9DaG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BIQCghUdW5uZWxJRBgB",
"IAEoDRILCgNJZHgYAiABKA0iTgoRUHJvdG9idWZfQzJTX0RBVEESEAoIVHVu",
"bmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhoKEkh1bnRlck5ldENvcmVfRGF0",
"YRgDIAEoDCJOChFQcm90b2J1Zl9TMkNfREFUQRIQCghUdW5uZWxJRBgBIAEo",
"DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKvoB",
"CglDb21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN",
"CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM",
"X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS",
"HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM",
"X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS",
"GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS",
"T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz",
"ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq",
"SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB",
"EgsKB0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3Vs",
"dFN0YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYK",
"Ak9LEAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z"));
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_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "Cfgs" }, 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),
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null),
@ -788,6 +788,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Protobuf_Cfgs(Protobuf_Cfgs other) : this() {
compressAdapterType_ = other.compressAdapterType_;
cfgs_ = other.cfgs_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
@ -797,10 +798,24 @@ namespace AxibugProtobuf {
return new Protobuf_Cfgs(this);
}
/// <summary>Field number for the "CompressAdapterType" field.</summary>
public const int CompressAdapterTypeFieldNumber = 1;
private int compressAdapterType_;
/// <summary>
///压缩类型
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CompressAdapterType {
get { return compressAdapterType_; }
set {
compressAdapterType_ = value;
}
}
/// <summary>Field number for the "cfgs" field.</summary>
public const int CfgsFieldNumber = 1;
public const int CfgsFieldNumber = 2;
private static readonly pb::FieldCodec<global::AxibugProtobuf.Protobuf_Cfgs_Single> _repeated_cfgs_codec
= pb::FieldCodec.ForMessage(10, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
= pb::FieldCodec.ForMessage(18, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
private readonly pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single> cfgs_ = new pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single>();
/// <summary>
///配置
@ -823,6 +838,7 @@ namespace AxibugProtobuf {
if (ReferenceEquals(other, this)) {
return true;
}
if (CompressAdapterType != other.CompressAdapterType) return false;
if(!cfgs_.Equals(other.cfgs_)) return false;
return Equals(_unknownFields, other._unknownFields);
}
@ -830,6 +846,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (CompressAdapterType != 0) hash ^= CompressAdapterType.GetHashCode();
hash ^= cfgs_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
@ -847,6 +864,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -857,6 +878,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(ref output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -867,6 +892,9 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (CompressAdapterType != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(CompressAdapterType);
}
size += cfgs_.CalculateSize(_repeated_cfgs_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -879,6 +907,9 @@ namespace AxibugProtobuf {
if (other == null) {
return;
}
if (other.CompressAdapterType != 0) {
CompressAdapterType = other.CompressAdapterType;
}
cfgs_.Add(other.cfgs_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@ -894,7 +925,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(input, _repeated_cfgs_codec);
break;
}
@ -912,7 +947,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(ref input, _repeated_cfgs_codec);
break;
}

View File

@ -0,0 +1,93 @@
using System.IO.Compression;
namespace NoSugarNet.DataHelper
{
public enum E_CompressAdapter
{
//不压缩
None = 0,
//GIPZ
GZIP_Plan1 = 1,
}
/// <summary>
/// 压缩适配器
/// </summary>
public class CompressAdapter
{
IDataCompress mIDataCompress;
public CompressAdapter(E_CompressAdapter type)
{
switch (type)
{
//不压缩
case E_CompressAdapter.None:
mIDataCompress = new NoCompress();
break;
//GZIP Plan1
case E_CompressAdapter.GZIP_Plan1:
mIDataCompress = new GZipCompress();
break;
//TODO 其他压缩对比
//……
default:
mIDataCompress = new NoCompress();
break;
}
}
public byte[] Compress(byte[] data)
{
return mIDataCompress.Compress(data);
}
public byte[] Decompress(byte[] data)
{
return mIDataCompress.Decompress(data);
}
}
public interface IDataCompress
{
public byte[] Compress(byte[] data);
public byte[] Decompress(byte[] data);
}
public class NoCompress : IDataCompress
{
public byte[] Compress(byte[] data)
{
return data;
}
public byte[] Decompress(byte[] data)
{
return data;
}
}
public class GZipCompress : IDataCompress
{
public byte[] Compress(byte[] data)
{
using (var compressedStream = new MemoryStream())
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}
public byte[] Decompress(byte[] data)
{
using (var compressedStream = new MemoryStream(data))
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
return resultStream.ToArray();
}
}
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NoSugarNet.ServerCore.Common
{
/// <summary>
/// 压缩适配器
/// </summary>
public class CompressAdapter
{
IDataCompress mIDataCompress;
public CompressAdapter(ushort type)
{
switch (type)
{
//不压缩
case 0:
mIDataCompress = new NoCompress();
break;
//TODO 其他压缩对比
default:
mIDataCompress = new NoCompress();
break;
}
}
public byte[] Compress(byte[] data)
{
return mIDataCompress.Compress(data);
}
public byte[] Decompress(byte[] data)
{
return mIDataCompress.Decompress(data);
}
}
public interface IDataCompress
{
public byte[] Compress(byte[] data);
public byte[] Decompress(byte[] data);
}
public class NoCompress : IDataCompress
{
public byte[] Compress(byte[] data)
{
return data;
}
public byte[] Decompress(byte[] data)
{
return data;
}
}
}

View File

@ -1,4 +1,5 @@
using System.Text;
using NoSugarNet.DataHelper;
using System.Text;
namespace NoSugarNet.ServerCore.Common
{
@ -12,6 +13,7 @@ namespace NoSugarNet.ServerCore.Common
public static class Config
{
public static Dictionary<byte, TunnelClientData> Cfgs = new Dictionary<byte, TunnelClientData>();
public static Dictionary<byte, TunnelClientData> cfgs = new Dictionary<byte, TunnelClientData>();
public static E_CompressAdapter compressAdapterType;
}
}

View File

@ -1,11 +1,11 @@
using AxibugProtobuf;
using NoSugarNet.ClientCore.Network;
using Google.Protobuf;
using NoSugarNet.ClientCore.Network;
using NoSugarNet.DataHelper;
using NoSugarNet.ServerCore.Common;
using ServerCore.Common;
using ServerCore.NetWork;
using System.Net.Sockets;
using System.Collections.Generic;
namespace ServerCore.Manager
{
@ -14,6 +14,9 @@ namespace ServerCore.Manager
Dictionary<long, ServerLocalClient> mDictCommKey2ServerLocalClients = new Dictionary<long, ServerLocalClient>();
CompressAdapter mCompressAdapter;
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;
@ -24,10 +27,11 @@ namespace ServerCore.Manager
return CommKey / 10000000;
}
public LocalClientManager()
public LocalClientManager(E_CompressAdapter compressAdapterType)
{
ServerManager.g_Log.Debug("初始化压缩适配器" + compressAdapterType);
//初始化压缩适配器暂时使用0代表压缩类型
mCompressAdapter = new CompressAdapter(0);
mCompressAdapter = new CompressAdapter(compressAdapterType);
//注册网络消息
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SConnect, Recive_TunnelC2SConnect);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelC2SDisconnect, Recive_TunnelC2SDisconnect);
@ -176,14 +180,14 @@ namespace ServerCore.Manager
if (!ServerManager.g_ClientMgr.GetClientByUID(uid, out ClientInfo client))
return;
if (!Config.Cfgs.ContainsKey(tunnelId))
if (!Config.cfgs.ContainsKey(tunnelId))
return;
//开一个线程去建立连接
Thread thread = new Thread(() =>
{
//服务器本地局域网连接指定端口
TunnelClientData tunnelDataCfg = Config.Cfgs[tunnelId];
TunnelClientData tunnelDataCfg = Config.cfgs[tunnelId];
ServerLocalClient serverLocalClient = new ServerLocalClient(uid, tunnelId, (byte)Idx);
//连接成功
if (!serverLocalClient.Init(tunnelDataCfg.ServerLocalTargetIP, tunnelDataCfg.ServerLocalTargetPort))
@ -279,7 +283,8 @@ namespace ServerCore.Manager
//隧道ID定位投递服务端本地连接
if (!GetServerLocalClient(uid, tunnelId, Idx, out ServerLocalClient serverLocalClient))
return;
//记录数据长度
tSendAllLenght += data.Length;
//解压
data = mCompressAdapter.Decompress(data);
//记录数据长度
@ -331,8 +336,12 @@ namespace ServerCore.Manager
if (!ServerManager.g_ClientMgr.GetClientByUID(uid, out ClientInfo client))
return;
//压缩
data = mCompressAdapter.Compress(data);
//记录压缩后数据长度
tReciveAllLenght += data.Length;
byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_S2C_DATA()
{
TunnelID = tunnelId,

View File

@ -30,12 +30,13 @@ namespace ServerCore.Manager
ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdLogin, (int)ErrorCode.ErrorOk, respData);
Protobuf_Cfgs cfgsSP = new Protobuf_Cfgs();
byte[] keys = Config.Cfgs.Keys.ToArray();
for (int i = 0; i < Config.Cfgs.Count; i++)
byte[] keys = Config.cfgs.Keys.ToArray();
for (int i = 0; i < Config.cfgs.Count; i++)
{
TunnelClientData cfg = Config.Cfgs[keys[i]];
TunnelClientData cfg = Config.cfgs[keys[i]];
cfgsSP.Cfgs.Add(new Protobuf_Cfgs_Single() { TunnelID = cfg.TunnelId, Port = cfg.ClientLocalPort });
}
cfgsSP.CompressAdapterType = (int)Config.compressAdapterType;
byte[] respDataCfg = ProtoBufHelper.Serizlize(cfgsSP);
ServerManager.g_ClientMgr.ClientSend(cinfo, (int)CommandID.CmdCfgs, (int)ErrorCode.ErrorOk, respDataCfg);

View File

@ -1,6 +1,7 @@
using HaoYueNet.ClientNetwork.OtherMode;
using ServerCore.Manager;
using System;
using System.Security.Cryptography;
namespace NoSugarNet.ClientCore.Network
{

View File

@ -1,4 +1,5 @@
using NoSugarNet.ServerCore;
using NoSugarNet.DataHelper;
using NoSugarNet.ServerCore;
using NoSugarNet.ServerCore.Common;
using ServerCore.NetWork;
using System.Net;
@ -24,15 +25,16 @@ namespace ServerCore.Manager
public static event OnUpdateStatusHandler OnUpdateStatus;
#endregion
public static void InitServer(int port, Dictionary<byte, TunnelClientData> cfgs)
public static void InitServer(int port, Dictionary<byte, TunnelClientData> cfgs,int compressAdapterType = 1)
{
Config.Cfgs = cfgs;
Config.cfgs = cfgs;
Config.compressAdapterType = (E_CompressAdapter)compressAdapterType;
g_ClientMgr = new ClientManager();
g_ClientMgr.Init(45000, 120);
g_Log = new LogManager();
g_Login = new LoginManager();
g_Chat = new ChatManager();
g_Local = new LocalClientManager();
g_Local = new LocalClientManager((E_CompressAdapter)compressAdapterType);
//g_SocketMgr = new IOCPNetWork(1024, 1024);
g_SocketMgr = new IOCPNetWork(1024, 4096);
@ -57,10 +59,14 @@ namespace ServerCore.Manager
{
TunnelCount = TunnelCount,
ClientUserCount = ClientUserCount,
SendAllLenght = resultSendAllLenght,
ReciveAllLenght = resultReciveAllLenght,
ReciveSecSpeed = (resultReciveAllLenght - netStatus.ReciveAllLenght) / (TimerInterval / 1000),
SendSecSpeed = (resultSendAllLenght - netStatus.SendAllLenght) / (TimerInterval / 1000),
srcSendAllLenght = resultSendAllLenght,
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),
};
netStatus = resutnetStatus;
OnUpdateStatus?.Invoke(resutnetStatus);

View File

@ -4,9 +4,13 @@
{
public int ClientUserCount;
public int TunnelCount;
public long ReciveAllLenght;
public long SendAllLenght;
public long ReciveSecSpeed;
public long SendSecSpeed;
public long srcReciveAllLenght;
public long srcSendAllLenght;
public long srcReciveSecSpeed;
public long srcSendSecSpeed;
public long tReciveAllLenght;
public long tSendAllLenght;
public long tReciveSecSpeed;
public long tSendSecSpeed;
}
}

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Google.Protobuf">
<HintPath>..\Lib\Google.Protobuf.dll</HintPath>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>F:\Sin365\NoSugarNet\NoSugarNet.ServerCore\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-01-25T09:08:35.3176032Z;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -31,39 +31,39 @@ namespace AxibugProtobuf {
"cmQYBCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEo",
"CRIVCg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoG",
"U3RhdHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0",
"dXMiQwoNUHJvdG9idWZfQ2ZncxIyCgRjZmdzGAEgAygLMiQuQXhpYnVnUHJv",
"dG9idWYuUHJvdG9idWZfQ2Znc19TaW5nbGUiNgoUUHJvdG9idWZfQ2Znc19T",
"aW5nbGUSEAoIVHVubmVsSUQYASABKA0SDAoEUG9ydBgCIAEoBSIjChBQcm90",
"b2J1Zl9DaGF0TXNnEg8KB0NoYXRNc2cYASABKAkiSAoVUHJvdG9idWZfQ2hh",
"dE1zZ19SRVNQEhAKCE5pY2tOYW1lGAEgASgJEg8KB0NoYXRNc2cYAiABKAkS",
"DAoERGF0ZRgDIAEoAyI1ChRQcm90b2J1Zl9DMlNfQ29ubmVjdBIQCghUdW5u",
"ZWxJRBgBIAEoDRILCgNJZHgYAiABKA0iSAoUUHJvdG9idWZfUzJDX0Nvbm5l",
"Y3QSEAoIVHVubmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhEKCUNvbm5lY3Rl",
"ZBgD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MT0dJThDRDxIN",
"CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM",
"X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS",
"HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM",
"X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS",
"GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS",
"T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz",
"ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq",
"SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB",
"EgsKB0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3Vs",
"dFN0YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYK",
"Ak9LEAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z"));
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_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "Cfgs" }, 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),
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null),
@ -788,6 +788,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Protobuf_Cfgs(Protobuf_Cfgs other) : this() {
compressAdapterType_ = other.compressAdapterType_;
cfgs_ = other.cfgs_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
@ -797,10 +798,24 @@ namespace AxibugProtobuf {
return new Protobuf_Cfgs(this);
}
/// <summary>Field number for the "CompressAdapterType" field.</summary>
public const int CompressAdapterTypeFieldNumber = 1;
private int compressAdapterType_;
/// <summary>
///压缩类型
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CompressAdapterType {
get { return compressAdapterType_; }
set {
compressAdapterType_ = value;
}
}
/// <summary>Field number for the "cfgs" field.</summary>
public const int CfgsFieldNumber = 1;
public const int CfgsFieldNumber = 2;
private static readonly pb::FieldCodec<global::AxibugProtobuf.Protobuf_Cfgs_Single> _repeated_cfgs_codec
= pb::FieldCodec.ForMessage(10, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
= pb::FieldCodec.ForMessage(18, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
private readonly pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single> cfgs_ = new pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single>();
/// <summary>
///配置
@ -823,6 +838,7 @@ namespace AxibugProtobuf {
if (ReferenceEquals(other, this)) {
return true;
}
if (CompressAdapterType != other.CompressAdapterType) return false;
if(!cfgs_.Equals(other.cfgs_)) return false;
return Equals(_unknownFields, other._unknownFields);
}
@ -830,6 +846,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (CompressAdapterType != 0) hash ^= CompressAdapterType.GetHashCode();
hash ^= cfgs_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
@ -847,6 +864,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -857,6 +878,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(ref output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -867,6 +892,9 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (CompressAdapterType != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(CompressAdapterType);
}
size += cfgs_.CalculateSize(_repeated_cfgs_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -879,6 +907,9 @@ namespace AxibugProtobuf {
if (other == null) {
return;
}
if (other.CompressAdapterType != 0) {
CompressAdapterType = other.CompressAdapterType;
}
cfgs_.Add(other.cfgs_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@ -894,7 +925,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(input, _repeated_cfgs_codec);
break;
}
@ -912,7 +947,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(ref input, _repeated_cfgs_codec);
break;
}

View File

@ -10,15 +10,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{EDA9D3FD-1A7
Lib\HaoYueNet.ServerNetwork.dll = Lib\HaoYueNet.ServerNetwork.dll
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ServerCore", "NoSugarNet.ServerCore\NoSugarNet.ServerCore.csproj", "{25FB6F12-4619-4D2C-8FC1-70AAAA8AD100}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ServerCore", "NoSugarNet.ServerCore\NoSugarNet.ServerCore.csproj", "{25FB6F12-4619-4D2C-8FC1-70AAAA8AD100}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ClientCore", "NoSugarNet.ClientCore\NoSugarNet.ClientCore.csproj", "{80AF9D64-681C-4B6F-B2FF-5DD847186749}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ClientCore", "NoSugarNet.ClientCore\NoSugarNet.ClientCore.csproj", "{80AF9D64-681C-4B6F-B2FF-5DD847186749}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{5E65F25A-8B59-4FC7-8582-C6887C3CD0A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ClientCli", "Sample\NoSugarNet.ClientCli\NoSugarNet.ClientCli.csproj", "{29D76CF3-BF7E-45A5-9957-2CBC0A41B6FB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ClientCli", "Sample\NoSugarNet.ClientCli\NoSugarNet.ClientCli.csproj", "{29D76CF3-BF7E-45A5-9957-2CBC0A41B6FB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ServerCli", "Sample\NoSugarNet.ServerCli\NoSugarNet.ServerCli.csproj", "{65220036-9A81-49FA-A5BC-DA06783D2E52}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ServerCli", "Sample\NoSugarNet.ServerCli\NoSugarNet.ServerCli.csproj", "{65220036-9A81-49FA-A5BC-DA06783D2E52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.DataHelper", "NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj", "{3C41B685-B46B-4057-826B-C8C6F395BFA8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -42,6 +44,10 @@ Global
{65220036-9A81-49FA-A5BC-DA06783D2E52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65220036-9A81-49FA-A5BC-DA06783D2E52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65220036-9A81-49FA-A5BC-DA06783D2E52}.Release|Any CPU.Build.0 = Release|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -31,39 +31,39 @@ namespace AxibugProtobuf {
"cmQYBCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEo",
"CRIVCg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoG",
"U3RhdHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0",
"dXMiQwoNUHJvdG9idWZfQ2ZncxIyCgRjZmdzGAEgAygLMiQuQXhpYnVnUHJv",
"dG9idWYuUHJvdG9idWZfQ2Znc19TaW5nbGUiNgoUUHJvdG9idWZfQ2Znc19T",
"aW5nbGUSEAoIVHVubmVsSUQYASABKA0SDAoEUG9ydBgCIAEoBSIjChBQcm90",
"b2J1Zl9DaGF0TXNnEg8KB0NoYXRNc2cYASABKAkiSAoVUHJvdG9idWZfQ2hh",
"dE1zZ19SRVNQEhAKCE5pY2tOYW1lGAEgASgJEg8KB0NoYXRNc2cYAiABKAkS",
"DAoERGF0ZRgDIAEoAyI1ChRQcm90b2J1Zl9DMlNfQ29ubmVjdBIQCghUdW5u",
"ZWxJRBgBIAEoDRILCgNJZHgYAiABKA0iSAoUUHJvdG9idWZfUzJDX0Nvbm5l",
"Y3QSEAoIVHVubmVsSUQYASABKA0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21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN",
"CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM",
"X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS",
"HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM",
"X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS",
"GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS",
"T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz",
"ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq",
"SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB",
"EgsKB0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3Vs",
"dFN0YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYK",
"Ak9LEAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z"));
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_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "Cfgs" }, 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),
new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null),
@ -788,6 +788,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Protobuf_Cfgs(Protobuf_Cfgs other) : this() {
compressAdapterType_ = other.compressAdapterType_;
cfgs_ = other.cfgs_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
@ -797,10 +798,24 @@ namespace AxibugProtobuf {
return new Protobuf_Cfgs(this);
}
/// <summary>Field number for the "CompressAdapterType" field.</summary>
public const int CompressAdapterTypeFieldNumber = 1;
private int compressAdapterType_;
/// <summary>
///压缩类型
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CompressAdapterType {
get { return compressAdapterType_; }
set {
compressAdapterType_ = value;
}
}
/// <summary>Field number for the "cfgs" field.</summary>
public const int CfgsFieldNumber = 1;
public const int CfgsFieldNumber = 2;
private static readonly pb::FieldCodec<global::AxibugProtobuf.Protobuf_Cfgs_Single> _repeated_cfgs_codec
= pb::FieldCodec.ForMessage(10, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
= pb::FieldCodec.ForMessage(18, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser);
private readonly pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single> cfgs_ = new pbc::RepeatedField<global::AxibugProtobuf.Protobuf_Cfgs_Single>();
/// <summary>
///配置
@ -823,6 +838,7 @@ namespace AxibugProtobuf {
if (ReferenceEquals(other, this)) {
return true;
}
if (CompressAdapterType != other.CompressAdapterType) return false;
if(!cfgs_.Equals(other.cfgs_)) return false;
return Equals(_unknownFields, other._unknownFields);
}
@ -830,6 +846,7 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (CompressAdapterType != 0) hash ^= CompressAdapterType.GetHashCode();
hash ^= cfgs_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
@ -847,6 +864,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -857,6 +878,10 @@ namespace AxibugProtobuf {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (CompressAdapterType != 0) {
output.WriteRawTag(8);
output.WriteInt32(CompressAdapterType);
}
cfgs_.WriteTo(ref output, _repeated_cfgs_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -867,6 +892,9 @@ namespace AxibugProtobuf {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (CompressAdapterType != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(CompressAdapterType);
}
size += cfgs_.CalculateSize(_repeated_cfgs_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -879,6 +907,9 @@ namespace AxibugProtobuf {
if (other == null) {
return;
}
if (other.CompressAdapterType != 0) {
CompressAdapterType = other.CompressAdapterType;
}
cfgs_.Add(other.cfgs_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@ -894,7 +925,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(input, _repeated_cfgs_codec);
break;
}
@ -912,7 +947,11 @@ namespace AxibugProtobuf {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
case 8: {
CompressAdapterType = input.ReadInt32();
break;
}
case 18: {
cfgs_.AddEntriesFrom(ref input, _repeated_cfgs_codec);
break;
}

View File

@ -72,7 +72,8 @@ message Protobuf_Login_RESP
//
message Protobuf_Cfgs
{
repeated Protobuf_Cfgs_Single cfgs = 1;//
int32 CompressAdapterType = 1;//
repeated Protobuf_Cfgs_Single cfgs = 2;//
}
message Protobuf_Cfgs_Single

View File

@ -8,6 +8,7 @@ namespace NoSugarNet.ServerCli
public class ConfigDataModel
{
public int ServerPort { get; set; }
public int CompressAdapterType { get; set; }
public List<ConfigDataModel_Single> TunnelList { get; set; }
}

View File

@ -30,7 +30,7 @@ namespace NoSugarNet.ServerCli
}
ServerManager.OnUpdateStatus += OnUpdateStatus;
ServerManager.InitServer(Config.cfg.ServerPort, dictTunnel);
ServerManager.InitServer(Config.cfg.ServerPort, dictTunnel,Config.cfg.CompressAdapterType);
while (true)
{
@ -40,8 +40,8 @@ namespace NoSugarNet.ServerCli
static void OnUpdateStatus(NetStatus netState)
{
string info = $"{Title} RecLen:{netState.ReciveAllLenght} SendLen:{netState.SendAllLenght} tUserNum:{netState.ClientUserCount} tTunnelNum:{netState.TunnelCount} recSpeed:{ConvertBytesToKilobytes(netState.ReciveSecSpeed)}K/s sendSpeed:{ConvertBytesToKilobytes(netState.SendSecSpeed)}K/s";
Console.Title = info;
string info = $"User:{netState.ClientUserCount} Tun:{netState.TunnelCount} rec:{netState.srcReciveAllLenght}|{netState.tReciveAllLenght} {ConvertBytesToKilobytes(netState.srcReciveSecSpeed)}K/s|{ConvertBytesToKilobytes(netState.tReciveSecSpeed)}K/s send:{netState.srcSendAllLenght}|{netState.tSendAllLenght} {ConvertBytesToKilobytes(netState.srcSendSecSpeed)}K/s|{ConvertBytesToKilobytes(netState.tSendSecSpeed)}K/s";
Console.Title = Title + info;
Console.WriteLine(info);
}

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-01-23T10:28:01.1220581Z;True|2024-01-23T16:36:21.1141328+08:00;</History>
<History>True|2024-01-25T09:09:07.9161603Z;True|2024-01-23T18:28:01.1220581+08:00;True|2024-01-23T16:36:21.1141328+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>