OCT 1. 更新SCG协议
This commit is contained in:
parent
a5d0c64e86
commit
93f6f05f49
|
@ -4,7 +4,10 @@
|
|||
#pragma once
|
||||
|
||||
#define ENABLE_UDP_PROXY_DEBUG (0)
|
||||
#define SCG_HEAD_LENGTH (14)
|
||||
|
||||
int get_scg_cur_vmid();
|
||||
|
||||
const char *get_scg_proxy_ipaddr();
|
||||
|
||||
unsigned short get_scg_proxy_port();
|
|
@ -35,26 +35,27 @@ static void http_connected_cb(sion::Socket sock) {
|
|||
unsigned char *p;
|
||||
const unsigned int id = htonl(g_scgProxyCfg.curConnVmId);
|
||||
const auto svrId = static_cast<unsigned char>(WG_CTRL_SCG_ID);
|
||||
unsigned char scgProxy[] = {0x01, // VERSION
|
||||
0x00, // Length 0
|
||||
0x0A, // Length 1
|
||||
0xF0, // ++++++ INFO[0] TYPE
|
||||
0x04, // INFO[0] LENGTH
|
||||
0, // INFO[0] VMID[0]
|
||||
0, // INFO[0] VMID[1]
|
||||
0, // INFO[0] VMID[2]
|
||||
0, // INFO[0] VMID[3]
|
||||
0xF1, // INFO[1] TYPE
|
||||
0x00, // INFO[1] LENGTH 0
|
||||
0x01, // INFO[1] LENGTH 1
|
||||
svrId}; // ------ INFO[1] SCG Service ID
|
||||
unsigned char scgProxy[] = {0x01, // VERSION
|
||||
0x00, // Length 0
|
||||
SCG_HEAD_LENGTH - 3, // Length 1
|
||||
0xF0, // ++++++ INFO[0] TYPE
|
||||
0x00, // INFO[0] LENGTH 0
|
||||
0x04, // INFO[0] LENGTH 1
|
||||
0, // INFO[0] VMID[0]
|
||||
0, // INFO[0] VMID[1]
|
||||
0, // INFO[0] VMID[2]
|
||||
0, // INFO[0] VMID[3]
|
||||
0xF1, // INFO[1] TYPE
|
||||
0x00, // INFO[1] LENGTH 0
|
||||
0x01, // INFO[1] LENGTH 1
|
||||
svrId}; // ------ INFO[1] SCG Service ID
|
||||
|
||||
p = scgProxy;
|
||||
memcpy(vmid, &id, 4);
|
||||
scgProxy[5] = vmid[0];
|
||||
scgProxy[6] = vmid[1];
|
||||
scgProxy[7] = vmid[2];
|
||||
scgProxy[8] = vmid[3];
|
||||
scgProxy[6] = vmid[0];
|
||||
scgProxy[7] = vmid[1];
|
||||
scgProxy[8] = vmid[2];
|
||||
scgProxy[9] = vmid[3];
|
||||
|
||||
ret = send(sock, reinterpret_cast<const char *>(p), sizeof(scgProxy), 0);
|
||||
|
||||
|
@ -90,7 +91,7 @@ int init_scgproxy_service(const char *pSCGIpAddr, int scgPort) {
|
|||
int ret;
|
||||
|
||||
ANDROID_LOG(ANDROID_LOG_INFO, "SCGPROXY", "libsccproxy(%s) library information: (Build: %s %s GCC Ver:%s) With %u(bits) OS\n",
|
||||
ENABLE_UDP_PROXY_DEBUG ? "DEBUG" : "RELEASE", __DATE__, __TIME__, __VERSION__, (unsigned int)(sizeof(int *) * 8));
|
||||
ENABLE_UDP_PROXY_DEBUG ? "DEBUG" : "RELEASE", __DATE__, __TIME__, __VERSION__, (unsigned int) (sizeof(int *) * 8));
|
||||
|
||||
memset(&g_scgProxyCfg, 0, sizeof(SCGPROXY_CONFIG));
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
||||
#endif
|
||||
|
||||
#define SCG_UDP_HEAD_SIZE (13)
|
||||
#define SIG_CANCEL_SIGNAL SIGUSR1
|
||||
|
||||
typedef struct {
|
||||
|
@ -142,28 +141,29 @@ static void *UDPProxyRecvThread(void *UNUSED(lpParameter)) {
|
|||
bool isRemoteInit = false;
|
||||
sockaddr_in localWgAddr{};
|
||||
sockaddr_in scgAddr{};
|
||||
unsigned char recvBuf[1500 + SCG_UDP_HEAD_SIZE];
|
||||
unsigned char recvBuf[1500 + SCG_HEAD_LENGTH];
|
||||
PSCG_PROXY_INFO pProxy = &g_scgProxyInfo;
|
||||
char *pRecBuf = reinterpret_cast<char *>(&recvBuf[SCG_UDP_HEAD_SIZE]);
|
||||
char *pRecBuf = reinterpret_cast<char *>(&recvBuf[SCG_HEAD_LENGTH]);
|
||||
|
||||
scgAddr.sin_family = AF_INET;
|
||||
scgAddr.sin_port = htons(get_scg_proxy_port());
|
||||
inet_pton(AF_INET, get_scg_proxy_ipaddr(), &scgAddr.sin_addr.s_addr);
|
||||
|
||||
// 构建 SCG UDP 包头
|
||||
recvBuf[0] = 0x01; // VERSION
|
||||
recvBuf[1] = 0x0A; // Length 0
|
||||
recvBuf[2] = 0x09; // Length 1
|
||||
recvBuf[3] = 0xF0; // ++++++ INFO[0] TYPE
|
||||
recvBuf[4] = 0x04; // INFO[0] LENGTH
|
||||
recvBuf[5] = 0; // INFO[0] VMID[0]
|
||||
recvBuf[6] = 0; // INFO[0] VMID[1]
|
||||
recvBuf[7] = 0; // INFO[0] VMID[2]
|
||||
recvBuf[8] = 0; // INFO[0] VMID[3]
|
||||
recvBuf[9] = 0xF1; // INFO[1] TYPE
|
||||
recvBuf[10] = 0x00; // INFO[1] LENGTH 0
|
||||
recvBuf[11] = 0x01; // INFO[1] LENGTH 1
|
||||
recvBuf[12] = WG_TUNNEL_SCG_ID; // ------ INFO[1] SCG Service ID
|
||||
recvBuf[0] = 0x01; // VERSION
|
||||
recvBuf[1] = 0x00; // Length 0
|
||||
recvBuf[2] = SCG_HEAD_LENGTH - 3; // Length 1
|
||||
recvBuf[3] = 0xF0; // ++++++ INFO[0] TYPE
|
||||
recvBuf[4] = 0x00; // INFO[0] LENGTH 0
|
||||
recvBuf[5] = 0x04; // INFO[0] LENGTH 1
|
||||
recvBuf[6] = 0; // INFO[0] VMID[0]
|
||||
recvBuf[7] = 0; // INFO[0] VMID[1]
|
||||
recvBuf[8] = 0; // INFO[0] VMID[2]
|
||||
recvBuf[9] = 0; // INFO[0] VMID[3]
|
||||
recvBuf[10] = 0xF1; // INFO[1] TYPE
|
||||
recvBuf[11] = 0x00; // INFO[1] LENGTH 0
|
||||
recvBuf[12] = 0x01; // INFO[1] LENGTH 1
|
||||
recvBuf[13] = WG_TUNNEL_SCG_ID; // ------ INFO[1] SCG Service ID
|
||||
|
||||
pProxy->exitNow = false;
|
||||
while (!pProxy->exitNow) {
|
||||
|
@ -208,14 +208,14 @@ static void *UDPProxyRecvThread(void *UNUSED(lpParameter)) {
|
|||
}
|
||||
}
|
||||
|
||||
recvBuf[5] = vmid[0]; // INFO[0] VMID[0]
|
||||
recvBuf[6] = vmid[1]; // INFO[0] VMID[1]
|
||||
recvBuf[7] = vmid[2]; // INFO[0] VMID[2]
|
||||
recvBuf[8] = vmid[3]; // INFO[0] VMID[3]
|
||||
recvBuf[6] = vmid[0]; // INFO[0] VMID[0]
|
||||
recvBuf[7] = vmid[1]; // INFO[0] VMID[1]
|
||||
recvBuf[8] = vmid[2]; // INFO[0] VMID[2]
|
||||
recvBuf[9] = vmid[3]; // INFO[0] VMID[3]
|
||||
|
||||
// 增加SCG包头数据长度
|
||||
#if !USED_DIRECT_PROXY
|
||||
iRecvBytes += SCG_UDP_HEAD_SIZE;
|
||||
iRecvBytes += SCG_HEAD_LENGTH;
|
||||
#else
|
||||
ANDROID_LOG(ANDROID_LOG_WARN, "SCGPROXY", "Porxy Send Data Not Add SCG UDP HEAD\n");
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue