Various fixes
This commit is contained in:
parent
02acbecef5
commit
2b9e615e51
14 changed files with 122 additions and 89 deletions
|
@ -102,8 +102,8 @@ android {
|
|||
resConfig "en"
|
||||
minSdkVersion = 24
|
||||
targetSdkVersion = 30
|
||||
versionCode 7 // Change to a higher number
|
||||
versionName "2.0.7" // Change to a higher number
|
||||
versionCode 8 // Change to a higher number
|
||||
versionName "2.0.8" // Change to a higher number
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define APPLICATION_NAME "AmneziaVPN"
|
||||
#define SERVICE_NAME "AmneziaVPN-service"
|
||||
#define ORGANIZATION_NAME "AmneziaVPN.ORG"
|
||||
#define APP_MAJOR_VERSION "2.0.7"
|
||||
#define APP_VERSION "2.0.7.0"
|
||||
#define APP_MAJOR_VERSION "2.0.8"
|
||||
#define APP_VERSION "2.0.8.0"
|
||||
|
||||
#endif // DEFINES_H
|
||||
|
|
|
@ -196,13 +196,12 @@ int main(int argc, char *argv[])
|
|||
uiLogic->setQmlRoot(engine->rootObjects().at(0));
|
||||
}
|
||||
|
||||
// TODO - fix
|
||||
//#ifdef Q_OS_WIN
|
||||
// if (parser.isSet("a")) mainWindow.showOnStartup();
|
||||
// else mainWindow.show();
|
||||
//#else
|
||||
// mainWindow.showOnStartup();
|
||||
//#endif
|
||||
#ifdef Q_OS_WIN
|
||||
if (parser.isSet("a")) uiLogic->showOnStartup();
|
||||
else emit uiLogic->show();
|
||||
#else
|
||||
uiLogic->showOnStartup();
|
||||
#endif
|
||||
|
||||
|
||||
// TODO - fix
|
||||
|
|
|
@ -228,6 +228,21 @@ void Settings::addVpnSite(RouteMode mode, const QString &site, const QString &ip
|
|||
setVpnSites(mode, sites);
|
||||
}
|
||||
|
||||
void Settings::addVpnSites(RouteMode mode, const QMap<QString, QString> &sites)
|
||||
{
|
||||
QVariantMap allSites = vpnSites(mode);
|
||||
for (auto i = sites.constBegin(); i != sites.constEnd(); ++i) {
|
||||
const QString &site = i.key();
|
||||
const QString &ip = i.value();
|
||||
|
||||
if (allSites.contains(site) && allSites.value(site) == ip) continue;
|
||||
|
||||
allSites.insert(site, ip);
|
||||
}
|
||||
|
||||
setVpnSites(mode, allSites);
|
||||
}
|
||||
|
||||
QStringList Settings::getVpnIps(RouteMode mode) const
|
||||
{
|
||||
QStringList ips;
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
QVariantMap vpnSites(RouteMode mode) const { return m_settings.value("Conf/" + routeModeString(mode)).toMap(); }
|
||||
void setVpnSites(RouteMode mode, const QVariantMap &sites) { m_settings.setValue("Conf/"+ routeModeString(mode), sites); m_settings.sync(); }
|
||||
void addVpnSite(RouteMode mode, const QString &site, const QString &ip= "");
|
||||
void addVpnSites(RouteMode mode, const QMap<QString, QString> &sites); // map <site, ip>
|
||||
QStringList getVpnIps(RouteMode mode) const;
|
||||
void removeVpnSite(RouteMode mode, const QString &site);
|
||||
|
||||
|
|
|
@ -142,18 +142,53 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
|
||||
QStringList ips;
|
||||
QMap<QString, QString> sites;
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QString line = file.readLine();
|
||||
QStringList line_ips;
|
||||
QStringList line_sites;
|
||||
|
||||
int pos = 0;
|
||||
QRegExp rx = Utils::ipAddressWithSubnetRegExp();
|
||||
while ((pos = rx.indexIn(line, pos)) != -1) {
|
||||
ips << rx.cap(0);
|
||||
pos += rx.matchedLength();
|
||||
int posDomain = 0;
|
||||
QRegExp domainRx = Utils::domainRegExp();
|
||||
while ((posDomain = domainRx.indexIn(line, posDomain)) != -1) {
|
||||
line_sites.append(domainRx.cap(0));
|
||||
posDomain += domainRx.matchedLength();
|
||||
}
|
||||
|
||||
int posIp = 0;
|
||||
QRegExp ipRx = Utils::ipAddressWithSubnetRegExp();
|
||||
while ((posIp = ipRx.indexIn(line, posIp)) != -1) {
|
||||
line_ips.append(ipRx.cap(0));
|
||||
posIp += ipRx.matchedLength();
|
||||
}
|
||||
|
||||
// domain regex cover ip regex, so remove ips from sites
|
||||
for (const QString& ip: line_ips) {
|
||||
line_sites.removeAll(ip);
|
||||
}
|
||||
|
||||
if (line_sites.size() == 1 && line_ips.size() == 1) {
|
||||
sites.insert(line_sites.at(0), line_ips.at(0));
|
||||
}
|
||||
else if (line_sites.size() > 0 && line_ips.size() == 0) {
|
||||
for (const QString& site: line_sites) {
|
||||
sites.insert(site, "");
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const QString& site: line_sites) {
|
||||
sites.insert(site, "");
|
||||
}
|
||||
for (const QString& ip: line_ips) {
|
||||
ips.append(ip);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_settings.addVpnIps(mode, ips);
|
||||
m_settings.addVpnSites(mode, sites);
|
||||
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
|
|
|
@ -33,15 +33,24 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
onConnect();
|
||||
});
|
||||
}
|
||||
else {
|
||||
onConnectionStateChanged(VpnProtocol::Disconnected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VpnLogic::onUpdatePage()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);
|
||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
|
||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
|
||||
set_isCustomRoutesSupported (selectedContainer == DockerContainer::OpenVpn ||
|
||||
selectedContainer == DockerContainer::ShadowSocks||
|
||||
selectedContainer == DockerContainer::Cloak);
|
||||
|
||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites || !isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites && isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites && isCustomRoutesSupported());
|
||||
|
||||
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
|
||||
QString serverString = QString("%2 (%3)")
|
||||
|
@ -49,7 +58,6 @@ void VpnLogic::onUpdatePage()
|
|||
.arg(server.value(config_key::hostName).toString());
|
||||
set_labelCurrentServer(serverString);
|
||||
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentService(selectedContainerName);
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ class VpnLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(QString, labelErrorText)
|
||||
AUTO_PROPERTY(QString, labelVersionText)
|
||||
|
||||
AUTO_PROPERTY(bool, isCustomRoutesSupported)
|
||||
|
||||
AUTO_PROPERTY(bool, radioButtonVpnModeAllSitesChecked)
|
||||
AUTO_PROPERTY(bool, radioButtonVpnModeForwardSitesChecked)
|
||||
AUTO_PROPERTY(bool, radioButtonVpnModeExceptSitesChecked)
|
||||
|
|
|
@ -28,7 +28,7 @@ RadioButton {
|
|||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
color: "#181922"
|
||||
color: enabled ? "#181922" : "#686972"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
leftPadding: root.indicator.width + root.spacing
|
||||
}
|
||||
|
|
|
@ -213,6 +213,35 @@ PageBase {
|
|||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key == Qt.Key_PageUp) {
|
||||
let idx = tb.indexAt(1, tb.contentY)
|
||||
tb.positionViewAtIndex(idx-20, ListView.Beginning)
|
||||
event.accepted = true
|
||||
}
|
||||
else if (event.key == Qt.Key_PageDown) {
|
||||
let idx = tb.indexAt(1, tb.contentY)
|
||||
tb.positionViewAtIndex(idx+20, ListView.Beginning)
|
||||
event.accepted = true
|
||||
}
|
||||
else if (event.key == Qt.Key_Home) {
|
||||
tb.positionViewAtBeginning()
|
||||
event.accepted = true
|
||||
}
|
||||
else if (event.key == Qt.Key_End) {
|
||||
tb.positionViewAtEnd()
|
||||
event.accepted = true
|
||||
}
|
||||
else if (event.key == Qt.Key_Delete) {
|
||||
let items = []
|
||||
for(let i = 0; i < visualModel.count; i++){
|
||||
if (visualModel.items.get(i).inMultiSelect) items.push(i)
|
||||
}
|
||||
SitesLogic.onPushButtonSitesDeleteClicked(items)
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: tb
|
||||
x: 20
|
||||
|
@ -241,12 +270,11 @@ PageBase {
|
|||
font.pixelSize: 16
|
||||
text: qsTr("Delete selected")
|
||||
onClicked: {
|
||||
var items = []
|
||||
for(var i = 0; i < visualModel.count; i++){
|
||||
let items = []
|
||||
for(let i = 0; i < visualModel.count; i++){
|
||||
if (visualModel.items.get(i).inMultiSelect) items.push(i)
|
||||
}
|
||||
|
||||
console.debug(items)
|
||||
SitesLogic.onPushButtonSitesDeleteClicked(items)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,6 +259,7 @@ PageBase {
|
|||
onClicked: VpnLogic.onRadioButtonVpnModeAllSitesClicked(true)
|
||||
}
|
||||
RadioButtonType {
|
||||
enabled: VpnLogic.isCustomRoutesSupported
|
||||
x: 0
|
||||
y: 60
|
||||
width: 341
|
||||
|
@ -268,6 +269,7 @@ PageBase {
|
|||
onClicked: VpnLogic.onRadioButtonVpnModeExceptSitesClicked(true)
|
||||
}
|
||||
RadioButtonType {
|
||||
enabled: VpnLogic.isCustomRoutesSupported
|
||||
x: 0
|
||||
y: 30
|
||||
width: 341
|
||||
|
|
|
@ -149,24 +149,6 @@ void UiLogic::initalizeUiLogic()
|
|||
connect(m_notificationHandler, &NotificationHandler::connectRequested, vpnLogic(), &VpnLogic::onConnect);
|
||||
connect(m_notificationHandler, &NotificationHandler::disconnectRequested, vpnLogic(), &VpnLogic::onDisconnect);
|
||||
|
||||
// if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) {
|
||||
// needToHideCustomTitlebar = true;
|
||||
// }
|
||||
|
||||
//#if defined Q_OS_MAC
|
||||
// fixWidget(this);
|
||||
// needToHideCustomTitlebar = true;
|
||||
//#endif
|
||||
|
||||
// if (needToHideCustomTitlebar) {
|
||||
// ui->widget_tittlebar->hide();
|
||||
// resize(width(), 640);
|
||||
// ui->stackedWidget_main->move(0,0);
|
||||
// }
|
||||
|
||||
// Post initialization
|
||||
//emit goToPage(Page::Start, true, false);
|
||||
|
||||
if (m_settings.serversCount() > 0) {
|
||||
if (m_settings.defaultServerIndex() < 0) m_settings.setDefaultServer(0);
|
||||
emit goToPage(Page::Vpn, true, false);
|
||||
|
@ -176,37 +158,9 @@ void UiLogic::initalizeUiLogic()
|
|||
}
|
||||
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
//goToPage(Page::ServerContainers, true, false);
|
||||
//goToPage(Page::NewServerProtocols, true, false);
|
||||
//onGotoProtocolPage(Proto::OpenVpn);
|
||||
|
||||
|
||||
//ui->pushButton_general_settings_exit->hide();
|
||||
|
||||
|
||||
qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION);
|
||||
qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture());
|
||||
|
||||
|
||||
|
||||
vpnLogic()->onConnectionStateChanged(VpnProtocol::Disconnected);
|
||||
|
||||
|
||||
// m_ipAddressValidator.setRegExp(Utils::ipAddressRegExp());
|
||||
// m_ipAddressPortValidator.setRegExp(Utils::ipAddressPortRegExp());
|
||||
// m_ipNetwok24Validator.setRegExp(Utils::ipNetwork24RegExp());
|
||||
// m_ipPortValidator.setRegExp(Utils::ipPortRegExp());
|
||||
|
||||
// ui->lineEdit_new_server_ip->setValidator(&m_ipAddressPortValidator);
|
||||
// ui->lineEdit_network_settings_dns1->setValidator(&m_ipAddressValidator);
|
||||
// ui->lineEdit_network_settings_dns2->setValidator(&m_ipAddressValidator);
|
||||
|
||||
// ui->lineEdit_proto_openvpn_subnet->setValidator(&m_ipNetwok24Validator);
|
||||
|
||||
// ui->lineEdit_proto_openvpn_port->setValidator(&m_ipPortValidator);
|
||||
// ui->lineEdit_proto_shadowsocks_port->setValidator(&m_ipPortValidator);
|
||||
// ui->lineEdit_proto_cloak_port->setValidator(&m_ipPortValidator);
|
||||
|
||||
}
|
||||
|
||||
QString UiLogic::getDialogConnectErrorText() const
|
||||
|
@ -225,10 +179,13 @@ void UiLogic::setDialogConnectErrorText(const QString &dialogConnectErrorText)
|
|||
void UiLogic::showOnStartup()
|
||||
{
|
||||
if (! m_settings.isStartMinimized()) {
|
||||
show();
|
||||
} else {
|
||||
#if defined Q_OS_MACX
|
||||
setDockIconVisible(false);
|
||||
emit show();
|
||||
}
|
||||
else {
|
||||
#ifdef Q_OS_WIN
|
||||
emit hide();
|
||||
#elif defined Q_OS_MACX
|
||||
// TODO: fix: setDockIconVisible(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +259,6 @@ void UiLogic::keyPressEvent(Qt::Key key)
|
|||
// break;
|
||||
// }
|
||||
|
||||
//if (! ui->stackedWidget_main->isAnimationRunning() && ui->stackedWidget_main->currentWidget()->isEnabled()) {
|
||||
emit closePage();
|
||||
//}
|
||||
default:
|
||||
|
|
|
@ -213,20 +213,6 @@ private:
|
|||
|
||||
NotificationHandler* m_notificationHandler;
|
||||
|
||||
|
||||
// QRegExpValidator m_ipAddressValidator;
|
||||
// QRegExpValidator m_ipAddressPortValidator;
|
||||
// QRegExpValidator m_ipNetwok24Validator;
|
||||
// QRegExpValidator m_ipPortValidator;
|
||||
|
||||
// QPoint offset;
|
||||
// bool needToHideCustomTitlebar = false;
|
||||
|
||||
// void showEvent(QShowEvent *event) override;
|
||||
// void hideEvent(QHideEvent *event) override;
|
||||
|
||||
|
||||
// QStack<Page> pagesStack;
|
||||
int selectedServerIndex = -1; // server index to use when proto settings page opened
|
||||
DockerContainer selectedDockerContainer; // same
|
||||
ServerCredentials installCredentials; // used to save cred between pages new_server and new_server_protocols and wizard
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
|
||||
static QRegExp ipPortRegExp() { return QRegExp("^()([1-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[1-5])$"); }
|
||||
|
||||
static QRegExp domainRegExp() { return QRegExp("(((?!\\-))(xn\\-\\-)?[a-z0-9\\-_]{0,61}[a-z0-9]{1,1}\\.)*(xn\\-\\-)?([a-z0-9\\-]{1,61}|[a-z0-9\\-]{1,30})\\.[a-z]{2,}"); }
|
||||
static bool processIsRunning(const QString& fileName);
|
||||
static void killProcessByName(const QString &name);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue