mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-07 00:04:57 +03:00
Cedar: remove "NicDownOnDisconnect" option
SoftEther VPN originally created the NIC in the UP state and never changed it, even when the the client was not connected.
The behavior was changed in 59e1483dbf
, which also added the NicDownOnDisconnect option
The option was disabled by default for backwards compatibility with scripts that don't check whether the NIC is down, but it's not ideal.
This commit forces the correct behavior and removes the commands "TUNDownOnDisconnectEnable", "TUNDownOnDisconnectDisable" and "TUNDownOnDisconnectGet".
This commit is contained in:
@ -3660,7 +3660,6 @@ void InRpcClientConfig(CLIENT_CONFIG *c, PACK *p)
|
||||
c->KeepConnectProtocol = PackGetInt(p, "KeepConnectProtocol");
|
||||
c->KeepConnectInterval = PackGetInt(p, "KeepConnectInterval");
|
||||
c->AllowRemoteConfig = PackGetInt(p, "AllowRemoteConfig") == 0 ? false : true;
|
||||
c->NicDownOnDisconnect = PackGetBool(p, "NicDownOnDisconnect");
|
||||
PackGetStr(p, "KeepConnectHost", c->KeepConnectHost, sizeof(c->KeepConnectHost));
|
||||
}
|
||||
void OutRpcClientConfig(PACK *p, CLIENT_CONFIG *c)
|
||||
@ -3676,7 +3675,6 @@ void OutRpcClientConfig(PACK *p, CLIENT_CONFIG *c)
|
||||
PackAddInt(p, "KeepConnectProtocol", c->KeepConnectProtocol);
|
||||
PackAddInt(p, "KeepConnectInterval", c->KeepConnectInterval);
|
||||
PackAddInt(p, "AllowRemoteConfig", c->AllowRemoteConfig);
|
||||
PackAddBool(p, "NicDownOnDisconnect", c->NicDownOnDisconnect);
|
||||
PackAddStr(p, "KeepConnectHost", c->KeepConnectHost);
|
||||
}
|
||||
|
||||
@ -6445,7 +6443,7 @@ bool CtConnect(CLIENT *c, RPC_CLIENT_CONNECT *connect)
|
||||
|
||||
CLog(c, "LC_CONNECT", connect->AccountName);
|
||||
|
||||
r->ClientSession = NewClientSessionEx(c->Cedar, r->ClientOption, r->ClientAuth, pa, r, &c->Config.NicDownOnDisconnect);
|
||||
r->ClientSession = NewClientSessionEx(c->Cedar, r->ClientOption, r->ClientAuth, pa, r);
|
||||
Notify(r->ClientSession, CLIENT_NOTIFY_ACCOUNT_CHANGED);
|
||||
|
||||
ret = true;
|
||||
@ -6762,14 +6760,9 @@ bool CtSetClientConfig(CLIENT *c, CLIENT_CONFIG *o)
|
||||
// Apply TAP state
|
||||
LockList(c->AccountList);
|
||||
LockList(c->UnixVLanList);
|
||||
if (o->NicDownOnDisconnect)
|
||||
{
|
||||
CtVLansDown(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
CtVLansUp(c);
|
||||
}
|
||||
|
||||
CtVLansDown(c);
|
||||
|
||||
UnlockList(c->UnixVLanList);
|
||||
UnlockList(c->AccountList);
|
||||
|
||||
@ -8183,7 +8176,7 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create)
|
||||
StrCpy(r->Name, sizeof(r->Name), create->DeviceName);
|
||||
|
||||
// Create a TUN
|
||||
if (UnixVLanCreate(r->Name, r->MacAddress, !c->Config.NicDownOnDisconnect) == false)
|
||||
if (UnixVLanCreate(r->Name, r->MacAddress, false) == false)
|
||||
{
|
||||
// Failure
|
||||
Free(r);
|
||||
@ -9236,7 +9229,6 @@ void CiLoadClientConfig(CLIENT_CONFIG *c, FOLDER *f)
|
||||
c->AllowRemoteConfig = CfgGetBool(f, "AllowRemoteConfig");
|
||||
c->KeepConnectInterval = MAKESURE(CfgGetInt(f, "KeepConnectInterval"), KEEP_INTERVAL_MIN, KEEP_INTERVAL_MAX);
|
||||
c->NoChangeWcmNetworkSettingOnWindows8 = CfgGetBool(f, "NoChangeWcmNetworkSettingOnWindows8");
|
||||
c->NicDownOnDisconnect = CfgGetBool(f, "NicDownOnDisconnect");
|
||||
}
|
||||
|
||||
// Read the client authentication data
|
||||
@ -9566,7 +9558,7 @@ void CiLoadVLan(CLIENT *c, FOLDER *f)
|
||||
Add(c->UnixVLanList, v);
|
||||
|
||||
#ifdef OS_UNIX
|
||||
UnixVLanCreate(v->Name, v->MacAddress, !c->Config.NicDownOnDisconnect);
|
||||
UnixVLanCreate(v->Name, v->MacAddress, false);
|
||||
#endif // OS_UNIX
|
||||
}
|
||||
|
||||
@ -9682,7 +9674,7 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root)
|
||||
UNIX_VLAN *uv;
|
||||
|
||||
// Create a Tap for MacOS X
|
||||
if (UnixVLanCreate(CLIENT_MACOS_TAP_NAME, NULL, !c->Config.NicDownOnDisconnect) == false)
|
||||
if (UnixVLanCreate(CLIENT_MACOS_TAP_NAME, NULL, false) == false)
|
||||
{
|
||||
// Fail (abort)
|
||||
CLog(c, "LC_TAP_NOT_FOUND");
|
||||
@ -9792,7 +9784,6 @@ void CiWriteClientConfig(FOLDER *cc, CLIENT_CONFIG *config)
|
||||
CfgAddBool(cc, "AllowRemoteConfig", config->AllowRemoteConfig);
|
||||
CfgAddInt(cc, "KeepConnectInterval", config->KeepConnectInterval);
|
||||
CfgAddBool(cc, "NoChangeWcmNetworkSettingOnWindows8", config->NoChangeWcmNetworkSettingOnWindows8);
|
||||
CfgAddBool(cc, "NicDownOnDisconnect", config->NicDownOnDisconnect);
|
||||
}
|
||||
|
||||
// Write the client authentication data
|
||||
|
@ -90,7 +90,6 @@ struct CLIENT_CONFIG
|
||||
UINT KeepConnectProtocol; // Protocol
|
||||
UINT KeepConnectInterval; // Interval
|
||||
bool NoChangeWcmNetworkSettingOnWindows8; // Don't change the WCM network settings on Windows 8
|
||||
bool NicDownOnDisconnect; // Put NIC down on disconnect/connection loss and put it up again after connecting to VPN server
|
||||
};
|
||||
|
||||
// Version acquisition
|
||||
|
@ -2978,9 +2978,6 @@ void PcMain(PC *pc)
|
||||
{"AccountImport", PcAccountImport},
|
||||
{"RemoteEnable", PcRemoteEnable},
|
||||
{"RemoteDisable", PcRemoteDisable},
|
||||
{"TUNDownOnDisconnectEnable", PcTunDownOnDisconnectEnable},
|
||||
{"TUNDownOnDisconnectDisable", PcTunDownOnDisconnectDisable},
|
||||
{"TUNDownOnDisconnectGet", PcTunDownOnDisconnectGet},
|
||||
{"KeepEnable", PcKeepEnable},
|
||||
{"KeepDisable", PcKeepDisable},
|
||||
{"KeepSet", PcKeepSet},
|
||||
@ -6947,135 +6944,6 @@ UINT PcRemoteDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Enable turning TUN interface up/down on client connect/disconnect
|
||||
UINT PcTunDownOnDisconnectEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
{
|
||||
LIST *o;
|
||||
PC *pc = (PC *)param;
|
||||
UINT ret = ERR_NO_ERROR;
|
||||
CLIENT_CONFIG t;
|
||||
|
||||
// Get the parameter list
|
||||
o = ParseCommandList(c, cmd_name, str, NULL, 0);
|
||||
if (o == NULL)
|
||||
{
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// RPC call
|
||||
Zero(&t, sizeof(t));
|
||||
|
||||
ret = CcGetClientConfig(pc->RemoteClient, &t);
|
||||
|
||||
if (ret == ERR_NO_ERROR)
|
||||
{
|
||||
// Change the settings
|
||||
t.NicDownOnDisconnect = true;
|
||||
ret = CcSetClientConfig(pc->RemoteClient, &t);
|
||||
}
|
||||
|
||||
if (ret == ERR_NO_ERROR)
|
||||
{
|
||||
// Success
|
||||
}
|
||||
|
||||
if (ret != ERR_NO_ERROR)
|
||||
{
|
||||
// Error has occurred
|
||||
CmdPrintError(c, ret);
|
||||
}
|
||||
|
||||
// Release of the parameter list
|
||||
FreeParamValueList(o);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Disable turning TUN interface up/down on client connect/disconnect
|
||||
UINT PcTunDownOnDisconnectDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
{
|
||||
LIST *o;
|
||||
PC *pc = (PC *)param;
|
||||
UINT ret = ERR_NO_ERROR;
|
||||
CLIENT_CONFIG t;
|
||||
|
||||
// Get the parameter list
|
||||
o = ParseCommandList(c, cmd_name, str, NULL, 0);
|
||||
if (o == NULL)
|
||||
{
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// RPC call
|
||||
Zero(&t, sizeof(t));
|
||||
|
||||
ret = CcGetClientConfig(pc->RemoteClient, &t);
|
||||
|
||||
if (ret == ERR_NO_ERROR)
|
||||
{
|
||||
// Change the settings
|
||||
t.NicDownOnDisconnect = false;
|
||||
ret = CcSetClientConfig(pc->RemoteClient, &t);
|
||||
}
|
||||
|
||||
if (ret == ERR_NO_ERROR)
|
||||
{
|
||||
// Success
|
||||
}
|
||||
|
||||
if (ret != ERR_NO_ERROR)
|
||||
{
|
||||
// Error has occurred
|
||||
CmdPrintError(c, ret);
|
||||
}
|
||||
|
||||
// Release of the parameter list
|
||||
FreeParamValueList(o);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get status of turning TUN interface up/down on client connect/disconnect
|
||||
UINT PcTunDownOnDisconnectGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
{
|
||||
LIST *o;
|
||||
PC *pc = (PC *)param;
|
||||
UINT ret = ERR_NO_ERROR;
|
||||
CLIENT_CONFIG t;
|
||||
|
||||
o = ParseCommandList(c, cmd_name, str, NULL, 0);
|
||||
if (o == NULL)
|
||||
{
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// RPC call
|
||||
Zero(&t, sizeof(t));
|
||||
|
||||
ret = CcGetClientConfig(pc->RemoteClient, &t);
|
||||
|
||||
if (ret == ERR_NO_ERROR)
|
||||
{
|
||||
CT *ct = CtNewStandard();
|
||||
|
||||
CtInsert(ct, _UU("CMD_TUNDownOnDisconnectGet_COLUMN1"),
|
||||
t.NicDownOnDisconnect ? _UU("SM_ACCESS_ENABLE") : _UU("SM_ACCESS_DISABLE"));
|
||||
|
||||
CtFree(ct, c);
|
||||
}
|
||||
|
||||
if (ret != ERR_NO_ERROR)
|
||||
{
|
||||
// Error has occurred
|
||||
CmdPrintError(c, ret);
|
||||
}
|
||||
|
||||
// Release of the parameter list
|
||||
FreeParamValueList(o);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Enable the maintenance function of the Internet connection
|
||||
UINT PcKeepEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
{
|
||||
|
@ -377,9 +377,6 @@ UINT PcAccountExport(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcAccountImport(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcRemoteEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcRemoteDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcTunDownOnDisconnectEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcTunDownOnDisconnectDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcTunDownOnDisconnectGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcKeepEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcKeepDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
UINT PcKeepSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param);
|
||||
|
@ -506,7 +506,7 @@ void StartLink(LINK *k)
|
||||
pa->Param = (void *)k;
|
||||
LockLink(k);
|
||||
{
|
||||
k->ClientSession = NewClientSession(k->Cedar, k->Option, k->Auth, pa, NULL);
|
||||
k->ClientSession = NewClientSession(k->Cedar, k->Option, k->Auth, pa);
|
||||
}
|
||||
UnlockLink(k);
|
||||
}
|
||||
|
@ -5008,15 +5008,9 @@ REDIRECTED:
|
||||
}
|
||||
|
||||
PrintStatus(sess, _UU("STATUS_9"));
|
||||
|
||||
#ifdef OS_UNIX
|
||||
// Set TUN up if session has NicDownOnDisconnect set
|
||||
if (c->Session->NicDownOnDisconnect != NULL)
|
||||
{
|
||||
UnixVLanSetState(c->Session->ClientOption->DeviceName, true);
|
||||
}
|
||||
UnixVLanSetState(c->Session->ClientOption->DeviceName, true);
|
||||
#endif
|
||||
|
||||
// Shift the connection to the tunneling mode
|
||||
StartTunnelingMode(c);
|
||||
s = NULL;
|
||||
|
@ -1266,14 +1266,9 @@ void CleanupSession(SESSION *s)
|
||||
{
|
||||
FreePacketAdapter(s->PacketAdapter);
|
||||
}
|
||||
|
||||
#ifdef OS_UNIX
|
||||
if (s->NicDownOnDisconnect != NULL && *s->NicDownOnDisconnect)
|
||||
{
|
||||
UnixVLanSetState(s->ClientOption->DeviceName, false);
|
||||
}
|
||||
UnixVLanSetState(s->ClientOption->DeviceName, false);
|
||||
#endif
|
||||
|
||||
if (s->OldTraffic != NULL)
|
||||
{
|
||||
FreeTraffic(s->OldTraffic);
|
||||
@ -1423,14 +1418,9 @@ void ClientThread(THREAD *t, void *param)
|
||||
|
||||
CLog(s->Cedar->Client, "LC_CONNECT_ERROR", s->ClientOption->AccountName,
|
||||
GetUniErrorStr(s->Err), s->Err);
|
||||
|
||||
#ifdef OS_UNIX
|
||||
if (s->NicDownOnDisconnect != NULL && *s->NicDownOnDisconnect)
|
||||
{
|
||||
UnixVLanSetState(s->ClientOption->DeviceName, false);
|
||||
}
|
||||
UnixVLanSetState(s->ClientOption->DeviceName, false);
|
||||
#endif
|
||||
|
||||
if (s->LinkModeClient && s->Link != NULL)
|
||||
{
|
||||
HLog(s->Link->Hub, "LH_CONNECT_ERROR", s->ClientOption->AccountName,
|
||||
@ -1838,7 +1828,7 @@ SESSION *NewRpcSessionEx2(CEDAR *cedar, CLIENT_OPTION *option, UINT *err, char *
|
||||
}
|
||||
|
||||
// Create a client session
|
||||
SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, ACCOUNT *account, bool *NicDownOnDisconnect)
|
||||
SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, ACCOUNT *account)
|
||||
{
|
||||
SESSION *s;
|
||||
THREAD *t;
|
||||
@ -1966,8 +1956,6 @@ SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *au
|
||||
s->ClientOption->NumRetry = 0;
|
||||
}
|
||||
|
||||
s->NicDownOnDisconnect = NicDownOnDisconnect;
|
||||
|
||||
// Create a client thread
|
||||
t = NewThread(ClientThread, (void *)s);
|
||||
WaitThreadInit(t);
|
||||
@ -1975,9 +1963,9 @@ SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *au
|
||||
|
||||
return s;
|
||||
}
|
||||
SESSION *NewClientSession(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, bool *NicDownOnDisconnect)
|
||||
SESSION *NewClientSession(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa)
|
||||
{
|
||||
return NewClientSessionEx(cedar, option, auth, pa, NULL, NicDownOnDisconnect);
|
||||
return NewClientSessionEx(cedar, option, auth, pa, NULL);
|
||||
}
|
||||
|
||||
// Get the session from the session key
|
||||
|
@ -226,8 +226,6 @@ struct SESSION
|
||||
UINT64 LastDLinkSTPPacketSendTick; // Last D-Link STP packet transmission time
|
||||
UCHAR LastDLinkSTPPacketDataHash[MD5_SIZE]; // Last D-Link STP packet hash
|
||||
|
||||
bool *NicDownOnDisconnect; // Pointer to client configuration parameter. NULL for non-clients.
|
||||
|
||||
SHARED_BUFFER *IpcSessionSharedBuffer; // A shared buffer between IPC and Session
|
||||
IPC_SESSION_SHARED_BUFFER_DATA *IpcSessionShared; // Shared data between IPC and Session
|
||||
};
|
||||
@ -305,8 +303,8 @@ struct UI_CHECKCERT
|
||||
|
||||
|
||||
// Function prototype
|
||||
SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, struct ACCOUNT *account, bool *NicDownOnDisconnect);
|
||||
SESSION *NewClientSession(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, bool *NicDownOnDisconnect);
|
||||
SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa, struct ACCOUNT *account);
|
||||
SESSION *NewClientSession(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, PACKET_ADAPTER *pa);
|
||||
SESSION *NewRpcSession(CEDAR *cedar, CLIENT_OPTION *option);
|
||||
SESSION *NewRpcSessionEx(CEDAR *cedar, CLIENT_OPTION *option, UINT *err, char *client_str);
|
||||
SESSION *NewRpcSessionEx2(CEDAR *cedar, CLIENT_OPTION *option, UINT *err, char *client_str, void *hWnd);
|
||||
|
Reference in New Issue
Block a user