mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-21 18:24:35 +00:00
I2P Integration
This commit is contained in:
parent
f650e96363
commit
9f31849ca5
11 changed files with 336 additions and 0 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -5,3 +5,6 @@
|
|||
[submodule "external/quirc"]
|
||||
path = external/quirc
|
||||
url = https://github.com/dlbeer/quirc/
|
||||
[submodule "external/i2pd"]
|
||||
path = external/i2pd
|
||||
url = https://github.com/PurpleI2P/i2pd
|
||||
|
|
8
external/CMakeLists.txt
vendored
8
external/CMakeLists.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
file(GLOB I2PD_SOURCES "i2pd/daemon/*.cpp" "i2pd/libi2pd/*.cpp" "i2pd/libi2pd_client/*.cpp" "i2pd/i18n/*.cpp")
|
||||
|
||||
add_library(quirc STATIC
|
||||
quirc/lib/decode.c
|
||||
quirc/lib/identify.c
|
||||
|
@ -6,3 +8,9 @@ add_library(quirc STATIC
|
|||
)
|
||||
set_target_properties(quirc PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(quirc PUBLIC quirc/lib)
|
||||
|
||||
add_library(i2pd STATIC
|
||||
${I2PD_SOURCES}
|
||||
)
|
||||
set_target_properties(i2pd PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(i2pd PUBLIC i2pd/daemon i2pd/libi2pd i2pd/libi2pd_client i2pd/i18n)
|
||||
|
|
1
external/i2pd
vendored
Submodule
1
external/i2pd
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit ae439b5385944215ce9cba75eba55a2789b9989e
|
|
@ -81,6 +81,11 @@ ColumnLayout {
|
|||
text: qsTr("Info") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "Info"
|
||||
}
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "Network"
|
||||
text: qsTr("Network") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "Network"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
|
@ -92,6 +97,7 @@ ColumnLayout {
|
|||
property SettingsNode settingsNodeView: SettingsNode { }
|
||||
property SettingsLog settingsLogView: SettingsLog { }
|
||||
property SettingsInfo settingsInfoView: SettingsInfo { }
|
||||
property SettingsNetwork settingsNetworkView: SettingsNetwork { }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: settingsHeight
|
||||
color: "transparent"
|
||||
|
@ -133,6 +139,10 @@ ColumnLayout {
|
|||
name: "Info"
|
||||
PropertyChanges { target: settingsStateView; currentView: settingsStateView.settingsInfoView }
|
||||
PropertyChanges { target: settingsPage; settingsHeight: settingsStateView.settingsInfoView.infoHeight + 140 }
|
||||
}, State {
|
||||
name: "Network"
|
||||
PropertyChanges { target: settingsStateView; currentView: settingsStateView.settingsNetworkView }
|
||||
PropertyChanges { target: settingsPage; settingsHeight: settingsStateView.settingsNetworkView.networkHeight + 140 }
|
||||
}
|
||||
]
|
||||
|
||||
|
|
167
pages/settings/SettingsNetwork.qml
Normal file
167
pages/settings/SettingsNetwork.qml
Normal file
|
@ -0,0 +1,167 @@
|
|||
// Copyright (c) 2014-2018, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import moneroComponents.I2PDManager 1.0
|
||||
import moneroComponents.DaemonManager 1.0
|
||||
|
||||
import "../../components" as MoneroComponents
|
||||
|
||||
Rectangle {
|
||||
color: "transparent"
|
||||
Layout.fillWidth: true
|
||||
property alias networkHeight: networkLayout.height
|
||||
|
||||
ColumnLayout {
|
||||
id: networkLayout
|
||||
Layout.fillWidth: true
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 20
|
||||
anchors.topMargin: 0
|
||||
spacing: 30
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: networkTitleLabel
|
||||
fontSize: 24
|
||||
text: qsTr("Network traffic protection") + translationManager.emptyString
|
||||
}
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: networkMainLabel
|
||||
text: qsTr("Your wallet communicates with a set node and other nodes on the\nMonero network. This communication can be used to identify you.\nUse the options below to protect your privacy. Please check your\nlocal laws and internet policies before protecting your connection\nusing i2p, an anonymizing software.") + translationManager.emptyString
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
font.family: MoneroComponents.Style.fontRegular.name
|
||||
font.pixelSize: 14
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: modeButtonsColumn
|
||||
Layout.topMargin: 8
|
||||
|
||||
MoneroComponents.RadioButton {
|
||||
id: handleProtectButton
|
||||
text: qsTr("Protect my network connection") + translationManager.emptyString
|
||||
fontSize: 16
|
||||
enabled: !checked
|
||||
checked: false
|
||||
onClicked: {
|
||||
handleProtectButton.checked = true;
|
||||
handleUnprotectButton.checked = false;
|
||||
startI2PD();
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.RadioButton {
|
||||
id: handleUnprotectButton
|
||||
text: qsTr("Do not protect my connection") + translationManager.emptyString
|
||||
fontSize: 16
|
||||
enabled: !checked
|
||||
checked: true
|
||||
onClicked: {
|
||||
handleUnprotectButton.checked = true;
|
||||
handleProtectButton.checked = false;
|
||||
stopI2PD();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
MoneroComponents.Label {
|
||||
id: networkProtectionStatusLabel
|
||||
fontSize: 20
|
||||
text: qsTr("Status: ") + translationManager.emptyString
|
||||
}
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: networkProtectionStatus
|
||||
fontSize: 20
|
||||
text: qsTr("Unprotected") + translationManager.emptyString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function startI2PD()
|
||||
{
|
||||
var noSync = false;
|
||||
//these args will be deleted because DaemonManager::start will re-add them later.
|
||||
//removing '--tx-proxy=i2p,...' lets us blindly add '--tx-proxy i2p,...' later without risking duplication.
|
||||
var defaultArgs = ["--detach","--data-dir","--bootstrap-daemon-address","--prune-blockchain","--no-sync","--check-updates","--non-interactive","--max-concurrency","--tx-proxy=i2p,127.0.0.1:4447"]
|
||||
var customDaemonArgsArray = args.split(' ');
|
||||
var flag = "";
|
||||
var allArgs = [];
|
||||
var i2pdArgs = ["--tx-proxy i2p,127.0.0.1:4447"];
|
||||
//create an array (allArgs) of ['--arg value','--arg2','--arg3']
|
||||
for (let i = 0; i < customDaemonArgsArray.length; i++) {
|
||||
if(!customDaemonArgsArray[i].startsWith("--")) {
|
||||
flag += " " + customDaemonArgsArray[i]
|
||||
} else {
|
||||
if(flag){
|
||||
allArgs.push(flag)
|
||||
}
|
||||
flag = customDaemonArgsArray[i]
|
||||
}
|
||||
}
|
||||
allArgs.push(flag)
|
||||
//pop from allArgs if value is inside the deleteme array (defaultArgs)
|
||||
allArgs = allArgs.filter( ( el ) => !defaultArgs.includes( el.split(" ")[0] ) )
|
||||
//append required i2pd flags
|
||||
for (let i = 0; i < i2pdArgs.length; i++) {
|
||||
if(!allArgs.includes(i2pdArgs[i])) {
|
||||
allArgs.push(i2pdArgs[i])
|
||||
continue
|
||||
}
|
||||
}
|
||||
var success = daemonManager.start(allArgs.join(" "), persistentSettings.nettype, persistentSettings.blockchainDataDir, persistentSettings.bootstrapNodeAddress, noSync, persistentSettings.pruneBlockchain)
|
||||
if (success) {
|
||||
i2pdManager.start();
|
||||
}
|
||||
}
|
||||
|
||||
function stopI2PD()
|
||||
{
|
||||
i2pdManager.stop();
|
||||
}
|
||||
|
||||
function onI2PDStatus(isRunning)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
i2pdManager.i2pdStatus.connect(onI2PDStatus);
|
||||
}
|
||||
}
|
1
qml.qrc
1
qml.qrc
|
@ -185,6 +185,7 @@
|
|||
<file>pages/settings/SettingsLog.qml</file>
|
||||
<file>pages/settings/SettingsLayout.qml</file>
|
||||
<file>pages/settings/SettingsInfo.qml</file>
|
||||
<file>pages/settings/SettingsNetwork.qml</file>
|
||||
<file>components/WarningBox.qml</file>
|
||||
<file>images/miningxmr.png</file>
|
||||
<file>images/miningxmr@2x.png</file>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
add_subdirectory(QR-Code-scanner)
|
||||
add_subdirectory(i2pd)
|
||||
add_subdirectory(openpgp)
|
||||
add_subdirectory(zxcvbn-c)
|
||||
|
||||
|
@ -100,6 +101,7 @@ target_include_directories(monero-wallet-gui PUBLIC
|
|||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/daemon
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/p2pool
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/i2pd
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libwalletqt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/model
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-scanner
|
||||
|
@ -132,6 +134,7 @@ target_link_libraries(monero-wallet-gui
|
|||
easylogging
|
||||
${QT5_LIBRARIES}
|
||||
${EXTRA_LIBRARIES}
|
||||
i2p
|
||||
openpgp
|
||||
qrdecoder
|
||||
translations
|
||||
|
|
5
src/i2pd/CMakeLists.txt
Normal file
5
src/i2pd/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
add_library(i2p STATIC
|
||||
I2PDManager.cpp
|
||||
)
|
||||
find_package(ZLIB)
|
||||
target_link_libraries(i2p PRIVATE i2pd ZLIB::ZLIB)
|
82
src/i2pd/I2PDManager.cpp
Normal file
82
src/i2pd/I2PDManager.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
// Copyright (c) 2014-2022, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "I2PDManager.h"
|
||||
#include "../../external/i2pd/daemon/Daemon.h"
|
||||
#include <vector>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
I2PDManager::I2PDManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
m_i2pdDataDir = QApplication::applicationDirPath() + "/i2pd";
|
||||
if (!QDir(m_i2pdDataDir).exists()) {
|
||||
QDir().mkdir(m_i2pdDataDir);
|
||||
}
|
||||
#elif defined(Q_OS_UNIX)
|
||||
m_i2pdDataDir = QApplication::applicationDirPath() + "/i2pd";
|
||||
if (!QDir(m_i2pdDataDir).exists()) {
|
||||
QDir().mkdir(m_i2pdDataDir);
|
||||
}
|
||||
#endif
|
||||
if (m_i2pdDataDir.length() == 0) {
|
||||
qCritical() << "I2PD not compatible with current platform";
|
||||
}
|
||||
|
||||
std::string dataDir = "--datadir=" + m_i2pdDataDir.toStdString();
|
||||
std::vector<const char*> argv({"i2pd", dataDir.data()});
|
||||
Daemon.init(argv.size(), (char**) argv.data());
|
||||
}
|
||||
|
||||
I2PDManager::~I2PDManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void I2PDManager::start()
|
||||
{
|
||||
if (!isRunning()) {
|
||||
Daemon.start();
|
||||
Daemon.running;
|
||||
}
|
||||
}
|
||||
|
||||
void I2PDManager::stop()
|
||||
{
|
||||
if (isRunning()) {
|
||||
Daemon.stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool I2PDManager::isRunning() const
|
||||
{
|
||||
return Daemon.running;
|
||||
}
|
51
src/i2pd/I2PDManager.h
Normal file
51
src/i2pd/I2PDManager.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2014-2022, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef I2PDMANAGER_H
|
||||
#define I2PDMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class I2PDManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit I2PDManager(QObject *parent = 0);
|
||||
~I2PDManager();
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void start();
|
||||
Q_INVOKABLE void stop();
|
||||
Q_INVOKABLE bool isRunning() const;
|
||||
|
||||
private:
|
||||
QString m_i2pdDataDir;
|
||||
};
|
||||
|
||||
#endif // I2PDMANAGER_H
|
|
@ -79,6 +79,7 @@
|
|||
#ifndef Q_OS_IOS
|
||||
#include "daemon/DaemonManager.h"
|
||||
#include "p2pool/P2PoolManager.h"
|
||||
#include "i2pd/I2PDManager.h"
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
|
@ -410,6 +411,8 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
|||
"DaemonManager can't be instantiated directly");
|
||||
qmlRegisterUncreatableType<P2PoolManager>("moneroComponents.P2PoolManager", 1, 0, "P2PoolManager",
|
||||
"P2PoolManager can't be instantiated directly");
|
||||
qmlRegisterUncreatableType<I2PDManager>("moneroComponents.I2PDManager", 1, 0, "I2PDManager",
|
||||
"I2PDManager can't be instantiated directly");
|
||||
#endif
|
||||
qmlRegisterUncreatableType<AddressBookModel>("moneroComponents.AddressBookModel", 1, 0, "AddressBookModel",
|
||||
"AddressBookModel can't be instantiated directly");
|
||||
|
@ -472,8 +475,10 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
|||
#ifndef Q_OS_IOS
|
||||
DaemonManager daemonManager;
|
||||
P2PoolManager p2poolManager;
|
||||
I2PDManager i2pdManager;
|
||||
engine.rootContext()->setContextProperty("daemonManager", &daemonManager);
|
||||
engine.rootContext()->setContextProperty("p2poolManager", &p2poolManager);
|
||||
engine.rootContext()->setContextProperty("i2pdManager", &i2pdManager);
|
||||
#endif
|
||||
|
||||
engine.rootContext()->setContextProperty("isWindows", isWindows);
|
||||
|
|
Loading…
Reference in a new issue