1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-14 19:54: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:
Davide Beatrici
2020-06-27 22:47:04 +02:00
parent 47d08b055e
commit 235bd07e67
15 changed files with 16 additions and 289 deletions

View File

@ -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