Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2p integration (WIP) #4263

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ RUN wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_D

ARG OPENSSL_VERSION=1.1.1u
ARG OPENSSL_HASH=e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6
RUN wget -q https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \
RUN wget -q https://www.openssl.org/source/old/1.1.1/openssl-${OPENSSL_VERSION}.tar.gz \
&& echo "${OPENSSL_HASH} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c \
&& tar -xzf openssl-${OPENSSL_VERSION}.tar.gz \
&& rm openssl-${OPENSSL_VERSION}.tar.gz \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_
./b2 --with-atomic --with-system --with-filesystem --with-thread --with-date_time --with-chrono --with-regex --with-serialization --with-program_options --with-locale variant=release link=static runtime-link=static cflags="${CFLAGS}" cxxflags="${CXXFLAGS}" install -a --prefix=/usr && \
rm -rf $(pwd)

RUN wget https://www.openssl.org/source/openssl-1.1.1u.tar.gz && \
RUN wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1u.tar.gz && \
echo "e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6 openssl-1.1.1u.tar.gz" | sha256sum -c && \
tar -xzf openssl-1.1.1u.tar.gz && \
rm openssl-1.1.1u.tar.gz && \
Expand Down
3 changes: 3 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ add_library(quirc STATIC
)
set_target_properties(quirc PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(quirc PUBLIC quirc/lib)

option(WITH_BINARY "" OFF)
add_subdirectory(i2pd/build)
1 change: 1 addition & 0 deletions external/i2pd
Submodule i2pd added at ae439b
10 changes: 10 additions & 0 deletions pages/settings/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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"
Expand Down Expand Up @@ -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 }
}
]

Expand Down
169 changes: 169 additions & 0 deletions pages/settings/SettingsNetwork.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// 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 change: 1 addition & 0 deletions qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]</file>
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(QR-Code-scanner)
add_subdirectory(i2pd)
add_subdirectory(openpgp)
add_subdirectory(zxcvbn-c)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -132,6 +134,7 @@ target_link_libraries(monero-wallet-gui
easylogging
${QT5_LIBRARIES}
${EXTRA_LIBRARIES}
i2p
openpgp
qrdecoder
translations
Expand Down
23 changes: 23 additions & 0 deletions src/i2pd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
add_library(i2p STATIC
I2PDManager.cpp
)

find_package(ZLIB REQUIRED)

find_package(Boost REQUIRED)

target_include_directories(i2p
PRIVATE
"../../external/i2pd/libi2pd"
"../../external/i2pd/libi2pd_client"
"../../external/i2pd/i18n"
${Boost_INCLUDE_DIRS}
)

target_link_libraries(i2p
PRIVATE
libi2pdclient
libi2pd
libi2pdlang
ZLIB::ZLIB
)
Loading
Loading