From 7fc81776dd861c1639930c4d2fe114be9da7318b Mon Sep 17 00:00:00 2001
From: yuanyuanxiang <962914132@qq.com>
Date: Sun, 20 Jul 2025 18:49:49 +0800
Subject: [PATCH] Improve: Add random protocol option for building client
---
client/ClientDll.cpp | 3 ++-
client/ClientDll_vs2015.vcxproj | 4 ++++
client/KernelManager.cpp | 12 ++++++++----
common/commands.h | 3 ++-
server/2015Remote/2015Remote.rc | Bin 90322 -> 90322 bytes
server/2015Remote/BuildDlg.cpp | 3 ++-
6 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/client/ClientDll.cpp b/client/ClientDll.cpp
index 4eafcf5..787da5c 100644
--- a/client/ClientDll.cpp
+++ b/client/ClientDll.cpp
@@ -13,7 +13,8 @@
// 远程地址
CONNECT_ADDRESS g_SETTINGS = {
FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION,
- FALSE, Startup_DLL, PROTOCOL_SHINE, PROTO_TCP, RUNNING_RANDOM,
+ FALSE, Startup_DLL, PROTOCOL_SHINE, PROTO_RANDOM, RUNNING_RANDOM, {},
+ 7057226198541618915, {},
};
// 最终客户端只有2个全局变量: g_SETTINGS、g_MyApp,而g_SETTINGS作为g_MyApp的成员.
diff --git a/client/ClientDll_vs2015.vcxproj b/client/ClientDll_vs2015.vcxproj
index 9537ecb..fcd97e0 100644
--- a/client/ClientDll_vs2015.vcxproj
+++ b/client/ClientDll_vs2015.vcxproj
@@ -161,6 +161,7 @@
+
@@ -170,6 +171,7 @@
+
@@ -192,6 +194,7 @@
+
@@ -202,6 +205,7 @@
+
diff --git a/client/KernelManager.cpp b/client/KernelManager.cpp
index f7857fe..2f7d311 100644
--- a/client/KernelManager.cpp
+++ b/client/KernelManager.cpp
@@ -18,15 +18,19 @@
// UDP 协议仅能针对小包数据,且数据没有时序关联
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_disconnect) {
- if (!conn->IsVerified() || conn->protoType == PROTO_TCP)
+ if (conn->protoType == PROTO_HTTPS) return NULL;
+
+ int type = conn->protoType == PROTO_RANDOM ? time(nullptr) % PROTO_RANDOM : conn->protoType;
+ if (!conn->IsVerified() || type == PROTO_TCP)
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeNone, conn->GetHeaderEncType());
- if (conn->protoType == PROTO_UDP)
+ if (type == PROTO_UDP)
return new IOCPUDPClient(bExit, exit_while_disconnect);
- if (conn->protoType == PROTO_HTTP)
+ if (type == PROTO_HTTP || type == PROTO_HTTPS)
return new IOCPClient(bExit, exit_while_disconnect, MaskTypeHTTP, conn->GetHeaderEncType());
- if (conn->protoType == PROTO_KCP) {
+ if (type == PROTO_KCP) {
return new IOCPKCPClient(bExit, exit_while_disconnect);
}
+
return NULL;
}
diff --git a/common/commands.h b/common/commands.h
index b5a5d59..39d29c5 100644
--- a/common/commands.h
+++ b/common/commands.h
@@ -541,8 +541,9 @@ enum ProtoType {
PROTO_TCP = 0, // TCP
PROTO_UDP = 1, // UDP
PROTO_HTTP = 2, // HTTP
- PROTO_HTTPS = 3, // HTTPS
+ PROTO_RANDOM = 3, // 随机
PROTO_KCP = 4, // KCP
+ PROTO_HTTPS = 5, // HTTPS
};
#define KCP_SESSION_ID 666
diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc
index abf11397f699ca590b3d54d273d351deb7c1784a..e1dae101db1f4d1e2a10757d8ba71c2bcc45efcf 100644
GIT binary patch
delta 131
zcmca~koD3*)(uQCljAH+Chv-y0HzZXCV^?asce&jk|6Aw
N-gk*>b6RT7Zvga