Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into dev

This commit is contained in:
vladimir.kuznetsov 2023-10-20 21:51:40 +05:00
commit dadf0cf96e
7 changed files with 73 additions and 54 deletions

View file

@ -1,5 +1,7 @@
#include "protocols_defs.h" #include "protocols_defs.h"
#include <QRandomGenerator>
using namespace amnezia; using namespace amnezia;
QDebug operator<<(QDebug debug, const amnezia::ProtocolEnumNS::Proto &p) QDebug operator<<(QDebug debug, const amnezia::ProtocolEnumNS::Proto &p)
@ -98,15 +100,28 @@ amnezia::ServiceType ProtocolProps::protocolService(Proto p)
} }
} }
int ProtocolProps::getPortForInstall(Proto p)
{
switch (p) {
case Awg:
case WireGuard:
case ShadowSocks:
case OpenVpn:
return QRandomGenerator::global()->bounded(30000, 50000);
default:
return defaultPort(p);
}
}
int ProtocolProps::defaultPort(Proto p) int ProtocolProps::defaultPort(Proto p)
{ {
switch (p) { switch (p) {
case Proto::Any: return -1; case Proto::Any: return -1;
case Proto::OpenVpn: return 1194; case Proto::OpenVpn: return QString(protocols::openvpn::defaultPort).toInt();
case Proto::Cloak: return 443; case Proto::Cloak: return QString(protocols::cloak::defaultPort).toInt();
case Proto::ShadowSocks: return 6789; case Proto::ShadowSocks: return QString(protocols::shadowsocks::defaultPort).toInt();
case Proto::WireGuard: return 51820; case Proto::WireGuard: return QString(protocols::wireguard::defaultPort).toInt();
case Proto::Awg: return 55424; case Proto::Awg: return QString(protocols::awg::defaultPort).toInt();
case Proto::Ikev2: return -1; case Proto::Ikev2: return -1;
case Proto::L2tp: return -1; case Proto::L2tp: return -1;

View file

@ -228,6 +228,8 @@ namespace amnezia
Q_INVOKABLE static ServiceType protocolService(Proto p); Q_INVOKABLE static ServiceType protocolService(Proto p);
Q_INVOKABLE static int getPortForInstall(Proto p);
Q_INVOKABLE static int defaultPort(Proto p); Q_INVOKABLE static int defaultPort(Proto p);
Q_INVOKABLE static bool defaultPortChangeable(Proto p); Q_INVOKABLE static bool defaultPortChangeable(Proto p);

View file

@ -8,7 +8,7 @@ if ! command -v sudo > /dev/null 2>&1; then $pm update -yq; $pm install -yq sudo
if ! command -v fuser > /dev/null 2>&1; then sudo $pm install -yq psmisc; fi;\ if ! command -v fuser > /dev/null 2>&1; then sudo $pm install -yq psmisc; fi;\
if ! command -v lsof > /dev/null 2>&1; then sudo $pm install -yq lsof; fi;\ if ! command -v lsof > /dev/null 2>&1; then sudo $pm install -yq lsof; fi;\
if ! command -v docker > /dev/null 2>&1; then sudo $pm update -yq; sudo $pm install -yq $docker_pkg;\ if ! command -v docker > /dev/null 2>&1; then sudo $pm update -yq; sudo $pm install -yq $docker_pkg;\
if [ "$dist" = "fedora" ] || [ "$dist" = "debian" ]; then sudo systemctl enable docker && sudo systemctl start docker; fi;\ if [ "$dist" = "fedora" ] || [ "$dist" = "centos" ] || [ "$dist" = "debian" ]; then sudo systemctl enable docker && sudo systemctl start docker; fi;\
fi;\ fi;\
if [ "$dist" = "debian" ]; then \ if [ "$dist" = "debian" ]; then \
docker_service=$(systemctl list-units --full --all | grep docker.service | grep -v inactive | grep -v dead | grep -v failed);\ docker_service=$(systemctl list-units --full --all | grep docker.service | grep -v inactive | grep -v dead | grep -v failed);\

View file

@ -143,58 +143,58 @@
<context> <context>
<name>InstallController</name> <name>InstallController</name>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="141"/> <location filename="../ui/controllers/installController.cpp" line="143"/>
<location filename="../ui/controllers/installController.cpp" line="191"/> <location filename="../ui/controllers/installController.cpp" line="193"/>
<source>%1 installed successfully. </source> <source>%1 installed successfully. </source>
<translation>%1 успешно установлен. </translation> <translation>%1 успешно установлен. </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="143"/> <location filename="../ui/controllers/installController.cpp" line="145"/>
<location filename="../ui/controllers/installController.cpp" line="193"/> <location filename="../ui/controllers/installController.cpp" line="195"/>
<source>%1 is already installed on the server. </source> <source>%1 is already installed on the server. </source>
<translation>%1 уже установлен на сервер. </translation> <translation>%1 уже установлен на сервер. </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="146"/> <location filename="../ui/controllers/installController.cpp" line="148"/>
<source> <source>
Added containers that were already installed on the server</source> Added containers that were already installed on the server</source>
<translation> <translation>
В приложение добавлены обнаруженные на сервере протоклы и сервисы</translation> В приложение добавлены обнаруженные на сервере протоклы и сервисы</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="212"/> <location filename="../ui/controllers/installController.cpp" line="214"/>
<source> <source>
Already installed containers were found on the server. All installed containers have been added to the application</source> Already installed containers were found on the server. All installed containers have been added to the application</source>
<translation> <translation>
На сервере обнаружены установленные протоколы и сервисы, все они добавлены в приложение</translation> На сервере обнаружены установленные протоколы и сервисы, все они добавлены в приложение</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="293"/> <location filename="../ui/controllers/installController.cpp" line="295"/>
<source>Settings updated successfully</source> <source>Settings updated successfully</source>
<translation>Настройки успешно обновлены</translation> <translation>Настройки успешно обновлены</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="308"/> <location filename="../ui/controllers/installController.cpp" line="310"/>
<source>Server &apos;%1&apos; was removed</source> <source>Server &apos;%1&apos; was removed</source>
<translation>Сервер &apos;%1&apos; был удален</translation> <translation>Сервер &apos;%1&apos; был удален</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="318"/> <location filename="../ui/controllers/installController.cpp" line="320"/>
<source>All containers from server &apos;%1&apos; have been removed</source> <source>All containers from server &apos;%1&apos; have been removed</source>
<translation>Все протоклы и сервисы были удалены с сервера &apos;%1&apos;</translation> <translation>Все протоклы и сервисы были удалены с сервера &apos;%1&apos;</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="335"/> <location filename="../ui/controllers/installController.cpp" line="337"/>
<source>%1 has been removed from the server &apos;%2&apos;</source> <source>%1 has been removed from the server &apos;%2&apos;</source>
<translation>%1 был удален с сервера &apos;%2&apos;</translation> <translation>%1 был удален с сервера &apos;%2&apos;</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="481"/> <location filename="../ui/controllers/installController.cpp" line="483"/>
<source>Please login as the user</source> <source>Please login as the user</source>
<translation>Пожалуйста, войдите в систему от имени пользователя</translation> <translation>Пожалуйста, войдите в систему от имени пользователя</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="509"/> <location filename="../ui/controllers/installController.cpp" line="511"/>
<source>Server added successfully</source> <source>Server added successfully</source>
<translation>Сервер успешно добавлен</translation> <translation>Сервер успешно добавлен</translation>
</message> </message>
@ -2636,7 +2636,7 @@ This means that AmneziaWG keeps the fast performance of the original while addin
<translation>Сервис обмена файлами Sftp - безопасный FTP-сервис</translation> <translation>Сервис обмена файлами Sftp - безопасный FTP-сервис</translation>
</message> </message>
<message> <message>
<location filename="../protocols/protocols_defs.cpp" line="75"/> <location filename="../protocols/protocols_defs.cpp" line="77"/>
<source>Sftp service</source> <source>Sftp service</source>
<translation>Сервис SFTP</translation> <translation>Сервис SFTP</translation>
</message> </message>

View file

@ -131,7 +131,7 @@
<message> <message>
<location filename="../ui/qml/Components/HomeContainersListView.qml" line="58"/> <location filename="../ui/qml/Components/HomeContainersListView.qml" line="58"/>
<source>Unable change protocol while there is an active connection</source> <source>Unable change protocol while there is an active connection</source>
<translation>Невозможно изменить протокол при наличии активного соединения</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/qml/Components/HomeContainersListView.qml" line="69"/> <location filename="../ui/qml/Components/HomeContainersListView.qml" line="69"/>
@ -162,47 +162,47 @@
<translation type="obsolete"> </translation> <translation type="obsolete"> </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="141"/> <location filename="../ui/controllers/installController.cpp" line="143"/>
<location filename="../ui/controllers/installController.cpp" line="191"/> <location filename="../ui/controllers/installController.cpp" line="193"/>
<source>%1 installed successfully. </source> <source>%1 installed successfully. </source>
<translation>%1 </translation> <translation>%1 </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="143"/> <location filename="../ui/controllers/installController.cpp" line="145"/>
<location filename="../ui/controllers/installController.cpp" line="193"/> <location filename="../ui/controllers/installController.cpp" line="195"/>
<source>%1 is already installed on the server. </source> <source>%1 is already installed on the server. </source>
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="146"/> <location filename="../ui/controllers/installController.cpp" line="148"/>
<source> <source>
Added containers that were already installed on the server</source> Added containers that were already installed on the server</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="212"/> <location filename="../ui/controllers/installController.cpp" line="214"/>
<source> <source>
Already installed containers were found on the server. All installed containers have been added to the application</source> Already installed containers were found on the server. All installed containers have been added to the application</source>
<translation> <translation>
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="293"/> <location filename="../ui/controllers/installController.cpp" line="295"/>
<source>Settings updated successfully</source> <source>Settings updated successfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="308"/> <location filename="../ui/controllers/installController.cpp" line="310"/>
<source>Server &apos;%1&apos; was removed</source> <source>Server &apos;%1&apos; was removed</source>
<translation> &apos;%1&apos;</translation> <translation> &apos;%1&apos;</translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="318"/> <location filename="../ui/controllers/installController.cpp" line="320"/>
<source>All containers from server &apos;%1&apos; have been removed</source> <source>All containers from server &apos;%1&apos; have been removed</source>
<translation> &apos;%1&apos; </translation> <translation> &apos;%1&apos; </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="335"/> <location filename="../ui/controllers/installController.cpp" line="337"/>
<source>%1 has been removed from the server &apos;%2&apos;</source> <source>%1 has been removed from the server &apos;%2&apos;</source>
<translation>%1 &apos;%2&apos; </translation> <translation>%1 &apos;%2&apos; </translation>
</message> </message>
@ -223,12 +223,12 @@ Already installed containers were found on the server. All installed containers
<translation type="obsolete"> </translation> <translation type="obsolete"> </translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="481"/> <location filename="../ui/controllers/installController.cpp" line="483"/>
<source>Please login as the user</source> <source>Please login as the user</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/controllers/installController.cpp" line="509"/> <location filename="../ui/controllers/installController.cpp" line="511"/>
<source>Server added successfully</source> <source>Server added successfully</source>
<translation></translation> <translation></translation>
</message> </message>
@ -308,7 +308,7 @@ Already installed containers were found on the server. All installed containers
<message> <message>
<location filename="../ui/qml/Pages2/PageHome.qml" line="490"/> <location filename="../ui/qml/Pages2/PageHome.qml" line="490"/>
<source>Unable change server while there is an active connection</source> <source>Unable change server while there is an active connection</source>
<translation>Невозможно изменить сервер при наличии активного соединения</translation> <translation></translation>
</message> </message>
</context> </context>
<context> <context>
@ -2335,7 +2335,7 @@ and will not be shared or disclosed to the Amnezia or any third parties</source>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../protocols/protocols_defs.cpp" line="75"/> <location filename="../protocols/protocols_defs.cpp" line="77"/>
<source>Sftp service</source> <source>Sftp service</source>
<translation>Sftp </translation> <translation>Sftp </translation>
</message> </message>

View file

@ -75,33 +75,35 @@ void InstallController::install(DockerContainer container, int port, TransportPr
ProtocolProps::transportProtoToString(transportProto, protocol)); ProtocolProps::transportProtoToString(transportProto, protocol));
if (container == DockerContainer::Awg) { if (container == DockerContainer::Awg) {
QString defaultJunkPacketCount = QString::number(QRandomGenerator::global()->bounded(3, 10)); QString junkPacketCount = QString::number(QRandomGenerator::global()->bounded(3, 10));
QString defaultJunkPacketMinSize = QString::number(50); QString junkPacketMinSize = QString::number(50);
QString defaultJunkPacketMaxSize = QString::number(1000); QString junkPacketMaxSize = QString::number(1000);
QString defaultInitPacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150)); QString initPacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150));
QString defaultResponsePacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150)); QString responsePacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150));
QSet<QString> headersValue; QSet<QString> headersValue;
while (headersValue.size() != 4) { while (headersValue.size() != 4) {
headersValue.insert(QString::number(QRandomGenerator::global()->bounded(1, std::numeric_limits<qint32>::max())));
auto max = (std::numeric_limits<qint32>::max)();
headersValue.insert(QString::number(QRandomGenerator::global()->bounded(1, max)));
} }
auto headersValueList = headersValue.values(); auto headersValueList = headersValue.values();
QString defaultInitPacketMagicHeader = headersValueList.at(0); QString initPacketMagicHeader = headersValueList.at(0);
QString defaultResponsePacketMagicHeader = headersValueList.at(1); QString responsePacketMagicHeader = headersValueList.at(1);
QString defaultUnderloadPacketMagicHeader = headersValueList.at(2); QString underloadPacketMagicHeader = headersValueList.at(2);
QString defaultTransportPacketMagicHeader = headersValueList.at(3); QString transportPacketMagicHeader = headersValueList.at(3);
containerConfig[config_key::junkPacketCount] = defaultJunkPacketCount; containerConfig[config_key::junkPacketCount] = junkPacketCount;
containerConfig[config_key::junkPacketMinSize] = defaultJunkPacketMinSize; containerConfig[config_key::junkPacketMinSize] = junkPacketMinSize;
containerConfig[config_key::junkPacketMaxSize] = defaultJunkPacketMaxSize; containerConfig[config_key::junkPacketMaxSize] = junkPacketMaxSize;
containerConfig[config_key::initPacketJunkSize] = defaultInitPacketJunkSize; containerConfig[config_key::initPacketJunkSize] = initPacketJunkSize;
containerConfig[config_key::responsePacketJunkSize] = defaultResponsePacketJunkSize; containerConfig[config_key::responsePacketJunkSize] = responsePacketJunkSize;
containerConfig[config_key::initPacketMagicHeader] = defaultInitPacketMagicHeader; containerConfig[config_key::initPacketMagicHeader] = initPacketMagicHeader;
containerConfig[config_key::responsePacketMagicHeader] = defaultResponsePacketMagicHeader; containerConfig[config_key::responsePacketMagicHeader] = responsePacketMagicHeader;
containerConfig[config_key::underloadPacketMagicHeader] = defaultUnderloadPacketMagicHeader; containerConfig[config_key::underloadPacketMagicHeader] = underloadPacketMagicHeader;
containerConfig[config_key::transportPacketMagicHeader] = defaultTransportPacketMagicHeader; containerConfig[config_key::transportPacketMagicHeader] = transportPacketMagicHeader;
} }
if (container == DockerContainer::Sftp) { if (container == DockerContainer::Sftp) {

View file

@ -224,7 +224,7 @@ PageType {
if (ProtocolProps.defaultPort(defaultContainerProto) < 0) { if (ProtocolProps.defaultPort(defaultContainerProto) < 0) {
port.visible = false port.visible = false
} else { } else {
port.textFieldText = ProtocolProps.defaultPort(defaultContainerProto) port.textFieldText = ProtocolProps.getPortForInstall(defaultContainerProto)
} }
transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto) transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto)