From 1800c1ff12c9eecc070e93b16056e925480fa371 Mon Sep 17 00:00:00 2001 From: eugenyorbitsoftcom Date: Mon, 11 Jul 2022 11:06:01 +0600 Subject: [PATCH 1/7] added ability import amnezia vpn config --- client/ios/app/Info.plist | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/client/ios/app/Info.plist b/client/ios/app/Info.plist index 38aec45ea..20a28b2a5 100644 --- a/client/ios/app/Info.plist +++ b/client/ios/app/Info.plist @@ -8,6 +8,19 @@ $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName AmneziaVPN + CFBundleDocumentTypes + + + CFBundleTypeName + Amnezia VPN config + LSHandlerRank + Alternate + LSItemContentTypes + + org.amnezia.AmneziaVPN.amnezia-config + + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIcons @@ -47,5 +60,31 @@ UIUserInterfaceStyle Light + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + Amnezia VPN config + UTTypeIconFiles + + UTTypeIdentifier + org.amnezia.AmneziaVPN.amnezia-config + UTTypeTagSpecification + + public.filename-extension + + vpn + + public.mime-type + + text/plain + + + + From 9ed16b81e84c491e17d8f935835ef858bdfe3bce Mon Sep 17 00:00:00 2001 From: eugenyorbitsoftcom Date: Mon, 11 Jul 2022 16:08:57 +0600 Subject: [PATCH 2/7] read imported file configuration --- client/client.pro | 7 +- client/main.cpp | 13 ++- .../platforms/ios/QtAppDelegate-C-Interface.h | 9 ++ client/platforms/ios/QtAppDelegate.h | 9 ++ client/platforms/ios/QtAppDelegate.mm | 91 +++++++++++++++++++ 5 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 client/platforms/ios/QtAppDelegate-C-Interface.h create mode 100644 client/platforms/ios/QtAppDelegate.h create mode 100644 client/platforms/ios/QtAppDelegate.mm diff --git a/client/client.pro b/client/client.pro index 316730f93..8127c415b 100644 --- a/client/client.pro +++ b/client/client.pro @@ -300,7 +300,9 @@ ios { platforms/ios/bigint.h \ platforms/ios/bigintipv6addr.h \ platforms/ios/ipaddress.h \ - platforms/ios/ipaddressrange.h + platforms/ios/ipaddressrange.h \ + platforms/ios/QtAppDelegate.h \ + platforms/ios/QtAppDelegate-C-Interface.h SOURCES -= \ platforms/ios/QRCodeReader.cpp @@ -312,7 +314,8 @@ ios { platforms/ios/iosglue.mm \ platforms/ios/ipaddress.cpp \ platforms/ios/ipaddressrange.cpp \ - platforms/ios/QRCodeReader.mm + platforms/ios/QRCodeReader.mm \ + platforms/ios/QtAppDelegate.mm Q_ENABLE_BITCODE.value = NO Q_ENABLE_BITCODE.name = ENABLE_BITCODE diff --git a/client/main.cpp b/client/main.cpp index b1419f183..2aa35a39a 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -57,6 +57,10 @@ #include "native.h" #endif +#if defined(Q_OS_IOS) +#include "QtAppDelegate-C-Interface.h" +#endif + static void loadTranslator() { QTranslator* translator = new QTranslator; @@ -88,7 +92,6 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); #endif - #ifdef Q_OS_WIN AllowSetForegroundWindow(0); #endif @@ -97,6 +100,10 @@ int main(int argc, char *argv[]) NativeHelpers::registerApplicationInstance(&app); #endif +#if defined(Q_OS_IOS) + QtAppDelegateInitialize(); +#endif + loadTranslator(); QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf"); @@ -203,6 +210,10 @@ int main(int argc, char *argv[]) engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic()); engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic()); +#if defined(Q_OS_IOS) + setStartPageLogic(uiLogic->startPageLogic()); +#endif + engine->load(url); QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){ diff --git a/client/platforms/ios/QtAppDelegate-C-Interface.h b/client/platforms/ios/QtAppDelegate-C-Interface.h new file mode 100644 index 000000000..afd31e7d8 --- /dev/null +++ b/client/platforms/ios/QtAppDelegate-C-Interface.h @@ -0,0 +1,9 @@ +#ifndef QTAPPDELEGATECINTERFACE_H +#define QTAPPDELEGATECINTERFACE_H + +#include "ui/pages_logic/StartPageLogic.h" + +void QtAppDelegateInitialize(); +void setStartPageLogic(StartPageLogic*); + +#endif // QTAPPDELEGATECINTERFACE_H diff --git a/client/platforms/ios/QtAppDelegate.h b/client/platforms/ios/QtAppDelegate.h new file mode 100644 index 000000000..1e0dc4121 --- /dev/null +++ b/client/platforms/ios/QtAppDelegate.h @@ -0,0 +1,9 @@ +#import +#import "QtAppDelegate-C-Interface.h" + +#include "ui/pages_logic/StartPageLogic.h" + +@interface QtAppDelegate : UIResponder ++(QtAppDelegate *)sharedQtAppDelegate; +@property (nonatomic) StartPageLogic* startPageLogic; +@end diff --git a/client/platforms/ios/QtAppDelegate.mm b/client/platforms/ios/QtAppDelegate.mm new file mode 100644 index 000000000..f63bea358 --- /dev/null +++ b/client/platforms/ios/QtAppDelegate.mm @@ -0,0 +1,91 @@ +#import "QtAppDelegate.h" + +#include + +@implementation QtAppDelegate + ++(QtAppDelegate *)sharedQtAppDelegate { + static dispatch_once_t pred; + static QtAppDelegate *shared = nil; + dispatch_once(&pred, ^{ + shared = [[super alloc] init]; + }); + return shared; +} + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + [application setMinimumBackgroundFetchInterval: UIApplicationBackgroundFetchIntervalMinimum]; + // Override point for customization after application launch. + NSLog(@"Did this launch option happen"); + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + NSLog(@"In the background"); +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + NSLog(@"In the foreground"); +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + // We will add content here soon. + NSLog(@"In the completionHandler"); +} + +- (BOOL)application:(UIApplication *)app + openURL:(NSURL *)url + options:(NSDictionary *)options { + + NSLog(@"Application openURL: %@", url); + if (url.fileURL) { + QString filePath(url.path.UTF8String); + qDebug() << "filePath:" << filePath; + if (filePath.isEmpty()) return NO; + + QFile file(filePath); + bool isOpenFile = file.open(QIODevice::ReadOnly); + qDebug() << "isOpenFile:" << isOpenFile; + QByteArray data = file.readAll(); + + [QtAppDelegate sharedQtAppDelegate].startPageLogic->importConnectionFromCode(QString(data)); + return YES; + } + return NO; +} + + +void QtAppDelegateInitialize() +{ + [[UIApplication sharedApplication] setDelegate: [QtAppDelegate sharedQtAppDelegate]]; + NSLog(@"Created a new AppDelegate"); +} + +void setStartPageLogic(StartPageLogic* startPage) { + [QtAppDelegate sharedQtAppDelegate].startPageLogic = startPage; +} + +@end From 96015062706c5c16bad69d9e4f046978e1019c29 Mon Sep 17 00:00:00 2001 From: eugenyorbitsoftcom Date: Wed, 13 Jul 2022 16:08:55 +0600 Subject: [PATCH 3/7] share file for iOS --- client/client.pro | 8 ++++-- client/platforms/ios/MobileUtils.cpp | 10 +++++++ client/platforms/ios/MobileUtils.h | 17 ++++++++++++ client/platforms/ios/MobileUtils.mm | 33 ++++++++++++++++++++++ client/ui/uilogic.cpp | 41 ++++++++++++++++++---------- client/ui/uilogic.h | 2 ++ 6 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 client/platforms/ios/MobileUtils.cpp create mode 100644 client/platforms/ios/MobileUtils.h create mode 100644 client/platforms/ios/MobileUtils.mm diff --git a/client/client.pro b/client/client.pro index 8127c415b..ec1234793 100644 --- a/client/client.pro +++ b/client/client.pro @@ -38,6 +38,7 @@ HEADERS += \ debug.h \ defines.h \ managementserver.h \ + platforms/ios/MobileUtils.h \ platforms/linux/leakdetector.h \ protocols/protocols_defs.h \ settings.h \ @@ -95,6 +96,7 @@ SOURCES += \ debug.cpp \ main.cpp \ managementserver.cpp \ + platforms/ios/MobileUtils.cpp \ platforms/linux/leakdetector.cpp \ protocols/protocols_defs.cpp \ settings.cpp \ @@ -305,7 +307,8 @@ ios { platforms/ios/QtAppDelegate-C-Interface.h SOURCES -= \ - platforms/ios/QRCodeReader.cpp + platforms/ios/QRCodeReader.cpp \ + platforms/ios/MobileUtils.cpp SOURCES += \ protocols/ios_vpnprotocol.mm \ @@ -315,7 +318,8 @@ ios { platforms/ios/ipaddress.cpp \ platforms/ios/ipaddressrange.cpp \ platforms/ios/QRCodeReader.mm \ - platforms/ios/QtAppDelegate.mm + platforms/ios/QtAppDelegate.mm \ + platforms/ios/MobileUtils.mm Q_ENABLE_BITCODE.value = NO Q_ENABLE_BITCODE.name = ENABLE_BITCODE diff --git a/client/platforms/ios/MobileUtils.cpp b/client/platforms/ios/MobileUtils.cpp new file mode 100644 index 000000000..31b58c94e --- /dev/null +++ b/client/platforms/ios/MobileUtils.cpp @@ -0,0 +1,10 @@ +#include "MobileUtils.h" + +MobileUtils::MobileUtils() +{ + +} + +void MobileUtils::shareText(const QStringList& filesToSend) { + +} diff --git a/client/platforms/ios/MobileUtils.h b/client/platforms/ios/MobileUtils.h new file mode 100644 index 000000000..42aa4031a --- /dev/null +++ b/client/platforms/ios/MobileUtils.h @@ -0,0 +1,17 @@ +#ifndef MOBILEUTILS_H +#define MOBILEUTILS_H + +#include +#include + +class MobileUtils : public QObject { + Q_OBJECT + +public: + MobileUtils() = delete; + +public slots: + static void shareText(const QStringList& filesToSend); +}; + +#endif // MOBILEUTILS_H diff --git a/client/platforms/ios/MobileUtils.mm b/client/platforms/ios/MobileUtils.mm new file mode 100644 index 000000000..94c7c7751 --- /dev/null +++ b/client/platforms/ios/MobileUtils.mm @@ -0,0 +1,33 @@ +#include "MobileUtils.h" + +#include + +static UIViewController* getViewController() { + NSArray *windows = [[UIApplication sharedApplication]windows]; + for (UIWindow *window in windows) { + if (window.isKeyWindow) { + return window.rootViewController; + } + } + return nil; +} + +void MobileUtils::shareText(const QStringList& filesToSend) { + NSMutableArray *sharingItems = [NSMutableArray new]; + + for (int i = 0; i < filesToSend.size(); i++) { + NSURL *logFileUrl = [[NSURL alloc] initFileURLWithPath:filesToSend[i].toNSString()]; + [sharingItems addObject:logFileUrl]; + } + + UIViewController *qtController = getViewController(); + if (!qtController) return; + + UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil]; + + [qtController presentViewController:activityController animated:YES completion:nil]; + UIPopoverPresentationController *popController = activityController.popoverPresentationController; + if (popController) { + popController.sourceView = qtController.view; + } +} diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp index 878facb79..fe2d541d5 100644 --- a/client/ui/uilogic.cpp +++ b/client/ui/uilogic.cpp @@ -48,6 +48,8 @@ #include "platforms/android/android_controller.h" #endif +#include "platforms/ios/MobileUtils.h" + #include "pages_logic/AppSettingsLogic.h" #include "pages_logic/GeneralSettingsLogic.h" #include "pages_logic/NetworkSettingsLogic.h" @@ -612,21 +614,10 @@ PageEnumNS::Page UiLogic::currentPage() void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QString ext, const QString& data) { -// ext.replace("*", ""); -// QString fileName = QFileDialog::getSaveFileName(nullptr, desc, -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext); - -// if (fileName.isEmpty()) return; -// if (!fileName.endsWith(ext)) fileName.append(ext); - -// QFile save(fileName); -// save.open(QIODevice::WriteOnly); -// save.write(data.toUtf8()); -// save.close(); - -// QFileInfo fi(fileName); -// QDesktopServices::openUrl(fi.absoluteDir().absolutePath()); - +#ifdef Q_OS_IOS + shareTempFile(suggestedName, ext, data); + return; +#endif ext.replace("*", ""); QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); @@ -681,3 +672,23 @@ void UiLogic::copyToClipboard(const QString &text) { qApp->clipboard()->setText(text); } + +void UiLogic::shareTempFile(const QString &suggestedName, QString ext, const QString& data) { + ext.replace("*", ""); + QString fileName = QDir::tempPath() + "/" + suggestedName; + + if (fileName.isEmpty()) return; + if (!fileName.endsWith(ext)) fileName.append(ext); + + QFile::remove(fileName); + qDebug() << "UiLogic::shareTempFile" << fileName; + + QFile save(fileName); + save.open(QIODevice::WriteOnly); + save.write(data.toUtf8()); + save.close(); + + QStringList filesToSend; + filesToSend.append(fileName); + MobileUtils::shareText(filesToSend); +} diff --git a/client/ui/uilogic.h b/client/ui/uilogic.h index ff7d74066..4e818bcc0 100644 --- a/client/ui/uilogic.h +++ b/client/ui/uilogic.h @@ -104,6 +104,8 @@ public: Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data); Q_INVOKABLE void copyToClipboard(const QString& text); + void shareTempFile(const QString &suggestedName, QString ext, const QString& data); + QString getDialogConnectErrorText() const; void setDialogConnectErrorText(const QString &dialogConnectErrorText); From 79c56d440c46d60d72d7b3e1d49568951a7d385d Mon Sep 17 00:00:00 2001 From: eugenyorbitsoftcom Date: Thu, 14 Jul 2022 13:01:40 +0600 Subject: [PATCH 4/7] fix LD_RUNPATH_SEARCH_PATHS --- client/scripts/xcode_patcher.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/scripts/xcode_patcher.rb b/client/scripts/xcode_patcher.rb index 983ec0c7b..0a0550ca7 100644 --- a/client/scripts/xcode_patcher.rb +++ b/client/scripts/xcode_patcher.rb @@ -271,7 +271,11 @@ class XCodeprojPatcher @target_extension.build_configurations.each do |config| config.base_configuration_reference = @configFile - config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= '"$(inherited) @executable_path/../Frameworks @executable_path/../../Frameworks"' + config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= [ + '$(inherited)', + '@executable_path/../Frameworks', + '@executable_path/../../Frameworks' + ] config.build_settings['SWIFT_VERSION'] ||= '5.0' config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES' config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h' From b93dd8cb9b49f76472fbb0da461a8b898546c140 Mon Sep 17 00:00:00 2001 From: pokamest Date: Wed, 27 Jul 2022 03:22:46 +0300 Subject: [PATCH 5/7] Build fix --- client/client.pro | 6 +++--- client/main.cpp | 2 +- .../ios/{QRCodeReader.cpp => QRCodeReaderBase.cpp} | 4 ++-- client/platforms/ios/{QRCodeReader.h => QRCodeReaderBase.h} | 6 +++--- .../platforms/ios/{QRCodeReader.mm => QRCodeReaderBase.mm} | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename client/platforms/ios/{QRCodeReader.cpp => QRCodeReaderBase.cpp} (69%) rename client/platforms/ios/{QRCodeReader.h => QRCodeReaderBase.h} (81%) rename client/platforms/ios/{QRCodeReader.mm => QRCodeReaderBase.mm} (99%) diff --git a/client/client.pro b/client/client.pro index 316730f93..a809362ba 100644 --- a/client/client.pro +++ b/client/client.pro @@ -77,7 +77,7 @@ HEADERS += \ loghandler.h \ loglevel.h \ constants.h \ - platforms/ios/QRCodeReader.h + platforms/ios/QRCodeReaderBase.h SOURCES += \ configurators/cloak_configurator.cpp \ @@ -130,7 +130,7 @@ SOURCES += \ protocols/vpnprotocol.cpp \ logger.cpp \ loghandler.cpp \ - platforms/ios/QRCodeReader.cpp + platforms/ios/QRCodeReaderBase.cpp RESOURCES += \ resources.qrc @@ -312,7 +312,7 @@ ios { platforms/ios/iosglue.mm \ platforms/ios/ipaddress.cpp \ platforms/ios/ipaddressrange.cpp \ - platforms/ios/QRCodeReader.mm + platforms/ios/QRCodeReaderBase.mm Q_ENABLE_BITCODE.value = NO Q_ENABLE_BITCODE.name = ENABLE_BITCODE diff --git a/client/main.cpp b/client/main.cpp index b1419f183..00f257433 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -37,7 +37,7 @@ #include "QZXing.h" -#include "platforms/ios/QRCodeReader.h" +#include "platforms/ios/QRCodeReaderBase.h" #include "debug.h" #include "defines.h" diff --git a/client/platforms/ios/QRCodeReader.cpp b/client/platforms/ios/QRCodeReaderBase.cpp similarity index 69% rename from client/platforms/ios/QRCodeReader.cpp rename to client/platforms/ios/QRCodeReaderBase.cpp index c422a0e73..c3148a854 100644 --- a/client/platforms/ios/QRCodeReader.cpp +++ b/client/platforms/ios/QRCodeReaderBase.cpp @@ -1,4 +1,4 @@ -#include "QRCodeReader.h" +#include "QRCodeReaderBase.h" QRCodeReader::QRCodeReader() { @@ -11,4 +11,4 @@ QRect QRCodeReader::cameraSize() { void QRCodeReader::startReading() {} void QRCodeReader::stopReading() {} -void QRCodeReader::setCameraSize(QRect) {}; +void QRCodeReader::setCameraSize(QRect) {} diff --git a/client/platforms/ios/QRCodeReader.h b/client/platforms/ios/QRCodeReaderBase.h similarity index 81% rename from client/platforms/ios/QRCodeReader.h rename to client/platforms/ios/QRCodeReaderBase.h index bc8c9925a..29a4946d8 100644 --- a/client/platforms/ios/QRCodeReader.h +++ b/client/platforms/ios/QRCodeReaderBase.h @@ -1,5 +1,5 @@ -#ifndef QRCODEREADER_H -#define QRCODEREADER_H +#ifndef QRCODEREADERBASE_H +#define QRCODEREADERBASE_H #include #include @@ -25,4 +25,4 @@ private: QRect m_cameraSize; }; -#endif // QRCODEREADER_H +#endif // QRCODEREADERBASE_H diff --git a/client/platforms/ios/QRCodeReader.mm b/client/platforms/ios/QRCodeReaderBase.mm similarity index 99% rename from client/platforms/ios/QRCodeReader.mm rename to client/platforms/ios/QRCodeReaderBase.mm index 85f71ba60..bd0dbac38 100644 --- a/client/platforms/ios/QRCodeReader.mm +++ b/client/platforms/ios/QRCodeReaderBase.mm @@ -1,4 +1,4 @@ -#include "QRCodeReader.h" +#include "QRCodeReaderBase.h" #import #import From a8fe4e6aabeb4afc4f50cdf43e61459d48ea605a Mon Sep 17 00:00:00 2001 From: pokamest Date: Wed, 27 Jul 2022 17:34:43 +0300 Subject: [PATCH 6/7] Docker images fix: log driver=none --- client/server_scripts/dns/run_container.sh | 7 ++++++- client/server_scripts/ipsec/run_container.sh | 13 +++++++------ client/server_scripts/openvpn/run_container.sh | 11 ++++++----- .../server_scripts/openvpn_cloak/run_container.sh | 11 ++++++----- .../openvpn_shadowsocks/run_container.sh | 1 + client/server_scripts/sftp/run_container.sh | 8 +++++++- client/server_scripts/wireguard/run_container.sh | 1 + 7 files changed, 34 insertions(+), 18 deletions(-) diff --git a/client/server_scripts/dns/run_container.sh b/client/server_scripts/dns/run_container.sh index b3be2c227..f8ff03809 100644 --- a/client/server_scripts/dns/run_container.sh +++ b/client/server_scripts/dns/run_container.sh @@ -1,2 +1,7 @@ # Run container -sudo docker run -d --restart always --network amnezia-dns-net --ip=172.29.172.254 --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--network amnezia-dns-net \ +--ip=172.29.172.254 \ +--name $CONTAINER_NAME $CONTAINER_NAME diff --git a/client/server_scripts/ipsec/run_container.sh b/client/server_scripts/ipsec/run_container.sh index adb023532..a2fbbd34c 100644 --- a/client/server_scripts/ipsec/run_container.sh +++ b/client/server_scripts/ipsec/run_container.sh @@ -1,8 +1,9 @@ -sudo docker run \ - --restart=always \ - -p 500:500/udp \ - -p 4500:4500/udp \ - -d --privileged \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--privileged \ +--log-driver none \ +--restart=always \ +-p 500:500/udp \ +-p 4500:4500/udp \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn/run_container.sh b/client/server_scripts/openvpn/run_container.sh index 9012a386f..5649dd21f 100644 --- a/client/server_scripts/openvpn/run_container.sh +++ b/client/server_scripts/openvpn/run_container.sh @@ -1,9 +1,10 @@ # Run container -sudo docker run \ - -d --restart always \ - --cap-add=NET_ADMIN \ - -p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--cap-add=NET_ADMIN \ +-p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn_cloak/run_container.sh b/client/server_scripts/openvpn_cloak/run_container.sh index c3ee3a158..bec8e8898 100644 --- a/client/server_scripts/openvpn_cloak/run_container.sh +++ b/client/server_scripts/openvpn_cloak/run_container.sh @@ -1,9 +1,10 @@ # Run container -sudo docker run \ - -d --restart always \ - --cap-add=NET_ADMIN \ - -p $CLOAK_SERVER_PORT:443/tcp \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--cap-add=NET_ADMIN \ +-p $CLOAK_SERVER_PORT:443/tcp \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn_shadowsocks/run_container.sh b/client/server_scripts/openvpn_shadowsocks/run_container.sh index 4d529b15d..3714aa620 100644 --- a/client/server_scripts/openvpn_shadowsocks/run_container.sh +++ b/client/server_scripts/openvpn_shadowsocks/run_container.sh @@ -1,5 +1,6 @@ # Run container sudo docker run \ +--log-driver none \ -d --restart always \ --cap-add=NET_ADMIN \ -p $SHADOWSOCKS_SERVER_PORT:$SHADOWSOCKS_SERVER_PORT/tcp \ diff --git a/client/server_scripts/sftp/run_container.sh b/client/server_scripts/sftp/run_container.sh index 7184d0bef..03944eb8c 100644 --- a/client/server_scripts/sftp/run_container.sh +++ b/client/server_scripts/sftp/run_container.sh @@ -1 +1,7 @@ -sudo docker run -d --restart always -p $SFTP_PORT:22/tcp --name $CONTAINER_NAME $CONTAINER_NAME $SFTP_USER:$SFTP_PASSWORD:::upload +sudo docker run -d \ +--log-driver none \ +--restart always \ +-p $SFTP_PORT:22/tcp \ +--name $CONTAINER_NAME \ +$CONTAINER_NAME \ +$SFTP_USER:$SFTP_PASSWORD:::upload diff --git a/client/server_scripts/wireguard/run_container.sh b/client/server_scripts/wireguard/run_container.sh index 0fdac5416..2520525a6 100644 --- a/client/server_scripts/wireguard/run_container.sh +++ b/client/server_scripts/wireguard/run_container.sh @@ -1,5 +1,6 @@ # Run container sudo docker run -d \ +--log-driver none \ --restart always \ --privileged \ --cap-add=NET_ADMIN \ From dab6e10881c25af13e5e4b96490c5a68fb9456f4 Mon Sep 17 00:00:00 2001 From: pokamest Date: Sat, 30 Jul 2022 16:20:41 +0300 Subject: [PATCH 7/7] Wordpress site in the Tor network --- client/configurators/vpn_configurator.cpp | 9 ++-- client/containers/containers_defs.cpp | 4 +- client/protocols/protocols_defs.cpp | 2 +- client/resources.qrc | 1 + client/server_scripts/website_tor/Dockerfile | 3 ++ .../website_tor/configure_container.sh | 2 +- .../website_tor/run_container.sh | 11 ++-- .../Pages/Protocols/PageProtoTorWebSite.qml | 54 +++++++++++-------- .../Pages/Share/PageShareProtoTorWebSite.qml | 2 +- 9 files changed, 50 insertions(+), 38 deletions(-) create mode 100644 client/server_scripts/website_tor/Dockerfile diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index 28669168c..c2b128f09 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -109,12 +109,9 @@ void VpnConfigurator::updateContainerConfigAfterInstallation(DockerContainer con qDebug() << "amnezia-tor onions" << stdOut; - QStringList l = stdOut.split(","); - for (QString s : l) { - if (s.contains(":80")) { - protocol.insert(config_key::site, s); - } - } + QString onion = stdOut; + onion.replace("\n", ""); + protocol.insert(config_key::site, onion); containerConfig.insert(ProtocolProps::protoToString(mainProto), protocol); } diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index ab665fbba..54721a2e9 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -77,7 +77,7 @@ QMap ContainerProps::containerHumanNames() {DockerContainer::WireGuard, "WireGuard"}, {DockerContainer::Ipsec, QObject::tr("IPsec")}, - {DockerContainer::TorWebSite, QObject::tr("Web site in TOR network")}, + {DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")}, {DockerContainer::Dns, QObject::tr("DNS Service")}, //{DockerContainer::FileShare, QObject::tr("SMB file sharing service")}, {DockerContainer::Sftp, QObject::tr("Sftp file sharing service")} @@ -94,7 +94,7 @@ QMap ContainerProps::containerDescriptions() {DockerContainer::WireGuard, QObject::tr("WireGuard container")}, {DockerContainer::Ipsec, QObject::tr("IPsec container")}, - {DockerContainer::TorWebSite, QObject::tr("Web site in TOR network")}, + {DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")}, {DockerContainer::Dns, QObject::tr("DNS Service")}, //{DockerContainer::FileShare, QObject::tr("SMB file sharing service - is Window file sharing protocol")}, {DockerContainer::Sftp, QObject::tr("Sftp file sharing service - is secure FTP service")} diff --git a/client/protocols/protocols_defs.cpp b/client/protocols/protocols_defs.cpp index 93578d122..549c3774b 100644 --- a/client/protocols/protocols_defs.cpp +++ b/client/protocols/protocols_defs.cpp @@ -76,7 +76,7 @@ QMap ProtocolProps::protocolHumanNames() {Proto::Ikev2, "IKEv2"}, {Proto::L2tp, "L2TP"}, - {Proto::TorWebSite, "Web site in TOR network"}, + {Proto::TorWebSite, "Web site in Tor network"}, {Proto::Dns, "DNS Service"}, {Proto::FileShare, "File Sharing Service"}, {Proto::Sftp, QObject::tr("Sftp service")} diff --git a/client/resources.qrc b/client/resources.qrc index db61db332..a48a98f78 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -158,5 +158,6 @@ images/svg/settings_suggest_black_24dp.svg ui/qml/Controls/SvgButtonType.qml ui/qml/Pages/PageQrDecoderIos.qml + server_scripts/website_tor/Dockerfile diff --git a/client/server_scripts/website_tor/Dockerfile b/client/server_scripts/website_tor/Dockerfile new file mode 100644 index 000000000..ba408716f --- /dev/null +++ b/client/server_scripts/website_tor/Dockerfile @@ -0,0 +1,3 @@ +FROM amneziavpn/torpress:latest + +LABEL maintainer="AmneziaVPN" diff --git a/client/server_scripts/website_tor/configure_container.sh b/client/server_scripts/website_tor/configure_container.sh index 31c9eb937..70fc8c37b 100644 --- a/client/server_scripts/website_tor/configure_container.sh +++ b/client/server_scripts/website_tor/configure_container.sh @@ -1,3 +1,3 @@ sleep 5 # get onions list -onions +cat /var/lib/tor/hidden_service/hostname diff --git a/client/server_scripts/website_tor/run_container.sh b/client/server_scripts/website_tor/run_container.sh index e5dfce98f..df62f8653 100644 --- a/client/server_scripts/website_tor/run_container.sh +++ b/client/server_scripts/website_tor/run_container.sh @@ -1,6 +1,5 @@ -# Run container -sudo docker stop amnezia-tor -sudo docker rm amnezia-tor -sudo docker run -d -p 80:80 --restart always --name $CONTAINER_NAME tutum/wordpress -sudo docker run -d --link $CONTAINER_NAME --name amnezia-tor goldy/tor-hidden-service -sudo docker exec -i amnezia-tor apk add bash +sudo docker run -d \ +--log-driver none \ +--restart always \ +--name $CONTAINER_NAME \ +$CONTAINER_NAME diff --git a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml b/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml index 9959e5fa4..1285e8bb8 100644 --- a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml +++ b/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.15 import ProtocolEnum 1.0 import "../" import "../../Controls" @@ -16,43 +17,54 @@ PageProtocolBase { Caption { id: caption - text: qsTr("TOR Web site settings") + text: qsTr("Tor Web Site settings") } - Rectangle { - id: frame_settings - width: parent.width + + ColumnLayout { + id: content + enabled: logic.pageEnabled anchors.top: caption.bottom + anchors.left: root.left + anchors.right: root.right + anchors.bottom: pb_save.top + anchors.margins: 20 anchors.topMargin: 10 - border.width: 1 - border.color: "lightgray" - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - radius: 2 - Grid { - id: grid - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 30 - rightPadding: 30 - spacing: 5 + RowLayout { + Layout.fillWidth: true + LabelType { - width: 130 + id: lbl_onion + Layout.preferredWidth: 0.3 * root.width - 10 text: qsTr("Web site onion address") } TextFieldType { id: tf_site_address - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 + Layout.fillWidth: true text: logic.labelTorWebSiteAddressText readOnly: true } + } + ShareConnectionButtonCopyType { + Layout.fillWidth: true + Layout.topMargin: 5 + copyText: tf_site_address.text + } + + RichLabelType { + Layout.fillWidth: true + Layout.topMargin: 15 + text: qsTr("Notes:
    +
  • Use Tor Browser to open this url.
  • +
  • After installation it takes several minutes while your onion site will become available in the Tor Network.
  • +
  • When configuring WordPress set the domain as this onion address.
  • +
+") } } + } diff --git a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml b/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml index 59a96345f..35caf05b5 100644 --- a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml +++ b/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml @@ -15,6 +15,6 @@ PageShareProtocolBase { Caption { id: caption - text: qsTr("Share TOR Web site") + text: qsTr("Share Tor Web site") } }