added generation of random values for awg parameters
This commit is contained in:
parent
e2ae341ba9
commit
79e1761c1f
4 changed files with 87 additions and 49 deletions
|
@ -490,8 +490,7 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential
|
|||
const QJsonObject &cloakConfig = config.value(ProtocolProps::protoToString(Proto::Cloak)).toObject();
|
||||
const QJsonObject &ssConfig = config.value(ProtocolProps::protoToString(Proto::ShadowSocks)).toObject();
|
||||
const QJsonObject &wireguarConfig = config.value(ProtocolProps::protoToString(Proto::WireGuard)).toObject();
|
||||
const QJsonObject &amneziaWireguarConfig =
|
||||
config.value(ProtocolProps::protoToString(Proto::Awg)).toObject();
|
||||
const QJsonObject &amneziaWireguarConfig = config.value(ProtocolProps::protoToString(Proto::Awg)).toObject();
|
||||
const QJsonObject &sftpConfig = config.value(ProtocolProps::protoToString(Proto::Sftp)).toObject();
|
||||
|
||||
Vars vars;
|
||||
|
@ -591,33 +590,21 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential
|
|||
// Amnezia wireguard vars
|
||||
vars.append({ { "$AWG_SERVER_PORT",
|
||||
amneziaWireguarConfig.value(config_key::port).toString(protocols::awg::defaultPort) } });
|
||||
vars.append({ { "$JUNK_PACKET_COUNT",
|
||||
amneziaWireguarConfig.value(config_key::junkPacketCount)
|
||||
.toString(protocols::awg::defaultJunkPacketCount) } });
|
||||
vars.append({ { "$JUNK_PACKET_MIN_SIZE",
|
||||
amneziaWireguarConfig.value(config_key::junkPacketMinSize)
|
||||
.toString(protocols::awg::defaultJunkPacketMinSize) } });
|
||||
vars.append({ { "$JUNK_PACKET_MAX_SIZE",
|
||||
amneziaWireguarConfig.value(config_key::junkPacketMaxSize)
|
||||
.toString(protocols::awg::defaultJunkPacketMaxSize) } });
|
||||
vars.append({ { "$INIT_PACKET_JUNK_SIZE",
|
||||
amneziaWireguarConfig.value(config_key::initPacketJunkSize)
|
||||
.toString(protocols::awg::defaultInitPacketJunkSize) } });
|
||||
|
||||
vars.append({ { "$JUNK_PACKET_COUNT", amneziaWireguarConfig.value(config_key::junkPacketCount).toString() } });
|
||||
vars.append({ { "$JUNK_PACKET_MIN_SIZE", amneziaWireguarConfig.value(config_key::junkPacketMinSize).toString() } });
|
||||
vars.append({ { "$JUNK_PACKET_MAX_SIZE", amneziaWireguarConfig.value(config_key::junkPacketMaxSize).toString() } });
|
||||
vars.append({ { "$INIT_PACKET_JUNK_SIZE", amneziaWireguarConfig.value(config_key::initPacketJunkSize).toString() } });
|
||||
vars.append({ { "$RESPONSE_PACKET_JUNK_SIZE",
|
||||
amneziaWireguarConfig.value(config_key::responsePacketJunkSize)
|
||||
.toString(protocols::awg::defaultResponsePacketJunkSize) } });
|
||||
amneziaWireguarConfig.value(config_key::responsePacketJunkSize).toString() } });
|
||||
vars.append({ { "$INIT_PACKET_MAGIC_HEADER",
|
||||
amneziaWireguarConfig.value(config_key::initPacketMagicHeader)
|
||||
.toString(protocols::awg::defaultInitPacketMagicHeader) } });
|
||||
amneziaWireguarConfig.value(config_key::initPacketMagicHeader).toString() } });
|
||||
vars.append({ { "$RESPONSE_PACKET_MAGIC_HEADER",
|
||||
amneziaWireguarConfig.value(config_key::responsePacketMagicHeader)
|
||||
.toString(protocols::awg::defaultResponsePacketMagicHeader) } });
|
||||
amneziaWireguarConfig.value(config_key::responsePacketMagicHeader).toString() } });
|
||||
vars.append({ { "$UNDERLOAD_PACKET_MAGIC_HEADER",
|
||||
amneziaWireguarConfig.value(config_key::underloadPacketMagicHeader)
|
||||
.toString(protocols::awg::defaultUnderloadPacketMagicHeader) } });
|
||||
amneziaWireguarConfig.value(config_key::underloadPacketMagicHeader).toString() } });
|
||||
vars.append({ { "$TRANSPORT_PACKET_MAGIC_HEADER",
|
||||
amneziaWireguarConfig.value(config_key::transportPacketMagicHeader)
|
||||
.toString(protocols::awg::defaultTransportPacketMagicHeader) } });
|
||||
amneziaWireguarConfig.value(config_key::transportPacketMagicHeader).toString() } });
|
||||
|
||||
QString serverIp = Utils::getIPAddress(credentials.hostName);
|
||||
if (!serverIp.isEmpty()) {
|
||||
|
|
|
@ -143,58 +143,58 @@
|
|||
<context>
|
||||
<name>InstallController</name>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="110"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="161"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="141"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="192"/>
|
||||
<source>%1 installed successfully. </source>
|
||||
<translation>%1 успешно установлен. </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="112"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="163"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="143"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="194"/>
|
||||
<source>%1 is already installed on the server. </source>
|
||||
<translation>%1 уже установлен на сервер. </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="115"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="146"/>
|
||||
<source>
|
||||
Added containers that were already installed on the server</source>
|
||||
<translation>
|
||||
В приложение добавлены обнаруженные на сервере протоклы и сервисы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="182"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="213"/>
|
||||
<source>
|
||||
Already installed containers were found on the server. All installed containers have been added to the application</source>
|
||||
<translation>
|
||||
На сервере обнаружены установленные протоколы и сервисы, все они добавлены в приложение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="266"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="297"/>
|
||||
<source>Settings updated successfully</source>
|
||||
<translation>Настройки успешно обновлены</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="281"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="312"/>
|
||||
<source>Server '%1' was removed</source>
|
||||
<translation>Сервер '%1' был удален</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="291"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="322"/>
|
||||
<source>All containers from server '%1' have been removed</source>
|
||||
<translation>Все протоклы и сервисы были удалены с сервера '%1'</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="308"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="339"/>
|
||||
<source>%1 has been removed from the server '%2'</source>
|
||||
<translation>%1 был удален с сервера '%2'</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="454"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="485"/>
|
||||
<source>Please login as the user</source>
|
||||
<translation>Пожалуйста, войдите в систему от имени пользователя</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="483"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="514"/>
|
||||
<source>Server added successfully</source>
|
||||
<translation>Сервер успешно добавлен</translation>
|
||||
</message>
|
||||
|
@ -2700,6 +2700,16 @@ This means that AmneziaWG keeps the fast performance of the original while addin
|
|||
<source>error 0x%1: %2</source>
|
||||
<translation>error 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>
|
||||
|
|
|
@ -162,47 +162,47 @@
|
|||
<translation type="obsolete"> 已安装在服务器上</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="110"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="161"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="141"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="192"/>
|
||||
<source>%1 installed successfully. </source>
|
||||
<translation>%1 安装成功。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="112"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="163"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="143"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="194"/>
|
||||
<source>%1 is already installed on the server. </source>
|
||||
<translation>服务器上已经安装 %1。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="115"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="146"/>
|
||||
<source>
|
||||
Added containers that were already installed on the server</source>
|
||||
<translation>添加已安装在服务器上的容器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="182"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="213"/>
|
||||
<source>
|
||||
Already installed containers were found on the server. All installed containers have been added to the application</source>
|
||||
<translation>
|
||||
在服务上发现已经安装协议并添加至应用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="266"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="297"/>
|
||||
<source>Settings updated successfully</source>
|
||||
<translation>配置更新成功</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="281"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="312"/>
|
||||
<source>Server '%1' was removed</source>
|
||||
<translation>已移除服务器 '%1'</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="291"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="322"/>
|
||||
<source>All containers from server '%1' have been removed</source>
|
||||
<translation>服务器 '%1' 的所有容器已移除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="308"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="339"/>
|
||||
<source>%1 has been removed from the server '%2'</source>
|
||||
<translation>%1 已从服务器 '%2' 上移除</translation>
|
||||
</message>
|
||||
|
@ -223,12 +223,12 @@ Already installed containers were found on the server. All installed containers
|
|||
<translation type="obsolete"> 协议已从</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="454"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="485"/>
|
||||
<source>Please login as the user</source>
|
||||
<translation>请以用户身份登录</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/controllers/installController.cpp" line="483"/>
|
||||
<location filename="../ui/controllers/installController.cpp" line="514"/>
|
||||
<source>Server added successfully</source>
|
||||
<translation>增加服务器成功</translation>
|
||||
</message>
|
||||
|
@ -2839,6 +2839,16 @@ While it offers a blend of security, stability, and speed, it's essential t
|
|||
<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>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QEventLoop>
|
||||
#include <QJsonObject>
|
||||
#include <QStandardPaths>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include "core/servercontroller.h"
|
||||
|
@ -73,6 +74,36 @@ void InstallController::install(DockerContainer container, int port, TransportPr
|
|||
containerConfig.insert(config_key::transport_proto,
|
||||
ProtocolProps::transportProtoToString(transportProto, protocol));
|
||||
|
||||
if (container == DockerContainer::Awg) {
|
||||
QString defaultJunkPacketCount = QString::number(QRandomGenerator::global()->bounded(3, 10));
|
||||
QString defaultJunkPacketMinSize = QString::number(50);
|
||||
QString defaultJunkPacketMaxSize = QString::number(1000);
|
||||
QString defaultInitPacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150));
|
||||
QString defaultResponsePacketJunkSize = QString::number(QRandomGenerator::global()->bounded(15, 150));
|
||||
|
||||
QSet<QString> headersValue;
|
||||
while (headersValue.size() != 4) {
|
||||
headersValue.insert(QString::number(QRandomGenerator::global()->bounded(1, std::numeric_limits<qint32>::max())));
|
||||
}
|
||||
|
||||
auto headersValueList = headersValue.values();
|
||||
|
||||
QString defaultInitPacketMagicHeader = headersValueList.at(0);
|
||||
QString defaultResponsePacketMagicHeader = headersValueList.at(1);
|
||||
QString defaultUnderloadPacketMagicHeader = headersValueList.at(2);
|
||||
QString defaultTransportPacketMagicHeader = headersValueList.at(3);
|
||||
|
||||
containerConfig[config_key::junkPacketCount] = defaultJunkPacketCount;
|
||||
containerConfig[config_key::junkPacketMinSize] = defaultJunkPacketMinSize;
|
||||
containerConfig[config_key::junkPacketMaxSize] = defaultJunkPacketMaxSize;
|
||||
containerConfig[config_key::initPacketJunkSize] = defaultInitPacketJunkSize;
|
||||
containerConfig[config_key::responsePacketJunkSize] = defaultResponsePacketJunkSize;
|
||||
containerConfig[config_key::initPacketMagicHeader] = defaultInitPacketMagicHeader;
|
||||
containerConfig[config_key::responsePacketMagicHeader] = defaultResponsePacketMagicHeader;
|
||||
containerConfig[config_key::underloadPacketMagicHeader] = defaultUnderloadPacketMagicHeader;
|
||||
containerConfig[config_key::transportPacketMagicHeader] = defaultTransportPacketMagicHeader;
|
||||
}
|
||||
|
||||
if (container == DockerContainer::Sftp) {
|
||||
containerConfig.insert(config_key::userName, protocols::sftp::defaultUserName);
|
||||
containerConfig.insert(config_key::password, Utils::getRandomString(10));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue