aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml84
-rw-r--r--.github/workflows/depends.yml33
-rw-r--r--.github/workflows/gitian.yml36
-rw-r--r--CMakeLists.txt2
-rw-r--r--contrib/depends/funcs.mk2
-rw-r--r--contrib/depends/packages/libusb.mk10
-rw-r--r--contrib/depends/packages/unbound.mk11
-rw-r--r--contrib/depends/patches/unbound/hardcode_config_date.patch22
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h32
-rw-r--r--src/net/host.h20
-rw-r--r--src/net/i2p_address.cpp7
-rw-r--r--src/net/tor_address.cpp7
-rw-r--r--src/serialization/binary_archive.h2
-rw-r--r--src/wallet/wallet2.cpp1
-rw-r--r--tests/unit_tests/net.cpp22
15 files changed, 229 insertions, 62 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7132adc9c..a7c722c8b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,7 +35,9 @@ jobs:
- uses: actions/checkout@v5
with:
submodules: recursive
- - uses: actions/cache@v5
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
with:
path: /Users/runner/Library/Caches/ccache
key: ccache-${{ runner.os }}-build-${{ github.sha }}
@@ -45,11 +47,17 @@ jobs:
run: |
brew uninstall cmake
brew update
- brew install --quiet cmake boost hidapi openssl zmq libpgm expat libunwind-headers protobuf ccache
+ brew install --quiet cmake boost hidapi openssl zmq libpgm unbound libunwind-headers protobuf ccache
- name: build
run: |
${{env.CCACHE_SETTINGS}}
make -j${{env.MAKE_JOB_COUNT}}
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: /Users/runner/Library/Caches/ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
build-windows:
name: 'Windows (MSYS2)'
@@ -64,7 +72,9 @@ jobs:
- uses: actions/checkout@v5
with:
submodules: recursive
- - uses: actions/cache@v5
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
with:
path: C:\Users\runneradmin\.ccache
key: ccache-${{ runner.os }}-build-${{ github.sha }}
@@ -72,12 +82,19 @@ jobs:
- uses: msys2/setup-msys2@v2
with:
update: true
+ cache: false
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf-c mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound git
- uses: ./.github/actions/set-make-job-count
- name: build
run: |
${{env.CCACHE_SETTINGS}}
make release-static-win64 -j${{env.MAKE_JOB_COUNT}}
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: C:\Users\runneradmin\.ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
build-arch:
name: 'Arch Linux'
@@ -86,17 +103,32 @@ jobs:
image: archlinux:latest
steps:
- name: install dependencies
- run: pacman -Syyu --noconfirm base-devel git cmake boost boost-libs openssl zeromq unbound libsodium readline expat gtest python3 doxygen graphviz hidapi libusb protobuf
+ run: pacman -Syyu --noconfirm base-devel git cmake boost boost-libs openssl zeromq unbound libsodium readline expat gtest python3 doxygen graphviz hidapi libusb protobuf ccache
- name: configure git
run: git config --global --add safe.directory '*'
- uses: actions/checkout@v5
with:
submodules: recursive
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
+ with:
+ path: ~/.cache/ccache
+ key: ccache-arch-build-${{ github.sha }}
+ restore-keys: ccache-arch-build-
- uses: ./.github/actions/set-make-job-count
- name: build
env:
CMAKE_BUILD_PARALLEL_LEVEL: ${{env.MAKE_JOB_COUNT}}
- run: ${{env.BUILD_DEFAULT_LINUX}}
+ run: |
+ ${{ env.CCACHE_SETTINGS }}
+ ${{ env.BUILD_DEFAULT_LINUX }}
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: ~/.cache/ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
build-debian:
# Oldest supported Debian version
@@ -118,11 +150,26 @@ jobs:
- uses: actions/checkout@v5
with:
submodules: recursive
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
+ with:
+ path: ~/.cache/ccache
+ key: ccache-debian-11-build-${{ github.sha }}
+ restore-keys: ccache-debian-11-build-
- uses: ./.github/actions/set-make-job-count
- name: build
env:
CMAKE_BUILD_PARALLEL_LEVEL: ${{env.MAKE_JOB_COUNT}}
- run: ${{env.BUILD_DEFAULT_LINUX}}
+ run: |
+ ${{ env.CCACHE_SETTINGS }}
+ ${{ env.BUILD_DEFAULT_LINUX }}
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: ~/.cache/ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
build-ubuntu:
name: ${{ matrix.name }}
@@ -131,10 +178,6 @@ jobs:
fail-fast: false
matrix:
include:
- # Oldest supported Ubuntu LTS version
- - name: Ubuntu 20.04
- container: ubuntu:20.04
-
# Most popular Ubuntu LTS version
- name: Ubuntu 22.04
container: ubuntu:22.04
@@ -156,7 +199,9 @@ jobs:
- uses: actions/checkout@v5
with:
submodules: recursive
- - uses: actions/cache@v5
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
with:
path: ~/.ccache
key: ccache-${{ matrix.container }}-build-${{ github.sha }}
@@ -168,10 +213,15 @@ jobs:
run: |
${{env.CCACHE_SETTINGS}}
${{env.BUILD_DEFAULT_LINUX}}
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: ~/.ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
test-ubuntu:
name: "${{ matrix.name }} (tests)"
- needs: build-ubuntu
runs-on: ubuntu-latest
strategy:
matrix:
@@ -203,7 +253,9 @@ jobs:
- uses: actions/checkout@v5
with:
submodules: recursive
- - uses: actions/cache@v5
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
with:
path: ~/.ccache
key: ccache-${{ matrix.container }}-build-${{ github.sha }}
@@ -220,6 +272,12 @@ jobs:
${{env.CCACHE_SETTINGS}}
${{env.BUILD_DEFAULT_LINUX}}
cmake --build build --target test
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: ~/.ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
source-archive:
name: "source archive"
diff --git a/.github/workflows/depends.yml b/.github/workflows/depends.yml
index 2be2a60e5..92345d831 100644
--- a/.github/workflows/depends.yml
+++ b/.github/workflows/depends.yml
@@ -73,28 +73,21 @@ jobs:
fetch-depth: 0
submodules: recursive
# Most volatile cache
- - name: ccache
- uses: actions/cache@v5
+ - name: restore ccache
+ uses: actions/cache/restore@v5
+ id: ccache-restore
with:
path: ~/.ccache
key: ccache-${{ matrix.toolchain.host }}-${{ github.sha }}
restore-keys: ccache-${{ matrix.toolchain.host }}-
# Less volatile cache
- - name: depends cache
- uses: actions/cache@v5
+ - name: restore depends cache
+ uses: actions/cache/restore@v5
+ id: depends-restore
with:
path: contrib/depends/built
key: depends-${{ matrix.toolchain.host }}-${{ hashFiles('contrib/depends/packages/*') }}
- restore-keys: |
- depends-${{ matrix.toolchain.host }}-${{ hashFiles('contrib/depends/packages/*') }}
- depends-${{ matrix.toolchain.host }}-
-# Static cache
- - name: OSX SDK cache
- uses: actions/cache@v5
- with:
- path: contrib/depends/sdk-sources
- key: sdk-${{ matrix.toolchain.host }}-${{ matrix.toolchain.osx_sdk }}
- restore-keys: sdk-${{ matrix.toolchain.host }}-${{ matrix.toolchain.osx_sdk }}
+ restore-keys: depends-${{ matrix.toolchain.host }}-
- name: prepare w64-mingw32
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'i686-w64-mingw32' }}
run: |
@@ -104,6 +97,18 @@ jobs:
run: |
${{env.CCACHE_SETTINGS}}
make depends target=${{ matrix.toolchain.host }} -j4
+ - name: save ccache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.ccache-restore.outputs.cache-hit != 'true'
+ with:
+ path: ~/.ccache
+ key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
+ - name: save depends cache
+ uses: actions/cache/save@v5
+ if: github.event_name != 'pull_request' && steps.depends-restore.outputs.cache-hit != 'true'
+ with:
+ path: contrib/depends/built
+ key: ${{ steps.depends-restore.outputs.cache-primary-key }}
- uses: actions/upload-artifact@v7
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'x86_64-apple-darwin11' || matrix.toolchain.host == 'x86_64-unknown-linux-gnu' }}
with:
diff --git a/.github/workflows/gitian.yml b/.github/workflows/gitian.yml
index 2d2af5799..d3999eff4 100644
--- a/.github/workflows/gitian.yml
+++ b/.github/workflows/gitian.yml
@@ -2,8 +2,17 @@ name: ci/gh-actions/gitian
on:
push:
- tags:
- - '*'
+ paths:
+ - 'contrib/depends/**'
+ - 'contrib/gitian/**'
+ - '!contrib/**.md'
+ - '.github/workflows/gitian.yml'
+ pull_request:
+ paths:
+ - 'contrib/depends/**'
+ - 'contrib/gitian/**'
+ - '!contrib/**.md'
+ - '.github/workflows/gitian.yml'
jobs:
build-gitian:
@@ -24,20 +33,33 @@ jobs:
option: "m"
name: ${{ matrix.operating-system.name }}
steps:
+ - uses: actions/checkout@v5
+ with:
+ submodules: recursive
- name: prepare
run: |
sudo apt update
- curl -O https://raw.githubusercontent.com/monero-project/monero/${{ github.ref_name }}/contrib/gitian/gitian-build.py
+ cp contrib/gitian/gitian-build.py .
chmod +x gitian-build.py
+ - name: set env
+ run: |
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
+ echo "GITIAN_VERSION=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
+ echo "GITIAN_OUTDIR=pull-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
+ echo "GITIAN_EXTRA_FLAGS=--pull" >> $GITHUB_ENV
+ else
+ echo "GITIAN_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
+ echo "GITIAN_OUTDIR=${{ github.ref_name }}" >> $GITHUB_ENV
+ fi
- name: setup
run: |
- ./gitian-build.py --setup --docker github-actions ${{ github.ref_name }}
+ ./gitian-build.py --setup --docker --url https://github.com/${{ github.repository }} ${{ env.GITIAN_EXTRA_FLAGS }} github-actions ${{ env.GITIAN_VERSION }}
- name: build
run: |
- ./gitian-build.py --docker --detach-sign --no-commit --build -j 3 -o ${{ matrix.operating-system.option }} github-actions ${{ github.ref_name }}
+ ./gitian-build.py --docker --url https://github.com/${{ github.repository }} --detach-sign --no-commit --build -j 3 -o ${{ matrix.operating-system.option }} ${{ env.GITIAN_EXTRA_FLAGS }} github-actions ${{ env.GITIAN_VERSION }}
- name: post build
run: |
- cd out/${{ github.ref_name }}
+ cd out/${{ env.GITIAN_OUTDIR }}
shasum -a256 *
echo \`\`\` >> $GITHUB_STEP_SUMMARY
shasum -a256 * >> $GITHUB_STEP_SUMMARY
@@ -46,4 +68,4 @@ jobs:
with:
name: ${{ matrix.operating-system.name }}
path: |
- out/${{ github.ref_name }}/*
+ out/${{ env.GITIAN_OUTDIR }}/*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 001fd0220..149354c4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1153,7 +1153,7 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
if (APPLE)
if(DEPENDS)
- list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework AppKit -framework IOKit")
+ list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework AppKit -framework IOKit -framework Security")
else()
find_library(COREFOUNDATION CoreFoundation)
find_library(APPKIT AppKit)
diff --git a/contrib/depends/funcs.mk b/contrib/depends/funcs.mk
index e08669c98..adb9d2788 100644
--- a/contrib/depends/funcs.mk
+++ b/contrib/depends/funcs.mk
@@ -143,7 +143,7 @@ $(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig
$(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)"
$(1)_build_env+=PATH="$(build_prefix)/bin:$(PATH)"
$(1)_stage_env+=PATH="$(build_prefix)/bin:$(PATH)"
-$(1)_autoconf=./configure --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)"
+$(1)_autoconf=./configure --build=$(BUILD) --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)"
ifeq ($(filter $(1),libusb unbound),)
$(1)_autoconf += --disable-dependency-tracking
diff --git a/contrib/depends/packages/libusb.mk b/contrib/depends/packages/libusb.mk
index c1d9fe6a9..c6767bba0 100644
--- a/contrib/depends/packages/libusb.mk
+++ b/contrib/depends/packages/libusb.mk
@@ -1,8 +1,8 @@
package=libusb
-$(package)_version=1.0.26
+$(package)_version=1.0.30
$(package)_download_path=https://github.com/libusb/libusb/releases/download/v$($(package)_version)
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
-$(package)_sha256_hash=12ce7a61fc9854d1d2a1ffe095f7b5fac19ddba095c259e6067a46500381b5a5
+$(package)_sha256_hash=fea36f34f9156400209595e300840767ab1a385ede1dc7ee893015aea9c6dbaf
define $(package)_preprocess_cmds
autoreconf -i
@@ -15,6 +15,12 @@ define $(package)_set_vars
$(package)_config_opts_darwin=--disable-udev
endef
+# Remove blobs
+define $(package)_preprocess_cmds
+ rm -rf tests/fuzz/corpus && \
+ rm doc/libusb.png
+endef
+
ifneq ($(host_os),darwin)
define $(package)_config_cmds
cp -f $(BASEDIR)/config.guess config.guess &&\
diff --git a/contrib/depends/packages/unbound.mk b/contrib/depends/packages/unbound.mk
index d9ef0076a..3a1692ef0 100644
--- a/contrib/depends/packages/unbound.mk
+++ b/contrib/depends/packages/unbound.mk
@@ -1,10 +1,10 @@
package=unbound
-$(package)_version=1.19.1
+$(package)_version=1.25.1
$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
-$(package)_sha256_hash=bc1d576f3dd846a0739adc41ffaa702404c6767d2b6082deb9f2f97cbb24a3a9
+$(package)_sha256_hash=0fe8b6277b0959cfd17562debac0aa5f71e0b02dc4ffa9c60271c583edab586f
$(package)_dependencies=openssl expat
-$(package)_patches=disable-glibc-reallocarray.patch
+$(package)_patches=disable-glibc-reallocarray.patch hardcode_config_date.patch
define $(package)_set_vars
@@ -20,7 +20,10 @@ endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/disable-glibc-reallocarray.patch &&\
- autoconf
+ patch -p1 < $($(package)_patch_dir)/hardcode_config_date.patch &&\
+ autoconf && \
+ rm doc/*.odp doc/*.pdf contrib/*.tar.gz contrib/*.tar.bz2 &&\
+ rm -rf testdata dnscrypt/testdata
endef
define $(package)_config_cmds
diff --git a/contrib/depends/patches/unbound/hardcode_config_date.patch b/contrib/depends/patches/unbound/hardcode_config_date.patch
new file mode 100644
index 000000000..fd075da29
--- /dev/null
+++ b/contrib/depends/patches/unbound/hardcode_config_date.patch
@@ -0,0 +1,22 @@
+diff --git a/configure.ac b/configure.ac
+index f1c5b04..13f4ce6 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -994,7 +994,7 @@ if test "`uname`" = "Linux"; then
+ GCC_DOCKER_LINTFLAGS='-syntax'
+ AC_SUBST(GCC_DOCKER_LINTFLAGS)
+ fi
+-AX_BUILD_DATE_EPOCH(CONFIG_DATE, [%Y%m%d])
++CONFIG_DATE=20000101
+ AC_ARG_VAR(SOURCE_DATE_EPOCH, [If it is set, it uses the value of that variable instead of the current time as the build timestamp. The format is a unix timestamp. This enables reproducible build output.])
+ AC_SUBST(CONFIG_DATE)
+
+@@ -2559,7 +2559,7 @@ char *unbound_stat_strdup_log(const char *s, const char* file, int line,
+ dnl if we build from source tree, the man pages need @date@ and @version@
+ dnl if this is a distro tarball, that was already done by makedist.sh
+ AC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO])
+-AX_BUILD_DATE_EPOCH(date, [[%b %e, %Y]])
++date='Jan 1, 2000'
+ AC_SUBST(date)
+
+ AC_CONFIG_FILES([Makefile doc/example.conf doc/libunbound.3 doc/unbound.8 doc/unbound-anchor.8 doc/unbound-checkconf.8 doc/unbound.conf.5 doc/unbound-control.8 doc/unbound-host.1 smallapp/unbound-control-setup.sh dnstap/dnstap_config.h dnscrypt/dnscrypt_config.h contrib/libunbound.pc contrib/unbound.socket contrib/unbound.service contrib/unbound_portable.service])
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 73d46fd8b..7b8f45c4d 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -576,32 +576,34 @@ public:
{
if(m_cache_in_buffer.size() < sizeof(bucket_head2))
{
- if(m_cache_in_buffer.size() >= sizeof(uint64_t) && *((uint64_t*)m_cache_in_buffer.span(8).data()) != SWAP64LE(LEVIN_SIGNATURE))
+ if(m_cache_in_buffer.size() >= sizeof(uint64_t))
{
- MWARNING(m_connection_context << "Signature mismatch, connection will be closed");
- return false;
+ std::uint64_t levin_sig;
+ memcpy(&levin_sig, m_cache_in_buffer.span(sizeof(std::uint64_t)).data(), sizeof(std::uint64_t));
+ if (SWAP64LE(LEVIN_SIGNATURE) != levin_sig)
+ {
+ MWARNING(m_connection_context << "Signature mismatch, connection will be closed");
+ return false;
+ }
}
is_continue = false;
break;
}
-#if BYTE_ORDER == LITTLE_ENDIAN
- bucket_head2& phead = *(bucket_head2*)m_cache_in_buffer.span(sizeof(bucket_head2)).data();
-#else
- bucket_head2 phead = *(bucket_head2*)m_cache_in_buffer.span(sizeof(bucket_head2)).data();
- phead.m_signature = SWAP64LE(phead.m_signature);
- phead.m_cb = SWAP64LE(phead.m_cb);
- phead.m_command = SWAP32LE(phead.m_command);
- phead.m_return_code = SWAP32LE(phead.m_return_code);
- phead.m_flags = SWAP32LE(phead.m_flags);
- phead.m_protocol_version = SWAP32LE(phead.m_protocol_version);
+ memcpy(&m_current_head, m_cache_in_buffer.span(sizeof(bucket_head2)).data(), sizeof(bucket_head2));
+#if BYTE_ORDER != LITTLE_ENDIAN
+ m_current_head.m_signature = SWAP64LE(m_current_head.m_signature);
+ m_current_head.m_cb = SWAP64LE(m_current_head.m_cb);
+ m_current_head.m_command = SWAP32LE(m_current_head.m_command);
+ m_current_head.m_return_code = SWAP32LE(m_current_head.m_return_code);
+ m_current_head.m_flags = SWAP32LE(m_current_head.m_flags);
+ m_current_head.m_protocol_version = SWAP32LE(m_current_head.m_protocol_version);
#endif
- if(LEVIN_SIGNATURE != phead.m_signature)
+ if(LEVIN_SIGNATURE != m_current_head.m_signature)
{
LOG_ERROR_CC(m_connection_context, "Signature mismatch, connection will be closed");
return false;
}
- m_current_head = phead;
m_cache_in_buffer.erase(sizeof(bucket_head2));
m_state = stream_state_body;
diff --git a/src/net/host.h b/src/net/host.h
new file mode 100644
index 000000000..c96a7b434
--- /dev/null
+++ b/src/net/host.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <string>
+
+namespace net
+{
+ /*!
+ * \brief Canonicalize a hostname by converting letters to lowercase.
+ *
+ * \param host Hostname to canonicalize in-place.
+ */
+ inline void canonicalize_host(std::string& host) noexcept
+ {
+ for (char& c : host)
+ {
+ if ('A' <= c && c <= 'Z')
+ c = static_cast<char>(c - 'A' + 'a');
+ }
+ }
+}
diff --git a/src/net/i2p_address.cpp b/src/net/i2p_address.cpp
index 4e21085d0..e793048c0 100644
--- a/src/net/i2p_address.cpp
+++ b/src/net/i2p_address.cpp
@@ -36,6 +36,7 @@
#include <limits>
#include "net/error.h"
+#include "net/host.h"
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
#include "string_tools_lexical.h"
@@ -105,10 +106,12 @@ namespace net
expect<i2p_address> i2p_address::make(const boost::string_ref address)
{
boost::string_ref host = address.substr(0, address.rfind(':'));
- MONERO_CHECK(host_check(host));
+ std::string normalized_host{host};
+ net::canonicalize_host(normalized_host);
+ MONERO_CHECK(host_check(normalized_host));
static_assert(b32_length + sizeof(tld) == sizeof(i2p_address::host_), "bad internal host size");
- return i2p_address{host};
+ return i2p_address{normalized_host};
}
bool i2p_address::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
diff --git a/src/net/tor_address.cpp b/src/net/tor_address.cpp
index ac36dbffd..35bd8e9a2 100644
--- a/src/net/tor_address.cpp
+++ b/src/net/tor_address.cpp
@@ -37,6 +37,7 @@
#include <limits>
#include "net/error.h"
+#include "net/host.h"
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
#include "string_tools_lexical.h"
@@ -112,7 +113,9 @@ namespace net
const boost::string_ref port =
address.substr(host.size() + (host.size() == address.size() ? 0 : 1));
- MONERO_CHECK(host_check(host));
+ std::string normalized_host{host};
+ net::canonicalize_host(normalized_host);
+ MONERO_CHECK(host_check(normalized_host));
std::uint16_t porti = default_port;
if (!port.empty() && !epee::string_tools::get_xtype_from_string(porti, std::string{port}))
@@ -120,7 +123,7 @@ namespace net
static_assert(v2_length <= v3_length, "bad internal host size");
static_assert(v3_length + sizeof(tld) == sizeof(tor_address::host_), "bad internal host size");
- return tor_address{host, porti};
+ return tor_address{normalized_host, porti};
}
bool tor_address::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
diff --git a/src/serialization/binary_archive.h b/src/serialization/binary_archive.h
index 07a4ec169..f0c9b1a6d 100644
--- a/src/serialization/binary_archive.h
+++ b/src/serialization/binary_archive.h
@@ -145,7 +145,7 @@ struct binary_archive<false> : public binary_archive_base<false>
{
auto current = bytes_.cbegin();
auto end = bytes_.cend();
- good_ &= (0 <= tools::read_varint(current, end, v));
+ good_ &= (1 <= tools::read_varint(current, end, v));
current = std::min(current, bytes_.cend());
bytes_ = {current, std::size_t(bytes_.cend() - current)};
}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 66b3f1bfc..4c8d54f61 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -4582,6 +4582,7 @@ void wallet2::clear_user_data()
for (auto i = m_transfers.begin(); i != m_transfers.end(); ++i)
i->m_frozen = false;
m_tx_keys.clear();
+ m_additional_tx_keys.clear();
m_tx_notes.clear();
m_address_book.clear();
m_subaddress_labels.clear();
diff --git a/tests/unit_tests/net.cpp b/tests/unit_tests/net.cpp
index 30e5f5589..9633f50e5 100644
--- a/tests/unit_tests/net.cpp
+++ b/tests/unit_tests/net.cpp
@@ -58,6 +58,7 @@
#include "crypto/crypto.h"
#include "net/dandelionpp.h"
#include "net/error.h"
+#include "net/host.h"
#include "net/i2p_address.h"
#include "net/net_utils_base.h"
#include "net/socks.h"
@@ -69,12 +70,23 @@
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
+TEST(host, canonicalize_host)
+{
+ std::string host{"ABCdef123.ONION"};
+ net::canonicalize_host(host);
+ EXPECT_EQ("abcdef123.onion", host);
+}
+
namespace
{
static constexpr const char v2_onion[] =
"xmrto2bturnore26.onion";
static constexpr const char v3_onion[] =
"vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion";
+ static constexpr const char v3_onion_upper[] =
+ "VWW6YBAL4BD7SZMGNCYRUUCPGFKQAHZDDI37KTCEO3AH7NGMCOPNPYYD.ONION";
+ static constexpr const char v3_onion_2[] =
+ "zpv4fa3szgel7vf6jdjeugizdclq2vzkelscs2bhbgnlldzzggcen3ad.onion";
}
TEST(tor_address, constants)
@@ -147,6 +159,10 @@ TEST(tor_address, valid)
EXPECT_STREQ(v3_onion, address1->str().c_str());
EXPECT_TRUE(address1->is_blockable());
+ const auto uppercase = net::tor_address::make(v3_onion_upper);
+ ASSERT_TRUE(uppercase.has_value());
+ EXPECT_EQ(*address1, *uppercase);
+
net::tor_address address2{*address1};
EXPECT_EQ(0u, address2.port());
@@ -532,6 +548,8 @@ namespace
{
static constexpr const char b32_i2p[] =
"vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopn.b32.i2p";
+ static constexpr const char b32_i2p_upper[] =
+ "VWW6YBAL4BD7SZMGNCYRUUCPGFKQAHZDDI37KTCEO3AH7NGMCOPN.B32.I2P";
static constexpr const char b32_i2p_2[] =
"xmrto2bturnore26xmrto2bturnore26xmrto2bturnore26xmr2.b32.i2p";
}
@@ -600,6 +618,10 @@ TEST(i2p_address, valid)
EXPECT_STREQ(b32_i2p, address1->str().c_str());
EXPECT_TRUE(address1->is_blockable());
+ const auto uppercase = net::i2p_address::make(b32_i2p_upper);
+ ASSERT_TRUE(uppercase.has_value());
+ EXPECT_EQ(*address1, *uppercase);
+
net::i2p_address address2{*address1};
EXPECT_EQ(1u, address2.port());