Various bug fixes

This commit is contained in:
pokamest 2021-06-19 16:38:35 +03:00
parent 973cbd83d9
commit b1f7baa79f
10 changed files with 30 additions and 20 deletions

View file

@ -28,6 +28,7 @@ enum ErrorCode
ServerCheckFailed, ServerCheckFailed,
ServerPortAlreadyAllocatedError, ServerPortAlreadyAllocatedError,
ServerContainerMissingError, ServerContainerMissingError,
ServerDockerFailedError,
// Ssh connection errors // Ssh connection errors
SshSocketError, SshTimeoutError, SshProtocolError, SshSocketError, SshTimeoutError, SshProtocolError,

View file

@ -13,6 +13,8 @@ QString errorString(ErrorCode code){
// Server errors // Server errors
case(ServerCheckFailed): return QObject::tr("Server check failed"); case(ServerCheckFailed): return QObject::tr("Server check failed");
case(ServerPortAlreadyAllocatedError): return QObject::tr("Server port already used. Check for another software"); case(ServerPortAlreadyAllocatedError): return QObject::tr("Server port already used. Check for another software");
case(ServerContainerMissingError): return QObject::tr("Server error: Docker container missing");
case(ServerDockerFailedError): return QObject::tr("Server error: Docker failed");
// Ssh connection errors // Ssh connection errors
case(SshSocketError): return QObject::tr("Ssh connection error"); case(SshSocketError): return QObject::tr("Ssh connection error");

View file

@ -390,6 +390,9 @@ ErrorCode ServerController::setupContainer(const ServerCredentials &credentials,
if (e) return e; if (e) return e;
qDebug().noquote() << "ServerController::setupContainer configureContainerWorker finished"; qDebug().noquote() << "ServerController::setupContainer configureContainerWorker finished";
setupServerFirewall(credentials);
qDebug().noquote() << "ServerController::setupContainer setupServerFirewall finished";
return startupContainerWorker(credentials, container, config); return startupContainerWorker(credentials, container, config);
} }
@ -460,10 +463,14 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent
stdOut += data + "\n"; stdOut += data + "\n";
}; };
return runScript(sshParams(credentials), ErrorCode e = runScript(sshParams(credentials),
replaceVars(amnezia::scriptData(SharedScriptType::install_docker), replaceVars(amnezia::scriptData(SharedScriptType::install_docker),
genVarsForScript(credentials, container)), genVarsForScript(credentials)),
cbReadStdOut, cbReadStdErr); cbReadStdOut, cbReadStdErr);
if (stdOut.contains("command not found")) return ErrorCode::ServerDockerFailedError;
return e;
} }
ErrorCode ServerController::prepareHostWorker(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config) ErrorCode ServerController::prepareHostWorker(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config)
@ -681,7 +688,7 @@ ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credent
{ {
return runScript(sshParams(credentials), return runScript(sshParams(credentials),
replaceVars(amnezia::scriptData(SharedScriptType::setup_host_firewall), replaceVars(amnezia::scriptData(SharedScriptType::setup_host_firewall),
genVarsForScript(credentials, DockerContainer::OpenVpnOverCloak))); genVarsForScript(credentials)));
} }
QString ServerController::replaceVars(const QString &script, const Vars &vars) QString ServerController::replaceVars(const QString &script, const Vars &vars)

View file

@ -4,7 +4,7 @@
#define APPLICATION_NAME "AmneziaVPN" #define APPLICATION_NAME "AmneziaVPN"
#define SERVICE_NAME "AmneziaVPN-service" #define SERVICE_NAME "AmneziaVPN-service"
#define ORGANIZATION_NAME "AmneziaVPN.ORG" #define ORGANIZATION_NAME "AmneziaVPN.ORG"
#define APP_MAJOR_VERSION "1.8.0" #define APP_MAJOR_VERSION "1.8.1"
#define APP_VERSION "1.8.0.0" #define APP_VERSION "1.8.1.0"
#endif // DEFINES_H #endif // DEFINES_H

View file

@ -13,8 +13,6 @@
OpenVpnProtocol::OpenVpnProtocol(const QJsonObject &configuration, QObject* parent) : OpenVpnProtocol::OpenVpnProtocol(const QJsonObject &configuration, QObject* parent) :
VpnProtocol(configuration, parent) VpnProtocol(configuration, parent)
{ {
Utils::initializePath(defaultConfigPath());
readOpenVpnConfiguration(configuration); readOpenVpnConfiguration(configuration);
connect(&m_managementServer, &ManagementServer::readyRead, this, &OpenVpnProtocol::onReadyReadDataFromManagementServer); connect(&m_managementServer, &ManagementServer::readyRead, this, &OpenVpnProtocol::onReadyReadDataFromManagementServer);
} }
@ -28,13 +26,16 @@ OpenVpnProtocol::~OpenVpnProtocol()
QString OpenVpnProtocol::defaultConfigFileName() QString OpenVpnProtocol::defaultConfigFileName()
{ {
qDebug() << "OpenVpnProtocol::defaultConfigFileName" << defaultConfigPath() + QString("/%1.ovpn").arg(APPLICATION_NAME); //qDebug() << "OpenVpnProtocol::defaultConfigFileName" << defaultConfigPath() + QString("/%1.ovpn").arg(APPLICATION_NAME);
return defaultConfigPath() + QString("/%1.ovpn").arg(APPLICATION_NAME); return defaultConfigPath() + QString("/%1.ovpn").arg(APPLICATION_NAME);
} }
QString OpenVpnProtocol::defaultConfigPath() QString OpenVpnProtocol::defaultConfigPath()
{ {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/config"; QString p = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/config";
Utils::initializePath(p);
return p;
} }
void OpenVpnProtocol::stop() void OpenVpnProtocol::stop()

