added split tunneling to the config
This commit is contained in:
parent
7c8399ce88
commit
b78bf39767
6 changed files with 63 additions and 6 deletions
|
@ -43,6 +43,7 @@ namespace amnezia
|
|||
constexpr char server_priv_key[] = "server_priv_key";
|
||||
constexpr char server_pub_key[] = "server_pub_key";
|
||||
constexpr char psk_key[] = "psk_key";
|
||||
constexpr char allowed_ips[] = "allowed_ips";
|
||||
|
||||
constexpr char client_ip[] = "client_ip"; // internal ip address
|
||||
|
||||
|
@ -78,6 +79,9 @@ namespace amnezia
|
|||
constexpr char sftp[] = "sftp";
|
||||
constexpr char awg[] = "awg";
|
||||
|
||||
constexpr char splitTunnelSites[] = "splitTunnelSites";
|
||||
constexpr char splitTunnelType[] = "splitTunnelType";
|
||||
|
||||
}
|
||||
|
||||
namespace protocols
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
<context>
|
||||
<name>ImportController</name>
|
||||
<message>
|
||||
<location filename="../ui/controllers/importController.cpp" line="429"/>
|
||||
<location filename="../ui/controllers/importController.cpp" line="436"/>
|
||||
<source>Scanned %1 of %2.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -2413,10 +2413,14 @@ It's okay as long as it's from someone you trust.</source>
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="109"/>
|
||||
<location filename="../containers/containers_defs.cpp" line="112"/>
|
||||
<source>WireGuard - New popular VPN protocol with high performance, high speed and low power consumption. Recommended for regions with low levels of censorship.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="112"/>
|
||||
<source>AmneziaWG - Special protocol from Amnezia, based on WireGuard. It's fast like WireGuard, but very resistant to blockages. Recommended for regions with high levels of censorship.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="115"/>
|
||||
<source>IKEv2 - Modern stable protocol, a bit faster than others, restores connection after signal loss. It has native support on the latest versions of Android and iOS.</source>
|
||||
|
@ -2537,6 +2541,16 @@ It's okay as long as it's from someone you trust.</source>
|
|||
<source>error 0x%1: %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../3rd/wireguard-tools/contrib/highlighter/gui/highlight.cpp" line="39"/>
|
||||
<source>WireGuard Configuration Highlighter</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../3rd/wireguard-tools/contrib/highlighter/gui/highlight.cpp" line="82"/>
|
||||
<source>&Randomize colors</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SelectLanguageDrawer</name>
|
||||
|
@ -2704,7 +2718,7 @@ It's okay as long as it's from someone you trust.</source>
|
|||
<context>
|
||||
<name>VpnConnection</name>
|
||||
<message>
|
||||
<location filename="../vpnconnection.cpp" line="406"/>
|
||||
<location filename="../vpnconnection.cpp" line="422"/>
|
||||
<source>Mbps</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
<context>
|
||||
<name>ImportController</name>
|
||||
<message>
|
||||
<location filename="../ui/controllers/importController.cpp" line="429"/>
|
||||
<location filename="../ui/controllers/importController.cpp" line="436"/>
|
||||
<source>Scanned %1 of %2.</source>
|
||||
<translation>扫描 %1 of %2.</translation>
|
||||
</message>
|
||||
|
@ -2520,10 +2520,14 @@ It's okay as long as it's from someone you trust.</source>
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="109"/>
|
||||
<location filename="../containers/containers_defs.cpp" line="112"/>
|
||||
<source>WireGuard - New popular VPN protocol with high performance, high speed and low power consumption. Recommended for regions with low levels of censorship.</source>
|
||||
<translation>WireGuard - 新型流行的VPN协议,具有高性能、高速度和低功耗。建议用于审查力度较低的地区</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="112"/>
|
||||
<source>AmneziaWG - Special protocol from Amnezia, based on WireGuard. It's fast like WireGuard, but very resistant to blockages. Recommended for regions with high levels of censorship.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../containers/containers_defs.cpp" line="115"/>
|
||||
<source>IKEv2 - Modern stable protocol, a bit faster than others, restores connection after signal loss. It has native support on the latest versions of Android and iOS.</source>
|
||||
|
@ -2644,6 +2648,16 @@ It's okay as long as it's from someone you trust.</source>
|
|||
<source>error 0x%1: %2</source>
|
||||
<translation>错误 0x%1: %2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../3rd/wireguard-tools/contrib/highlighter/gui/highlight.cpp" line="39"/>
|
||||
<source>WireGuard Configuration Highlighter</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../3rd/wireguard-tools/contrib/highlighter/gui/highlight.cpp" line="82"/>
|
||||
<source>&Randomize colors</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SelectLanguageDrawer</name>
|
||||
|
@ -2815,7 +2829,7 @@ It's okay as long as it's from someone you trust.</source>
|
|||
<context>
|
||||
<name>VpnConnection</name>
|
||||
<message>
|
||||
<location filename="../vpnconnection.cpp" line="406"/>
|
||||
<location filename="../vpnconnection.cpp" line="422"/>
|
||||
<source>Mbps</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
|
|
@ -263,6 +263,13 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
|||
// return QJsonObject();
|
||||
// }
|
||||
|
||||
auto allowedIps = configMap.value("AllowedIPs").split(",");
|
||||
QJsonArray allowedIpsJsonArray;
|
||||
for (const auto &allowedIp : allowedIps) {
|
||||
allowedIpsJsonArray.append(allowedIp);
|
||||
}
|
||||
lastConfig[config_key::allowed_ips] = allowedIpsJsonArray;
|
||||
|
||||
QString protocolName = "wireguard";
|
||||
if (!configMap.value(config_key::junkPacketCount).isEmpty()
|
||||
&& !configMap.value(config_key::junkPacketMinSize).isEmpty()
|
||||
|
|
|
@ -329,6 +329,8 @@ void VpnConnection::connectToVpn(int serverIndex, const ServerCredentials &crede
|
|||
return;
|
||||
}
|
||||
|
||||
appendSplitTunnelingConfig();
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
m_vpnProtocol.reset(VpnProtocol::factory(container, m_vpnConfiguration));
|
||||
if (!m_vpnProtocol) {
|
||||
|
@ -363,6 +365,20 @@ void VpnConnection::createProtocolConnections()
|
|||
connect(m_vpnProtocol.data(), SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64)));
|
||||
}
|
||||
|
||||
void VpnConnection::appendSplitTunnelingConfig()
|
||||
{
|
||||
auto routeMode = m_settings->routeMode();
|
||||
auto sites = m_settings->getVpnIps(routeMode);
|
||||
|
||||
QJsonArray sitesJsonArray;
|
||||
for (const auto &site : sites) {
|
||||
sitesJsonArray.append(site);
|
||||
}
|
||||
|
||||
m_vpnConfiguration.insert(config_key::splitTunnelType, routeMode);
|
||||
m_vpnConfiguration.insert(config_key::splitTunnelSites, sitesJsonArray);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
void VpnConnection::restoreConnection()
|
||||
{
|
||||
|
|
|
@ -112,6 +112,8 @@ private:
|
|||
#endif
|
||||
|
||||
void createProtocolConnections();
|
||||
|
||||
void appendSplitTunnelingConfig();
|
||||
};
|
||||
|
||||
#endif // VPNCONNECTION_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue