Merge branch 'dev' into secure-config

This commit is contained in:
eugenyorbitsoftcom 2022-08-01 10:55:33 +06:00
commit bc6ae1d1b5
31 changed files with 356 additions and 85 deletions

View file

@ -38,6 +38,7 @@ HEADERS += \
debug.h \ debug.h \
defines.h \ defines.h \
managementserver.h \ managementserver.h \
platforms/ios/MobileUtils.h \
platforms/linux/leakdetector.h \ platforms/linux/leakdetector.h \
protocols/protocols_defs.h \ protocols/protocols_defs.h \
secureformat.h \ secureformat.h \
@ -78,7 +79,7 @@ HEADERS += \
loghandler.h \ loghandler.h \
loglevel.h \ loglevel.h \
constants.h \ constants.h \
platforms/ios/QRCodeReader.h platforms/ios/QRCodeReaderBase.h
SOURCES += \ SOURCES += \
configurators/cloak_configurator.cpp \ configurators/cloak_configurator.cpp \
@ -96,6 +97,7 @@ SOURCES += \
debug.cpp \ debug.cpp \
main.cpp \ main.cpp \
managementserver.cpp \ managementserver.cpp \
platforms/ios/MobileUtils.cpp \
platforms/linux/leakdetector.cpp \ platforms/linux/leakdetector.cpp \
protocols/protocols_defs.cpp \ protocols/protocols_defs.cpp \
secureformat.cpp \ secureformat.cpp \
@ -132,7 +134,7 @@ SOURCES += \
protocols/vpnprotocol.cpp \ protocols/vpnprotocol.cpp \
logger.cpp \ logger.cpp \
loghandler.cpp \ loghandler.cpp \
platforms/ios/QRCodeReader.cpp platforms/ios/QRCodeReaderBase.cpp
RESOURCES += \ RESOURCES += \
resources.qrc resources.qrc
@ -302,10 +304,13 @@ ios {
platforms/ios/bigint.h \ platforms/ios/bigint.h \
platforms/ios/bigintipv6addr.h \ platforms/ios/bigintipv6addr.h \
platforms/ios/ipaddress.h \ platforms/ios/ipaddress.h \
platforms/ios/ipaddressrange.h platforms/ios/ipaddressrange.h \
platforms/ios/QtAppDelegate.h \
platforms/ios/QtAppDelegate-C-Interface.h
SOURCES -= \ SOURCES -= \
platforms/ios/QRCodeReader.cpp platforms/ios/QRCodeReader.cpp \
platforms/ios/MobileUtils.cpp
SOURCES += \ SOURCES += \
protocols/ios_vpnprotocol.mm \ protocols/ios_vpnprotocol.mm \
@ -314,7 +319,9 @@ ios {
platforms/ios/iosglue.mm \ platforms/ios/iosglue.mm \
platforms/ios/ipaddress.cpp \ platforms/ios/ipaddress.cpp \
platforms/ios/ipaddressrange.cpp \ platforms/ios/ipaddressrange.cpp \
platforms/ios/QRCodeReader.mm platforms/ios/QRCodeReaderBase.mm
platforms/ios/QtAppDelegate.mm \
platforms/ios/MobileUtils.mm
Q_ENABLE_BITCODE.value = NO Q_ENABLE_BITCODE.value = NO
Q_ENABLE_BITCODE.name = ENABLE_BITCODE Q_ENABLE_BITCODE.name = ENABLE_BITCODE

View file

@ -109,12 +109,9 @@ void VpnConfigurator::updateContainerConfigAfterInstallation(DockerContainer con
qDebug() << "amnezia-tor onions" << stdOut; qDebug() << "amnezia-tor onions" << stdOut;
QStringList l = stdOut.split(","); QString onion = stdOut;
for (QString s : l) { onion.replace("\n", "");
if (s.contains(":80")) { protocol.insert(config_key::site, onion);
protocol.insert(config_key::site, s);
}
}
containerConfig.insert(ProtocolProps::protoToString(mainProto), protocol); containerConfig.insert(ProtocolProps::protoToString(mainProto), protocol);
} }

View file

@ -77,7 +77,7 @@ QMap<DockerContainer, QString> ContainerProps::containerHumanNames()
{DockerContainer::WireGuard, "WireGuard"}, {DockerContainer::WireGuard, "WireGuard"},
{DockerContainer::Ipsec, QObject::tr("IPsec")}, {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::Dns, QObject::tr("DNS Service")},
//{DockerContainer::FileShare, QObject::tr("SMB file sharing service")}, //{DockerContainer::FileShare, QObject::tr("SMB file sharing service")},
{DockerContainer::Sftp, QObject::tr("Sftp file sharing service")} {DockerContainer::Sftp, QObject::tr("Sftp file sharing service")}
@ -94,7 +94,7 @@ QMap<DockerContainer, QString> ContainerProps::containerDescriptions()
{DockerContainer::WireGuard, QObject::tr("WireGuard container")}, {DockerContainer::WireGuard, QObject::tr("WireGuard container")},
{DockerContainer::Ipsec, QObject::tr("IPsec 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::Dns, QObject::tr("DNS Service")},
//{DockerContainer::FileShare, QObject::tr("SMB file sharing service - is Window file sharing protocol")}, //{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")} {DockerContainer::Sftp, QObject::tr("Sftp file sharing service - is secure FTP service")}

View file

@ -8,6 +8,19 @@
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>AmneziaVPN</string> <string>AmneziaVPN</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Amnezia VPN config</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>org.amnezia.AmneziaVPN.amnezia-config</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIcons</key> <key>CFBundleIcons</key>
@ -47,5 +60,31 @@
<array/> <array/>
<key>UIUserInterfaceStyle</key> <key>UIUserInterfaceStyle</key>
<string>Light</string> <string>Light</string>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Amnezia VPN config</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>org.amnezia.AmneziaVPN.amnezia-config</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>vpn</string>
</array>
<key>public.mime-type</key>
<array>
<string>text/plain</string>
</array>
</dict>
</dict>
</array>
</dict> </dict>
</plist> </plist>

View file

@ -37,7 +37,7 @@
#include "QZXing.h" #include "QZXing.h"
#include "platforms/ios/QRCodeReader.h" #include "platforms/ios/QRCodeReaderBase.h"
#include "debug.h" #include "debug.h"
#include "defines.h" #include "defines.h"
@ -57,6 +57,10 @@
#include "native.h" #include "native.h"
#endif #endif
#if defined(Q_OS_IOS)
#include "QtAppDelegate-C-Interface.h"
#endif
static void loadTranslator() static void loadTranslator()
{ {
QTranslator* translator = new QTranslator; QTranslator* translator = new QTranslator;
@ -88,7 +92,6 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
AllowSetForegroundWindow(0); AllowSetForegroundWindow(0);
#endif #endif
@ -97,6 +100,10 @@ int main(int argc, char *argv[])
NativeHelpers::registerApplicationInstance(&app); NativeHelpers::registerApplicationInstance(&app);
#endif #endif
#if defined(Q_OS_IOS)
QtAppDelegateInitialize();
#endif
loadTranslator(); loadTranslator();
QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf"); QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf");
@ -220,6 +227,10 @@ int main(int argc, char *argv[])
engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic()); engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic());
engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic()); engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic());
#if defined(Q_OS_IOS)
setStartPageLogic(uiLogic->startPageLogic());
#endif
engine->load(url); engine->load(url);
QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){ QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){

View file

@ -0,0 +1,10 @@
#include "MobileUtils.h"
MobileUtils::MobileUtils()
{
}
void MobileUtils::shareText(const QStringList& filesToSend) {
}

View file

@ -0,0 +1,17 @@
#ifndef MOBILEUTILS_H
#define MOBILEUTILS_H
#include <QObject>
#include <QStringList>
class MobileUtils : public QObject {
Q_OBJECT
public:
MobileUtils() = delete;
public slots:
static void shareText(const QStringList& filesToSend);
};
#endif // MOBILEUTILS_H

View file

@ -0,0 +1,33 @@
#include "MobileUtils.h"
#include <UIKit/UIKit.h>
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;
}
}

View file

@ -1,4 +1,4 @@
#include "QRCodeReader.h" #include "QRCodeReaderBase.h"
QRCodeReader::QRCodeReader() QRCodeReader::QRCodeReader()
{ {
@ -11,4 +11,4 @@ QRect QRCodeReader::cameraSize() {
void QRCodeReader::startReading() {} void QRCodeReader::startReading() {}
void QRCodeReader::stopReading() {} void QRCodeReader::stopReading() {}
void QRCodeReader::setCameraSize(QRect) {}; void QRCodeReader::setCameraSize(QRect) {}

View file

@ -1,5 +1,5 @@
#ifndef QRCODEREADER_H #ifndef QRCODEREADERBASE_H
#define QRCODEREADER_H #define QRCODEREADERBASE_H
#include <QObject> #include <QObject>
#include <QRect> #include <QRect>
@ -25,4 +25,4 @@ private:
QRect m_cameraSize; QRect m_cameraSize;
}; };
#endif // QRCODEREADER_H #endif // QRCODEREADERBASE_H

View file

@ -1,4 +1,4 @@
#include "QRCodeReader.h" #include "QRCodeReaderBase.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>

View file

@ -0,0 +1,9 @@
#ifndef QTAPPDELEGATECINTERFACE_H
#define QTAPPDELEGATECINTERFACE_H
#include "ui/pages_logic/StartPageLogic.h"
void QtAppDelegateInitialize();
void setStartPageLogic(StartPageLogic*);
#endif // QTAPPDELEGATECINTERFACE_H

View file

@ -0,0 +1,9 @@
#import <UIKit/UIKit.h>
#import "QtAppDelegate-C-Interface.h"
#include "ui/pages_logic/StartPageLogic.h"
@interface QtAppDelegate : UIResponder <UIApplicationDelegate>
+(QtAppDelegate *)sharedQtAppDelegate;
@property (nonatomic) StartPageLogic* startPageLogic;
@end

View file

@ -0,0 +1,91 @@
#import "QtAppDelegate.h"
#include <QFile>
@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<UIApplicationOpenURLOptionsKey, id> *)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

View file

@ -76,7 +76,7 @@ QMap<amnezia::Proto, QString> ProtocolProps::protocolHumanNames()
{Proto::Ikev2, "IKEv2"}, {Proto::Ikev2, "IKEv2"},
{Proto::L2tp, "L2TP"}, {Proto::L2tp, "L2TP"},
{Proto::TorWebSite, "Web site in TOR network"}, {Proto::TorWebSite, "Web site in Tor network"},
{Proto::Dns, "DNS Service"}, {Proto::Dns, "DNS Service"},
{Proto::FileShare, "File Sharing Service"}, {Proto::FileShare, "File Sharing Service"},
{Proto::Sftp, QObject::tr("Sftp service")} {Proto::Sftp, QObject::tr("Sftp service")}

View file

@ -158,5 +158,6 @@
<file>images/svg/settings_suggest_black_24dp.svg</file> <file>images/svg/settings_suggest_black_24dp.svg</file>
<file>ui/qml/Controls/SvgButtonType.qml</file> <file>ui/qml/Controls/SvgButtonType.qml</file>
<file>ui/qml/Pages/PageQrDecoderIos.qml</file> <file>ui/qml/Pages/PageQrDecoderIos.qml</file>
<file>server_scripts/website_tor/Dockerfile</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -271,7 +271,11 @@ class XCodeprojPatcher
@target_extension.build_configurations.each do |config| @target_extension.build_configurations.each do |config|
config.base_configuration_reference = @configFile 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['SWIFT_VERSION'] ||= '5.0'
config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES' config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES'
config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h' config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h'

View file

@ -1,2 +1,7 @@
# Run container # 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

View file

@ -1,8 +1,9 @@
sudo docker run \ sudo docker run -d \
--restart=always \ --privileged \
-p 500:500/udp \ --log-driver none \
-p 4500:4500/udp \ --restart=always \
-d --privileged \ -p 500:500/udp \
--name $CONTAINER_NAME $CONTAINER_NAME -p 4500:4500/udp \
--name $CONTAINER_NAME $CONTAINER_NAME
sudo docker network connect amnezia-dns-net $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME

View file

@ -1,9 +1,10 @@
# Run container # Run container
sudo docker run \ sudo docker run -d \
-d --restart always \ --log-driver none \
--cap-add=NET_ADMIN \ --restart always \
-p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \ --cap-add=NET_ADMIN \
--name $CONTAINER_NAME $CONTAINER_NAME -p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \
--name $CONTAINER_NAME $CONTAINER_NAME
sudo docker network connect amnezia-dns-net $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME

View file

@ -1,9 +1,10 @@
# Run container # Run container
sudo docker run \ sudo docker run -d \
-d --restart always \ --log-driver none \
--cap-add=NET_ADMIN \ --restart always \
-p $CLOAK_SERVER_PORT:443/tcp \ --cap-add=NET_ADMIN \
--name $CONTAINER_NAME $CONTAINER_NAME -p $CLOAK_SERVER_PORT:443/tcp \
--name $CONTAINER_NAME $CONTAINER_NAME
sudo docker network connect amnezia-dns-net $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME

View file

@ -1,5 +1,6 @@
# Run container # Run container
sudo docker run \ sudo docker run \
--log-driver none \
-d --restart always \ -d --restart always \
--cap-add=NET_ADMIN \ --cap-add=NET_ADMIN \
-p $SHADOWSOCKS_SERVER_PORT:$SHADOWSOCKS_SERVER_PORT/tcp \ -p $SHADOWSOCKS_SERVER_PORT:$SHADOWSOCKS_SERVER_PORT/tcp \

