mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2026-04-19 05:21:17 +03:00
Merge pull request #2161 from siddharth-narayan/radius-retry-timeout
Add RadiusRetryTimeout option
This commit is contained in:
+5
-3
@@ -8739,7 +8739,7 @@ UINT StSetHubRadius(ADMIN *a, RPC_RADIUS *t)
|
||||
}
|
||||
|
||||
//SetRadiusServer(h, t->RadiusServerName, t->RadiusPort, t->RadiusSecret);
|
||||
SetRadiusServerEx(h, t->RadiusServerName, t->RadiusPort, t->RadiusSecret, t->RadiusRetryInterval);
|
||||
SetRadiusServerEx2(h, t->RadiusServerName, t->RadiusPort, t->RadiusSecret, t->RadiusRetryInterval, t->RadiusRetryTimeout);
|
||||
|
||||
ALog(a, h, "LA_SET_HUB_RADIUS");
|
||||
|
||||
@@ -8778,8 +8778,8 @@ UINT StGetHubRadius(ADMIN *a, RPC_RADIUS *t)
|
||||
Zero(t, sizeof(RPC_RADIUS));
|
||||
//GetRadiusServer(h, t->RadiusServerName, sizeof(t->RadiusServerName),
|
||||
// &t->RadiusPort, t->RadiusSecret, sizeof(t->RadiusSecret));
|
||||
GetRadiusServerEx(h, t->RadiusServerName, sizeof(t->RadiusServerName),
|
||||
&t->RadiusPort, t->RadiusSecret, sizeof(t->RadiusSecret), &t->RadiusRetryInterval);
|
||||
GetRadiusServerEx2(h, t->RadiusServerName, sizeof(t->RadiusServerName),
|
||||
&t->RadiusPort, t->RadiusSecret, sizeof(t->RadiusSecret), &t->RadiusRetryInterval, &t->RadiusRetryTimeout);
|
||||
|
||||
ReleaseHub(h);
|
||||
|
||||
@@ -13031,6 +13031,7 @@ void InRpcRadius(RPC_RADIUS *t, PACK *p)
|
||||
PackGetStr(p, "HubName", t->HubName, sizeof(t->HubName));
|
||||
PackGetStr(p, "RadiusSecret", t->RadiusSecret, sizeof(t->RadiusSecret));
|
||||
t->RadiusRetryInterval = PackGetInt(p, "RadiusRetryInterval");
|
||||
t->RadiusRetryTimeout = PackGetInt(p, "RadiusRetryTimeout");
|
||||
}
|
||||
void OutRpcRadius(PACK *p, RPC_RADIUS *t)
|
||||
{
|
||||
@@ -13045,6 +13046,7 @@ void OutRpcRadius(PACK *p, RPC_RADIUS *t)
|
||||
PackAddStr(p, "HubName", t->HubName);
|
||||
PackAddStr(p, "RadiusSecret", t->RadiusSecret);
|
||||
PackAddInt(p, "RadiusRetryInterval", t->RadiusRetryInterval);
|
||||
PackAddInt(p, "RadiusRetryTimeout", t->RadiusRetryTimeout);
|
||||
}
|
||||
|
||||
// RPC_HUB
|
||||
|
||||
@@ -259,6 +259,7 @@ struct RPC_RADIUS
|
||||
UINT RadiusPort; // Radius port number
|
||||
char RadiusSecret[MAX_PASSWORD_LEN + 1]; // Secret key
|
||||
UINT RadiusRetryInterval; // Radius retry interval
|
||||
UINT RadiusRetryTimeout; // Radius retry timeout
|
||||
};
|
||||
|
||||
// Specify the HUB
|
||||
|
||||
@@ -11791,6 +11791,9 @@ UINT PsRadiusServerSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
{"[server_name:port]", CmdPrompt, _UU("CMD_RadiusServerSet_Prompt_Host"), CmdEvalNotEmpty, NULL},
|
||||
{"SECRET", CmdPromptChoosePassword, _UU("CMD_RadiusServerSet_Prompt_Secret"), NULL, NULL},
|
||||
{"RETRY_INTERVAL", CmdPrompt, _UU("CMD_RadiusServerSet_Prompt_RetryInterval"), CmdEvalMinMax, &minmax},
|
||||
|
||||
// Support for setting timeout through commandline not added
|
||||
// {"RETRY_TIMEOUT", CmdPrompt, _UU("CMD_RadiusServerSet_Prompt_RetryTimeout"), CmdEvalMinMax, &minmax},
|
||||
};
|
||||
|
||||
// If virtual HUB is not selected, it's an error
|
||||
@@ -11815,6 +11818,7 @@ UINT PsRadiusServerSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
StrCpy(t.RadiusServerName, sizeof(t.RadiusServerName), host);
|
||||
StrCpy(t.RadiusSecret, sizeof(t.RadiusSecret), GetParamStr(o, "SECRET"));
|
||||
t.RadiusRetryInterval = GetParamInt(o, "RETRY_INTERVAL");
|
||||
// t.RadiusRetryTimeout = GetParamInt(o, "RETRY_TIMEOUT");
|
||||
|
||||
Free(host);
|
||||
|
||||
@@ -11938,6 +11942,9 @@ UINT PsRadiusServerGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
|
||||
UniToStri(tmp, t.RadiusRetryInterval);
|
||||
CtInsert(ct, _UU("CMD_RadiusServerGet_RetryInterval"), tmp);
|
||||
|
||||
UniToStri(tmp, t.RadiusRetryTimeout);
|
||||
CtInsert(ct, _UU("CMD_RadiusServerGet_RetryTimeout"), tmp);
|
||||
}
|
||||
|
||||
CtFree(ct, c);
|
||||
|
||||
+31
-10
@@ -99,6 +99,7 @@ EAP_CLIENT *HubNewEapClient(CEDAR *cedar, char *hubname, char *client_ip_str, ch
|
||||
char radius_servers[MAX_PATH] = {0};
|
||||
UINT radius_port = 0;
|
||||
UINT radius_retry_interval = 0;
|
||||
UINT radius_retry_timeout = 0;
|
||||
char radius_secret[MAX_PATH] = {0};
|
||||
char radius_suffix_filter[MAX_PATH] = {0};
|
||||
if (cedar == NULL || hubname == NULL || client_ip_str == NULL || username == NULL)
|
||||
@@ -115,8 +116,8 @@ EAP_CLIENT *HubNewEapClient(CEDAR *cedar, char *hubname, char *client_ip_str, ch
|
||||
|
||||
if (hub != NULL)
|
||||
{
|
||||
if (GetRadiusServerEx2(hub, radius_servers, sizeof(radius_servers), &radius_port, radius_secret,
|
||||
sizeof(radius_secret), &radius_retry_interval, radius_suffix_filter, sizeof(radius_suffix_filter)))
|
||||
if (GetRadiusServerEx3(hub, radius_servers, sizeof(radius_servers), &radius_port, radius_secret,
|
||||
sizeof(radius_secret), &radius_retry_interval, &radius_retry_timeout, radius_suffix_filter, sizeof(radius_suffix_filter)))
|
||||
{
|
||||
bool use_peap = hub->RadiusUsePeapInsteadOfEap;
|
||||
|
||||
@@ -6415,17 +6416,23 @@ void ReleaseHub(HUB *h)
|
||||
bool GetRadiusServer(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size)
|
||||
{
|
||||
UINT interval;
|
||||
|
||||
return GetRadiusServerEx(hub, name, size, port, secret, secret_size, &interval);
|
||||
}
|
||||
bool GetRadiusServerEx(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval)
|
||||
{
|
||||
return GetRadiusServerEx2(hub, name, size, port, secret, secret_size, interval, NULL, 0);
|
||||
bool GetRadiusServerEx(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval) {
|
||||
UINT timeout;
|
||||
|
||||
return GetRadiusServerEx2(hub, name, size, port, secret, secret_size, interval, timeout);
|
||||
}
|
||||
bool GetRadiusServerEx2(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, char *suffix_filter, UINT suffix_filter_size)
|
||||
bool GetRadiusServerEx2(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, UINT *timeout)
|
||||
{
|
||||
return GetRadiusServerEx3(hub, name, size, port, secret, secret_size, interval, timeout, NULL, 0);
|
||||
}
|
||||
bool GetRadiusServerEx3(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, UINT *timeout, char *suffix_filter, UINT suffix_filter_size)
|
||||
{
|
||||
bool ret = false;
|
||||
// Validate arguments
|
||||
if (hub == NULL || name == NULL || port == NULL || secret == NULL || interval == NULL)
|
||||
if (hub == NULL || name == NULL || port == NULL || secret == NULL || interval == NULL || timeout == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -6439,6 +6446,7 @@ bool GetRadiusServerEx2(HUB *hub, char *name, UINT size, UINT *port, char *secre
|
||||
StrCpy(name, size, hub->RadiusServerName);
|
||||
*port = hub->RadiusServerPort;
|
||||
*interval = hub->RadiusRetryInterval;
|
||||
*timeout = hub->RadiusRetryTimeout;
|
||||
|
||||
tmp_size = hub->RadiusSecret->Size + 1;
|
||||
tmp = ZeroMalloc(tmp_size);
|
||||
@@ -6465,6 +6473,10 @@ void SetRadiusServer(HUB *hub, char *name, UINT port, char *secret)
|
||||
SetRadiusServerEx(hub, name, port, secret, RADIUS_RETRY_INTERVAL);
|
||||
}
|
||||
void SetRadiusServerEx(HUB *hub, char *name, UINT port, char *secret, UINT interval)
|
||||
{
|
||||
SetRadiusServerEx2(hub, name, port, secret, interval, RADIUS_RETRY_TIMEOUT);
|
||||
}
|
||||
void SetRadiusServerEx2(HUB *hub, char *name, UINT port, char *secret, UINT interval, UINT timeout)
|
||||
{
|
||||
// Validate arguments
|
||||
if (hub == NULL)
|
||||
@@ -6484,19 +6496,28 @@ void SetRadiusServerEx(HUB *hub, char *name, UINT port, char *secret, UINT inter
|
||||
hub->RadiusServerName = NULL;
|
||||
hub->RadiusServerPort = 0;
|
||||
hub->RadiusRetryInterval = RADIUS_RETRY_INTERVAL;
|
||||
hub->RadiusRetryTimeout = RADIUS_RETRY_TIMEOUT;
|
||||
|
||||
FreeBuf(hub->RadiusSecret);
|
||||
}
|
||||
else
|
||||
{
|
||||
hub->RadiusServerName = CopyStr(name);
|
||||
hub->RadiusServerPort = port;
|
||||
|
||||
if (timeout == 0) {
|
||||
timeout = RADIUS_RETRY_TIMEOUT;
|
||||
}
|
||||
hub->RadiusRetryTimeout = timeout;
|
||||
|
||||
if (interval == 0)
|
||||
{
|
||||
hub->RadiusRetryInterval = RADIUS_RETRY_INTERVAL;
|
||||
hub->RadiusRetryInterval = RADIUS_RETRY_INTERVAL; ///What happens here is that RADIUS_RETRY_TIMEOUT is not configurable, and RADIUS_RETRY_INTERVAL is set to the timeout if it's larger.
|
||||
}
|
||||
else if (interval > RADIUS_RETRY_TIMEOUT)
|
||||
|
||||
if (interval > timeout)
|
||||
{
|
||||
hub->RadiusRetryInterval = RADIUS_RETRY_TIMEOUT;
|
||||
hub->RadiusRetryInterval = timeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+4
-1
@@ -341,6 +341,7 @@ struct HUB
|
||||
char *RadiusServerName; // Radius server name
|
||||
UINT RadiusServerPort; // Radius server port number
|
||||
UINT RadiusRetryInterval; // Radius retry interval
|
||||
UINT RadiusRetryTimeout; // Radius timeout, it will no longer retry
|
||||
BUF *RadiusSecret; // Radius shared key
|
||||
char RadiusSuffixFilter[MAX_SIZE]; // Radius suffix filter
|
||||
char RadiusRealm[MAX_SIZE]; // Radius realm (optional)
|
||||
@@ -482,9 +483,11 @@ void GetAccessListStr(char *str, UINT size, ACCESS *a);
|
||||
void DeleteOldIpTableEntry(LIST *o);
|
||||
void SetRadiusServer(HUB *hub, char *name, UINT port, char *secret);
|
||||
void SetRadiusServerEx(HUB *hub, char *name, UINT port, char *secret, UINT interval);
|
||||
void SetRadiusServerEx2(HUB *hub, char *name, UINT port, char *secret, UINT interval, UINT timeout);
|
||||
bool GetRadiusServer(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size);
|
||||
bool GetRadiusServerEx(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval);
|
||||
bool GetRadiusServerEx2(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, char *suffix_filter, UINT suffix_filter_size);
|
||||
bool GetRadiusServerEx2(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, UINT *timeout);
|
||||
bool GetRadiusServerEx3(HUB *hub, char *name, UINT size, UINT *port, char *secret, UINT secret_size, UINT *interval, UINT *timeout, char *suffix_filter, UINT suffix_filter_size);
|
||||
int CompareCert(void *p1, void *p2);
|
||||
void GetHubLogSetting(HUB *h, HUB_LOG *setting);
|
||||
void SetHubLogSetting(HUB *h, HUB_LOG *setting);
|
||||
|
||||
+19
-1
@@ -5429,7 +5429,7 @@ void ClientUploadNoop(CONNECTION *c)
|
||||
}
|
||||
|
||||
p = PackError(0);
|
||||
PackAddInt(p, "noop", 1);
|
||||
PackAddInt(p, "noop", NOOP);
|
||||
(void)HttpClientSend(c->FirstSock, p);
|
||||
FreePack(p);
|
||||
|
||||
@@ -5440,6 +5440,24 @@ void ClientUploadNoop(CONNECTION *c)
|
||||
}
|
||||
}
|
||||
|
||||
void ServerUploadNoop(CONNECTION *c)
|
||||
{
|
||||
PACK *p;
|
||||
// Validate arguments
|
||||
if (c == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p = PackError(0);
|
||||
PackAddInt(p, "noop", NOOP_IGNORE);
|
||||
(void)HttpServerSend(c->FirstSock, p);
|
||||
FreePack(p);
|
||||
|
||||
// Client can't re-respond to an HTTP "response"
|
||||
// so we don't wait for it on the server side
|
||||
}
|
||||
|
||||
// Add client version information to the PACK
|
||||
void PackAddClientVersion(PACK *p, CONNECTION *c)
|
||||
{
|
||||
|
||||
@@ -169,6 +169,7 @@ bool GetSessionKeyFromPack(PACK *p, UCHAR *session_key, UINT *session_key_32);
|
||||
void CreateNodeInfo(NODE_INFO *info, CONNECTION *c);
|
||||
UINT SecureSign(SECURE_SIGN *sign, UINT device_id, char *pin);
|
||||
void ClientUploadNoop(CONNECTION *c);
|
||||
void ServerUploadNoop(CONNECTION *c);
|
||||
bool ClientCheckServerCert(CONNECTION *c, bool *expired);
|
||||
void ClientCheckServerCertThread(THREAD *thread, void *param);
|
||||
bool ClientSecureSign(CONNECTION *c, UCHAR *sign, UCHAR *random, X **x);
|
||||
|
||||
+15
-4
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Radius.h"
|
||||
|
||||
#include "Protocol.h"
|
||||
#include "Connection.h"
|
||||
#include "IPC.h"
|
||||
#include "Server.h"
|
||||
@@ -1767,7 +1768,7 @@ LABEL_ERROR:
|
||||
////////// Classical implementation
|
||||
|
||||
// Attempts Radius authentication (with specifying retry interval and multiple server)
|
||||
bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT secret_size, wchar_t *username, char *password, UINT interval, UCHAR *mschap_v2_server_response_20,
|
||||
bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT secret_size, wchar_t *username, char *password, UINT interval, UINT timeout, UCHAR *mschap_v2_server_response_20,
|
||||
RADIUS_LOGIN_OPTION *opt, char *hubname)
|
||||
{
|
||||
UCHAR random[MD5_SIZE];
|
||||
@@ -2072,14 +2073,22 @@ bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT sec
|
||||
|
||||
// Transmission process start
|
||||
start = Tick64();
|
||||
|
||||
// Limit timeout to be larger than hardcoded timeout
|
||||
// Limit interval to be larger than the hardcoded interval and less than timeout
|
||||
if (timeout < RADIUS_RETRY_TIMEOUT) {
|
||||
timeout = RADIUS_RETRY_TIMEOUT;
|
||||
}
|
||||
|
||||
if(interval < RADIUS_RETRY_INTERVAL)
|
||||
{
|
||||
interval = RADIUS_RETRY_INTERVAL;
|
||||
}
|
||||
else if(interval > RADIUS_RETRY_TIMEOUT)
|
||||
else if(interval > timeout)
|
||||
{
|
||||
interval = RADIUS_RETRY_TIMEOUT;
|
||||
interval = timeout;
|
||||
}
|
||||
|
||||
next_send_time = start + (UINT64)interval;
|
||||
|
||||
while (true)
|
||||
@@ -2099,6 +2108,8 @@ SEND_RETRY:
|
||||
next_send_time = Tick64() + (UINT64)interval;
|
||||
|
||||
RECV_RETRY:
|
||||
ServerUploadNoop(c);
|
||||
|
||||
now = Tick64();
|
||||
if (next_send_time <= now)
|
||||
{
|
||||
@@ -2109,7 +2120,7 @@ RECV_RETRY:
|
||||
goto SEND_RETRY;
|
||||
}
|
||||
|
||||
if ((start + RADIUS_RETRY_TIMEOUT) < now)
|
||||
if ((start + timeout) < now)
|
||||
{
|
||||
// Time-out
|
||||
break;
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ struct RADIUS_LOGIN_OPTION
|
||||
};
|
||||
|
||||
// Function prototype
|
||||
bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT secret_size, wchar_t *username, char *password, UINT interval, UCHAR *mschap_v2_server_response_20,
|
||||
bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT secret_size, wchar_t *username, char *password, UINT interval, UINT timeout, UCHAR *mschap_v2_server_response_20,
|
||||
RADIUS_LOGIN_OPTION *opt, char *hubname);
|
||||
BUF *RadiusEncryptPassword(char *password, UCHAR *random, UCHAR *secret, UINT secret_size);
|
||||
BUF *RadiusCreateUserName(wchar_t *username);
|
||||
|
||||
+3
-2
@@ -516,6 +516,7 @@ bool SamAuthUserByPlainPassword(CONNECTION *c, HUB *hub, char *username, char *p
|
||||
char suffix_filter[MAX_SIZE];
|
||||
wchar_t suffix_filter_w[MAX_SIZE];
|
||||
UINT interval;
|
||||
UINT timeout;
|
||||
EAP_CLIENT *eap = NULL;
|
||||
char password1[MAX_SIZE];
|
||||
UCHAR client_challenge[16];
|
||||
@@ -586,7 +587,7 @@ bool SamAuthUserByPlainPassword(CONNECTION *c, HUB *hub, char *username, char *p
|
||||
}
|
||||
|
||||
// Get the Radius server information
|
||||
if (GetRadiusServerEx2(hub, radius_server_addr, sizeof(radius_server_addr), &radius_server_port, radius_secret, sizeof(radius_secret), &interval, suffix_filter, sizeof(suffix_filter)))
|
||||
if (GetRadiusServerEx3(hub, radius_server_addr, sizeof(radius_server_addr), &radius_server_port, radius_secret, sizeof(radius_secret), &interval, &timeout, suffix_filter, sizeof(suffix_filter)))
|
||||
{
|
||||
Unlock(hub->lock);
|
||||
|
||||
@@ -597,7 +598,7 @@ bool SamAuthUserByPlainPassword(CONNECTION *c, HUB *hub, char *username, char *p
|
||||
// Attempt to login
|
||||
b = RadiusLogin(c, radius_server_addr, radius_server_port,
|
||||
radius_secret, StrLen(radius_secret),
|
||||
name, password, interval, mschap_v2_server_response_20, opt, hub->Name);
|
||||
name, password, interval, timeout, mschap_v2_server_response_20, opt, hub->Name);
|
||||
|
||||
if (b)
|
||||
{
|
||||
|
||||
+8
-1
@@ -4855,6 +4855,7 @@ void SiWriteHubCfg(FOLDER *f, HUB *h)
|
||||
}
|
||||
CfgAddInt(f, "RadiusServerPort", h->RadiusServerPort);
|
||||
CfgAddInt(f, "RadiusRetryInterval", h->RadiusRetryInterval);
|
||||
CfgAddInt(f, "RadiusRetryTimeout", h->RadiusRetryTimeout);
|
||||
CfgAddStr(f, "RadiusSuffixFilter", h->RadiusSuffixFilter);
|
||||
CfgAddStr(f, "RadiusRealm", h->RadiusRealm);
|
||||
|
||||
@@ -5020,9 +5021,11 @@ void SiLoadHubCfg(SERVER *s, FOLDER *f, char *name)
|
||||
BUF *secret;
|
||||
UINT port;
|
||||
UINT interval;
|
||||
UINT timeout;
|
||||
|
||||
port = CfgGetInt(f, "RadiusServerPort");
|
||||
interval = CfgGetInt(f, "RadiusRetryInterval");
|
||||
timeout = CfgGetInt(f, "RadiusRetryTimeout");
|
||||
|
||||
CfgGetStr(f, "RadiusSuffixFilter", h->RadiusSuffixFilter, sizeof(h->RadiusSuffixFilter));
|
||||
CfgGetStr(f, "RadiusRealm", h->RadiusRealm, sizeof(h->RadiusRealm));
|
||||
@@ -5035,6 +5038,10 @@ void SiLoadHubCfg(SERVER *s, FOLDER *f, char *name)
|
||||
interval = RADIUS_RETRY_INTERVAL;
|
||||
}
|
||||
|
||||
if (timeout == 0) {
|
||||
timeout = RADIUS_RETRY_TIMEOUT;
|
||||
}
|
||||
|
||||
if (port != 0 && CfgGetStr(f, "RadiusServerName", name, sizeof(name)))
|
||||
{
|
||||
secret = CfgGetBuf(f, "RadiusSecret");
|
||||
@@ -5048,7 +5055,7 @@ void SiLoadHubCfg(SERVER *s, FOLDER *f, char *name)
|
||||
}
|
||||
secret_str[sizeof(secret_str) - 1] = 0;
|
||||
//SetRadiusServer(h, name, port, secret_str);
|
||||
SetRadiusServerEx(h, name, port, secret_str, interval);
|
||||
SetRadiusServerEx2(h, name, port, secret_str, interval, timeout);
|
||||
FreeBuf(secret);
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -1207,12 +1207,14 @@ PACK *HttpClientRecv(SOCK *s)
|
||||
UINT size;
|
||||
UCHAR *tmp;
|
||||
HTTP_VALUE *v;
|
||||
UINT num_noop = 0;
|
||||
// Validate arguments
|
||||
if (s == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
START:
|
||||
h = RecvHttpHeader(s);
|
||||
if (h == NULL)
|
||||
{
|
||||
@@ -1257,6 +1259,22 @@ PACK *HttpClientRecv(SOCK *s)
|
||||
p = BufToPack(b);
|
||||
FreeBuf(b);
|
||||
|
||||
// Client shouldn't receive a noop other than NOOP_IGNORE
|
||||
// because it can't respond without a full new HTTP request
|
||||
UINT noop = PackGetInt(p, "noop");
|
||||
if (noop == NOOP_IGNORE) {
|
||||
Debug("recv: noop ignore\n");
|
||||
FreePack(p);
|
||||
|
||||
num_noop++;
|
||||
|
||||
if (num_noop > MAX_NOOP_PER_SESSION)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
goto START;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1365,13 +1383,14 @@ START:
|
||||
FreeBuf(b);
|
||||
|
||||
// Determine whether it's a NOOP
|
||||
if (PackGetInt(p, "noop") != 0)
|
||||
UINT noop = PackGetInt(p, "noop");
|
||||
if (noop == NOOP)
|
||||
{
|
||||
Debug("recv: noop\n");
|
||||
FreePack(p);
|
||||
|
||||
p = PackError(0);
|
||||
PackAddInt(p, "noop", 1);
|
||||
PackAddInt(p, "noop", NOOP_IGNORE);
|
||||
if (HttpServerSend(s, p) == false)
|
||||
{
|
||||
FreePack(p);
|
||||
@@ -1387,6 +1406,11 @@ START:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
goto START;
|
||||
} else if (noop == NOOP_IGNORE) {
|
||||
Debug("recv: noop ignore\n");
|
||||
FreePack(p);
|
||||
|
||||
goto START;
|
||||
}
|
||||
|
||||
|
||||
@@ -881,8 +881,6 @@ struct SSL_VERIFY_OPTION
|
||||
X *SavedCert; // Saved server certificate
|
||||
};
|
||||
|
||||
#define SSL_DEFAULT_CONNECT_TIMEOUT (15 * 1000) // SSL default timeout
|
||||
|
||||
// Header for TCP Pair
|
||||
struct TCP_PAIR_HEADER
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
// The number of allowable NOOP
|
||||
#define MAX_NOOP_PER_SESSION 30
|
||||
#define NOOP 1
|
||||
#define NOOP_IGNORE 2 // A noop, but don't send a response noop
|
||||
|
||||
// VALUE object
|
||||
struct VALUE
|
||||
|
||||
Reference in New Issue
Block a user