View file

@ -93,7 +93,7 @@ constexpr char ckPublicKeyPath[] = "/opt/amnezia/cloak/cloak_public.key";
constexpr char ckBypassUidKeyPath[] = "/opt/amnezia/cloak/cloak_bypass_uid.key"; constexpr char ckBypassUidKeyPath[] = "/opt/amnezia/cloak/cloak_bypass_uid.key";
constexpr char ckAdminKeyPath[] = "/opt/amnezia/cloak/cloak_admin_uid.key"; constexpr char ckAdminKeyPath[] = "/opt/amnezia/cloak/cloak_admin_uid.key";
constexpr char defaultPort[] = "443"; constexpr char defaultPort[] = "443";
constexpr char defaultRedirSite[] = "mail.ru"; constexpr char defaultRedirSite[] = "tile.openstreetmap.org";
constexpr char defaultCipher[] = "chacha20-ietf-poly1305"; constexpr char defaultCipher[] = "chacha20-ietf-poly1305";
} }

View file

@ -1,7 +1,9 @@
pm_apt="/usr/bin/apt-get"; pm_yum="/usr/bin/yum";\ pm_apt="/usr/bin/apt-get"; pm_yum="/usr/bin/yum";\
if [[ -f "$pm_apt" ]]; then pm=$pm_apt; docker_pkg="docker.io"; else pm=$pm_yum; docker_pkg="docker"; fi;\ if [[ -f "$pm_apt" ]]; then pm=$pm_apt; docker_pkg="docker.io"; else pm=$pm_yum; docker_pkg="docker"; fi;\
if [[ ! -f "/usr/bin/sudo" ]]; then $pm update -y -q; $pm install -y -q sudo; fi;\ if [[ ! -f "/usr/bin/sudo" ]]; then $pm update -y -q; $pm install -y -q sudo; fi;\
docker_service=$(systemctl list-units --full -all | grep docker.service);\ docker_service=$(systemctl list-units --full -all | grep docker.service | grep -v inactive | grep -v dead | grep -v failed);\
if [[ -f "$pm_apt" ]]; then export DEBIAN_FRONTEND=noninteractive; fi;\ if [[ -f "$pm_apt" ]]; then export DEBIAN_FRONTEND=noninteractive; fi;\
if [[ -z "$docker_service" ]]; then sudo $pm update -y -q; sudo $pm install -y -q curl $docker_pkg; fi;\ if [[ -z "$docker_service" ]]; then sudo $pm update -y -q; sudo $pm install -y -q curl $docker_pkg; fi;\
sudo systemctl start docker docker_service=$(systemctl list-units --full -all | grep docker.service | grep -v inactive | grep -v dead | grep -v failed);\
if [[ -z "$docker_service" ]]; then sleep 5 && sudo systemctl start docker && sleep 5; fi;\
docker --version

View file

@ -109,7 +109,7 @@ void SlidingStackedWidget::waitForAnimation()
{ {
if (!isAnimationRunning()) return; if (!isAnimationRunning()) return;
qDebug() << "Wait for stacked widget animation"; //qDebug() << "Wait for stacked widget animation";
QEventLoop l; QEventLoop l;
connect(animgroup, &QParallelAnimationGroup::finished, &l, &QEventLoop::quit); connect(animgroup, &QParallelAnimationGroup::finished, &l, &QEventLoop::quit);
l.exec(); l.exec();

View file

@ -2224,7 +2224,7 @@ border: none;
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>mail.ru</string> <string>tile.openstreetmap.org</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -7542,7 +7542,7 @@ color: #100A44;
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="text"> <property name="text">
<string>mail.ru</string> <string>tile.openstreetmap.org</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_102"> <widget class="QLabel" name="label_102">

View file

@ -261,10 +261,6 @@ ErrorCode VpnConnection::connectToVpn(int serverIndex,
emit connectionStateChanged(VpnProtocol::Connecting); emit connectionStateChanged(VpnProtocol::Connecting);
if (credentials.isValid()) {
ServerController::setupServerFirewall(credentials);
}
if (m_vpnProtocol) { if (m_vpnProtocol) {
disconnect(m_vpnProtocol.data(), &VpnProtocol::protocolError, this, &VpnConnection::vpnProtocolError); disconnect(m_vpnProtocol.data(), &VpnProtocol::protocolError, this, &VpnConnection::vpnProtocolError);
m_vpnProtocol->stop(); m_vpnProtocol->stop();
@ -346,7 +342,8 @@ void VpnConnection::disconnectFromVpn()
IpcClient::Interface()->flushDns(); IpcClient::Interface()->flushDns();
// delete cached routes // delete cached routes
IpcClient::Interface()->clearSavedRoutes(); QRemoteObjectPendingReply<bool> response = IpcClient::Interface()->clearSavedRoutes();
response.waitForFinished(1000);
} }
if (!m_vpnProtocol.data()) { if (!m_vpnProtocol.data()) {