View file

@ -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

View file

@ -0,0 +1,3 @@
FROM amneziavpn/torpress:latest
LABEL maintainer="AmneziaVPN"

View file

@ -1,3 +1,3 @@
sleep 5 sleep 5
# get onions list # get onions list
onions cat /var/lib/tor/hidden_service/hostname

View file

@ -1,6 +1,5 @@
# Run container sudo docker run -d \
sudo docker stop amnezia-tor --log-driver none \
sudo docker rm amnezia-tor --restart always \
sudo docker run -d -p 80:80 --restart always --name $CONTAINER_NAME tutum/wordpress --name $CONTAINER_NAME \
sudo docker run -d --link $CONTAINER_NAME --name amnezia-tor goldy/tor-hidden-service $CONTAINER_NAME
sudo docker exec -i amnezia-tor apk add bash

View file

@ -1,5 +1,6 @@
# Run container # Run container
sudo docker run -d \ sudo docker run -d \
--log-driver none \
--restart always \ --restart always \
--privileged \ --privileged \
--cap-add=NET_ADMIN \ --cap-add=NET_ADMIN \

View file

@ -1,5 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import ProtocolEnum 1.0 import ProtocolEnum 1.0
import "../" import "../"
import "../../Controls" import "../../Controls"
@ -16,43 +17,54 @@ PageProtocolBase {
Caption { Caption {
id: caption id: caption
text: qsTr("TOR Web site settings") text: qsTr("Tor Web Site settings")
} }
Rectangle {
id: frame_settings ColumnLayout {
width: parent.width id: content
enabled: logic.pageEnabled
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.left: root.left
anchors.right: root.right
anchors.bottom: pb_save.top
anchors.margins: 20
anchors.topMargin: 10 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 { LabelType {
width: 130 id: lbl_onion
Layout.preferredWidth: 0.3 * root.width - 10
text: qsTr("Web site onion address") text: qsTr("Web site onion address")
} }
TextFieldType { TextFieldType {
id: tf_site_address id: tf_site_address
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 Layout.fillWidth: true
text: logic.labelTorWebSiteAddressText text: logic.labelTorWebSiteAddressText
readOnly: true readOnly: true
} }
}
ShareConnectionButtonCopyType {
Layout.fillWidth: true
Layout.topMargin: 5
copyText: tf_site_address.text
}
RichLabelType {
Layout.fillWidth: true
Layout.topMargin: 15
text: qsTr("Notes:<ul>
<li>Use <a href=\"https://www.torproject.org/download/\">Tor Browser</a> to open this url.</li>
<li>After installation it takes several minutes while your onion site will become available in the Tor Network.</li>
<li>When configuring WordPress set the domain as this onion address.</li>
</ul>
")
} }
} }
} }

View file

@ -15,6 +15,6 @@ PageShareProtocolBase {
Caption { Caption {
id: caption id: caption
text: qsTr("Share TOR Web site") text: qsTr("Share Tor Web site")
} }
} }

View file

@ -48,6 +48,8 @@
#include "platforms/android/android_controller.h" #include "platforms/android/android_controller.h"
#endif #endif
#include "platforms/ios/MobileUtils.h"
#include "pages_logic/AppSettingsLogic.h" #include "pages_logic/AppSettingsLogic.h"
#include "pages_logic/GeneralSettingsLogic.h" #include "pages_logic/GeneralSettingsLogic.h"
#include "pages_logic/NetworkSettingsLogic.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) void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QString ext, const QString& data)
{ {
// ext.replace("*", ""); #ifdef Q_OS_IOS
// QString fileName = QFileDialog::getSaveFileName(nullptr, desc, shareTempFile(suggestedName, ext, data);
// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext); return;
#endif
// 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());
ext.replace("*", ""); ext.replace("*", "");
QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
@ -681,3 +672,23 @@ void UiLogic::copyToClipboard(const QString &text)
{ {
qApp->clipboard()->setText(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);
}

View file

@ -104,6 +104,8 @@ public:
Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data); Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data);
Q_INVOKABLE void copyToClipboard(const QString& text); Q_INVOKABLE void copyToClipboard(const QString& text);
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
QString getDialogConnectErrorText() const; QString getDialogConnectErrorText() const;
void setDialogConnectErrorText(const QString &dialogConnectErrorText); void setDialogConnectErrorText(const QString &dialogConnectErrorText);