Merge remote-tracking branch 'origin/master' into HEAD

b6a029f222

Multisig functional test broken
This commit is contained in:
Crypto City 2022-08-08 17:44:32 +00:00
commit 088538c160
903 changed files with 15493 additions and 16343 deletions

View File

@ -1,24 +1,30 @@
name: ci/gh-actions/cli
on: [push, pull_request]
on:
push:
pull_request:
paths-ignore:
- 'docs/**'
- '**/README.md'
# The below variables reduce repetitions across similar targets
env:
REMOVE_BUNDLED_BOOST : rm -rf /usr/local/share/boost
BUILD_DEFAULT_LINUX: |
ccache --max-size=150M
cmake -S . -B build -D ARCH="default" -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release && cmake --build build -j3
cmake -S . -B build -D ARCH="default" -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Release && cmake --build build -j3
APT_INSTALL_LINUX: 'sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev libprotobuf-dev protobuf-compiler ccache'
APT_SET_CONF: |
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
CCACHE_SETTINGS: |
ccache --max-size=150M
ccache --set-config=compression=true
jobs:
build-macos:
runs-on: macOS-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
@ -27,19 +33,18 @@ jobs:
- uses: actions/cache@v2
with:
path: /Users/runner/Library/Caches/ccache
key: ccache-macos-build-${{ github.sha }}
restore-keys: ccache-macos-build-
key: ccache-${{ runner.os }}-build-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-build-
- name: install dependencies
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf ccache
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost hidapi openssl zmq libpgm miniupnpc ldns expat libunwind-headers protobuf ccache
- name: build
run: |
ccache --max-size=150M
${{env.CCACHE_SETTINGS}}
make -j3
build-windows:
runs-on: windows-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: C:\Users\runneradmin\.ccache-temp
CCACHE_DIR: C:\Users\runneradmin\.ccache
defaults:
@ -52,15 +57,15 @@ jobs:
- uses: actions/cache@v2
with:
path: C:\Users\runneradmin\.ccache
key: ccache-windows-build-${{ github.sha }}
restore-keys: ccache-windows-build-
key: ccache-${{ runner.os }}-build-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-build-
- uses: eine/setup-msys2@v2
with:
update: true
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 git
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
- name: build
run: |
ccache --max-size=150M
${{env.CCACHE_SETTINGS}}
make release-static-win64 -j2
# See the OS labels and monitor deprecations here:
@ -69,7 +74,6 @@ jobs:
build-ubuntu:
runs-on: ${{ matrix.os }}
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
strategy:
matrix:
@ -81,33 +85,8 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-ubuntu-build-${{ matrix.os }}-${{ github.sha }}
restore-keys: ccache-ubuntu-build-${{ matrix.os }}
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
run: ${{env.APT_SET_CONF}}
- name: update apt
run: sudo apt update
- name: install monero dependencies
run: ${{env.APT_INSTALL_LINUX}}
- name: build
run: ${{env.BUILD_DEFAULT_LINUX}}
libwallet-ubuntu:
runs-on: ubuntu-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-ubuntu-libwallet-${{ github.sha }}
restore-keys: ccache-ubuntu-libwallet-
key: ccache-${{ runner.os }}-build-${{ matrix.os }}-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-build-${{ matrix.os }}
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
@ -118,7 +97,33 @@ jobs:
run: ${{env.APT_INSTALL_LINUX}}
- name: build
run: |
ccache --max-size=150M
${{env.CCACHE_SETTINGS}}
${{env.BUILD_DEFAULT_LINUX}}
libwallet-ubuntu:
runs-on: ubuntu-latest
env:
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-libwallet-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-libwallet-
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
run: ${{env.APT_SET_CONF}}
- name: update apt
run: sudo apt update
- name: install monero dependencies
run: ${{env.APT_INSTALL_LINUX}}
- name: build
run: |
${{env.CCACHE_SETTINGS}}
cmake .
make wallet_api -j3
@ -126,7 +131,6 @@ jobs:
needs: build-ubuntu
runs-on: ubuntu-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
@ -136,8 +140,8 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-ubuntu-build-ubuntu-latest-${{ github.sha }}
restore-keys: ccache-ubuntu-build-ubuntu-latest
key: ccache-${{ runner.os }}-build-ubuntu-latest-${{ github.sha }}
restore-keys: ccache-${{ runner.os }}-build-ubuntu-latest
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
@ -152,6 +156,7 @@ jobs:
env:
CTEST_OUTPUT_ON_FAILURE: ON
run: |
${{env.CCACHE_SETTINGS}}
${{env.BUILD_DEFAULT_LINUX}}
cmake --build build --target test

View File

@ -1,12 +1,25 @@
name: ci/gh-actions/depends
on: [push, pull_request]
on:
push:
pull_request:
paths-ignore:
- 'docs/**'
- '**/README.md'
env:
APT_SET_CONF: |
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
CCACHE_SETTINGS: |
ccache --max-size=150M
ccache --set-config=compression=true
jobs:
build-macos:
build-cross:
runs-on: ubuntu-18.04
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
strategy:
fail-fast: false
@ -33,10 +46,12 @@ jobs:
- name: "x86_64 Linux"
host: "x86_64-unknown-linux-gnu"
packages: "gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
- name: "Cross-Mac"
- name: "Cross-Mac x86_64"
host: "x86_64-apple-darwin11"
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git"
osx_sdk: "10.11"
- name: "Cross-Mac aarch64"
host: "aarch64-apple-darwin11"
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git"
- name: "x86_64 Freebsd"
host: "x86_64-unknown-freebsd"
packages: "clang-8 gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
@ -69,18 +84,9 @@ jobs:
key: sdk-${{ matrix.toolchain.host }}-${{ matrix.toolchain.osx_sdk }}
restore-keys: sdk-${{ matrix.toolchain.host }}-${{ matrix.toolchain.osx_sdk }}
- name: set apt conf
run: |
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
run: ${{env.APT_SET_CONF}}
- name: install dependencies
run: sudo apt update; sudo apt -y install build-essential libtool cmake autotools-dev automake pkg-config bsdmainutils curl git ca-certificates ccache ${{ matrix.toolchain.packages }}
- name: prepare apple-darwin11
if: ${{ matrix.toolchain.host == 'x86_64-apple-darwin11' }}
run: |
mkdir -p contrib/depends/SDKs contrib/depends/sdk-sources
if [ ! -f contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz ]; then curl --location --fail https://bitcoincore.org/depends-sources/sdks/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz -o contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz; fi
if [ -f contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz ]; then tar -C contrib/depends/SDKs -xf contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz; fi
- name: prepare w64-mingw32
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'i686-w64-mingw32' }}
run: |
@ -88,7 +94,7 @@ jobs:
sudo update-alternatives --set ${{ matrix.toolchain.host }}-gcc $(which ${{ matrix.toolchain.host }}-gcc-posix)
- name: build
run: |
ccache --max-size=150M
${{env.CCACHE_SETTINGS}}
make depends target=${{ matrix.toolchain.host }} -j2
- uses: actions/upload-artifact@v2
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'x86_64-apple-darwin11' || matrix.toolchain.host == 'x86_64-unknown-linux-gnu' }}

10
.gitignore vendored
View File

@ -24,6 +24,12 @@ external/miniupnpc/Makefile
miniupnpcstrings.h
version/
ClangBuildAnalyzerSession.txt
# gitian
contrib/gitian/builder/
contrib/gitian/docker/
contrib/gitian/sigs/
# Created by https://www.gitignore.io
### C++ ###
@ -70,6 +76,8 @@ cmake-build-debug/
# KDE directory preferences
.directory
### VSCode ###
.vscode/
### Eclipse ###
*.pydevproject
@ -110,3 +118,5 @@ nbproject
/testnet
__pycache__/
*.pyc
*.log

6
.gitmodules vendored
View File

@ -1,7 +1,3 @@
[submodule "external/unbound"]
path = external/unbound
url = https://git.townforge.net/townforge/unbound
branch = monero
[submodule "external/miniupnp"]
path = external/miniupnp
url = https://git.townforge.net/townforge/miniupnpc
@ -13,7 +9,7 @@
url = https://github.com/trezor/trezor-common.git
[submodule "external/randomx"]
path = external/randomx
url = https://git.townforge.net/townforge/randomx.git
url = https://github.com/tevador/RandomX.git
[submodule "external/urho3d"]
path = external/urho3d
url = https://git.townforge.net/townforge/Urho3D.git

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#
@ -92,6 +92,14 @@ endif()
enable_language(C ASM)
# Require C11/C++11 and disable extensions for all targets
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
function (die msg)
if (NOT WIN32)
string(ASCII 27 Esc)
@ -317,6 +325,16 @@ if(ARCH_ID STREQUAL "s390x")
set(S390X 1)
endif()
if(ARCH_ID STREQUAL "riscv64")
set(RISCV 1)
set(RISCV64 1)
endif()
if(ARCH_ID STREQUAL "riscv32")
set(RISCV 1)
set(RISCV32 1)
endif()
if(WIN32 OR ARM OR PPC64LE OR PPC64 OR PPC)
set(OPT_FLAGS_RELEASE "-O2")
else()
@ -350,7 +368,6 @@ if(NOT MANUAL_SUBMODULES)
message(STATUS "Checking submodules")
check_submodule(external/miniupnp)
check_submodule(external/unbound)
check_submodule(external/rapidjson)
check_submodule(external/trezor-common)
check_submodule(external/randomx)
@ -386,18 +403,6 @@ endif()
message(STATUS "BOOST_IGNORE_SYSTEM_PATHS defaults to ${BOOST_IGNORE_SYSTEM_PATHS_DEFAULT}")
option(BOOST_IGNORE_SYSTEM_PATHS "Ignore boost system paths for local boost installation" ${BOOST_IGNORE_SYSTEM_PATHS_DEFAULT})
if (NOT DEFINED ENV{DEVELOPER_LIBUNBOUND_OLD})
message(STATUS "Could not find DEVELOPER_LIBUNBOUND_OLD in env (not required)")
elseif ("$ENV{DEVELOPER_LIBUNBOUND_OLD}" EQUAL 1)
message(STATUS "Found: env DEVELOPER_LIBUNBOUND_OLD = 1, will use the work around")
add_definitions(-DDEVELOPER_LIBUNBOUND_OLD)
elseif ("$ENV{DEVELOPER_LIBUNBOUND_OLD}" EQUAL 0)
message(STATUS "Found: env DEVELOPER_LIBUNBOUND_OLD = 0")
else()
message(STATUS "Found: env DEVELOPER_LIBUNBOUND_OLD with bad value. Will NOT use the work around")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
enable_testing()
@ -466,15 +471,11 @@ else()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
endif()
link_directories(${Boost_LIBRARY_DIRS})
link_directories(${CMAKE_CURRENT_BINARY_DIR}/external/unbound)
include_directories(external/db_drivers/liblmdb external/rapidjson/include external/easylogging++ src contrib/epee/include external external/supercop/include)
if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
cmake_policy(SET CMP0042 NEW)
endif()
if(MSVC OR MINGW)
@ -485,9 +486,11 @@ endif()
option(STATIC "Link libraries statically" ${DEFAULT_STATIC})
# This is a CMake built-in switch that concerns internal libraries
if (NOT DEFINED BUILD_SHARED_LIBS AND NOT STATIC AND CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS_DEFAULT OFF)
if (NOT STATIC AND CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(BUILD_SHARED_LIBS_DEFAULT ON)
endif()
option(BUILD_SHARED_LIBS "Build internal libraries as shared" ${BUILD_SHARED_LIBS_DEFAULT})
if (BUILD_SHARED_LIBS)
message(STATUS "Building internal libraries with position independent code")
@ -520,6 +523,7 @@ if(STATIC)
set(CMAKE_SKIP_RPATH ON)
endif()
option(SANITIZE "Use ASAN memory sanitizer" OFF)
if(SANITIZE)
if (MSVC)
message(FATAL_ERROR "Cannot sanitize with MSVC")
@ -588,7 +592,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)")
endif ()
if (APPLE AND NOT IOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
if (NOT OPENSSL_ROOT_DIR)
EXECUTE_PROCESS(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
@ -659,6 +663,12 @@ if (WIN32)
list(APPEND OPENSSL_LIBRARIES ws2_32 crypt32)
endif()
if (STATIC AND NOT WIN32)
find_static_header_and_library(UNBOUND_INCLUDE_DIR unbound.h UNBOUND_LIBRARIES libunbound.a)
else()
find_package(Unbound)
endif()
add_definition_if_library_exists(c memset_s "string.h" HAVE_MEMSET_S)
add_definition_if_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO)
add_definition_if_function_found(strptime HAVE_STRPTIME)
@ -683,8 +693,6 @@ if (NOT (MSVC OR ARCH))
set_default_arch()
endif()
CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11)
option(COVERAGE "Enable profiling for test coverage report" OFF)
if(COVERAGE)
message(STATUS "Building with profiling for test coverage report")
@ -737,8 +745,7 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
add_subdirectory(external)
# Final setup for libunbound
include_directories(${UNBOUND_INCLUDE})
link_directories(${UNBOUND_LIBRARY_DIRS})
include_directories(${UNBOUND_INCLUDE_DIR})
# Final setup for easylogging++
include_directories(${EASYLOGGING_INCLUDE})
@ -757,7 +764,7 @@ if (HIDAPI_FOUND)
add_definitions(-DHAVE_HIDAPI)
include_directories(${HIDAPI_INCLUDE_DIR})
link_directories(${LIBHIDAPI_LIBRARY_DIRS})
else (HIDAPI_FOUND)
else()
message(STATUS "Could not find HIDAPI")
endif()
@ -809,7 +816,7 @@ else()
message(STATUS "AES support explicitly disabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_AES")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_AES")
elseif(NOT ARM AND NOT PPC64LE AND NOT PPC64 AND NOT PPC AND NOT S390X)
elseif(NOT ARM AND NOT PPC64LE AND NOT PPC64 AND NOT PPC AND NOT S390X AND NOT RISCV)
message(STATUS "AES support enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
@ -817,6 +824,8 @@ else()
message(STATUS "AES support not available on POWER")
elseif(S390X)
message(STATUS "AES support not available on s390x")
elseif(RISCV)
message(STATUS "AES support not available on RISC-V")
elseif(ARM6)
message(STATUS "AES support not available on ARMv6")
elseif(ARM7)
@ -837,7 +846,7 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(ARM)
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
endif()
@ -858,14 +867,14 @@ else()
endif()
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-static-assert.c" COMPILE_DEFINITIONS "-std=c11")
try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-static-assert.c" CMAKE_FLAGS -DCMAKE_C_STANDARD=11)
if(STATIC_ASSERT_RES)
set(STATIC_ASSERT_FLAG "")
else()
set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert")
endif()
try_compile(STATIC_ASSERT_CPP_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-static-assert.cpp" COMPILE_DEFINITIONS "-std=c++11")
try_compile(STATIC_ASSERT_CPP_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-static-assert.cpp" CMAKE_FLAGS -DCMAKE_CXX_STANDARD=11)
if(STATIC_ASSERT_CPP_RES)
set(STATIC_ASSERT_CPP_FLAG "")
else()
@ -968,8 +977,8 @@ else()
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS} ${LD_BACKCOMPAT_FLAGS}")
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
@ -1073,11 +1082,6 @@ else()
endif()
set(DEBUG_FLAGS "-g3")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
set(DEBUG_FLAGS "${DEBUG_FLAGS} -Og ")
else()
set(DEBUG_FLAGS "${DEBUG_FLAGS} -O0 ")
endif()
# At least some CLANGs default to not enough for monero
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=900")
@ -1143,6 +1147,7 @@ set(Boost_PROGRAM_OPTIONS_LIBRARY ${Boost_LIBRARY_DIRS}/libboost_program_options
set(Boost_SERIALIZATION_LIBRARY ${Boost_LIBRARY_DIRS}/libboost_serialization.a)
set(Boost_THREAD_LIBRARY ${Boost_LIBRARY_DIRS}/libboost_thread.a)
set(Boost_SYSTEM_LIBRARY ${Boost_LIBRARY_DIRS}/libboost_system.a)
add_definitions(-DBOOST_ASIO_ENABLE_SEQUENTIAL_STRAND_ALLOCATION)
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
@ -1309,10 +1314,6 @@ endif()
# when ON - will install libwallet_merged into "lib"
option(BUILD_GUI_DEPS "Build GUI dependencies." OFF)
# This is not nice, distribution packagers should not enable this, but depend
# on libunbound shipped with their distribution instead
option(INSTALL_VENDORED_LIBUNBOUND "Install libunbound binary built from source vendored with this repo." OFF)
find_package(PythonInterp)
find_program(iwyu_tool_path NAMES iwyu_tool.py iwyu_tool)
if (iwyu_tool_path AND PYTHONINTERP_FOUND)

View File

@ -1,4 +1,4 @@
# Portions Copyright (c) 2017-2020, The Monero Project
# Portions Copyright (c) 2017-2022, The Monero Project
# This file is based off of the https://code.google.com/archive/p/ios-cmake/
# It has been altered for Monero iOS development
#

View File

@ -1,192 +1,45 @@
# Multistage docker build, requires docker 17.05
# builder stage
FROM ubuntu:16.04 as builder
FROM ubuntu:20.04 as builder
RUN set -ex && \
apt-get update && \
apt-get --no-install-recommends --yes install \
ca-certificates \
cmake \
g++ \
make \
pkg-config \
graphviz \
doxygen \
git \
curl \
libtool-bin \
autoconf \
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --yes install \
automake \
bzip2 \
xsltproc \
gperf \
unzip
WORKDIR /usr/local
ENV CFLAGS='-fPIC'
ENV CXXFLAGS='-fPIC'
#Cmake
ARG CMAKE_VERSION=3.14.6
ARG CMAKE_VERSION_DOT=v3.14
ARG CMAKE_HASH=4e8ea11cabe459308671b476469eace1622e770317a15951d7b55a82ccaaccb9
RUN set -ex \
&& curl -s -O https://cmake.org/files/${CMAKE_VERSION_DOT}/cmake-${CMAKE_VERSION}.tar.gz \
&& echo "${CMAKE_HASH} cmake-${CMAKE_VERSION}.tar.gz" | sha256sum -c \
&& tar -xzf cmake-${CMAKE_VERSION}.tar.gz \
&& cd cmake-${CMAKE_VERSION} \
&& ./configure \
&& make \
&& make install
## Boost
ARG BOOST_VERSION=1_70_0
ARG BOOST_VERSION_DOT=1.70.0
ARG BOOST_HASH=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778
RUN set -ex \
&& curl -s -L -o boost_${BOOST_VERSION}.tar.bz2 https://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION_DOT}/boost_${BOOST_VERSION}.tar.bz2 \
&& echo "${BOOST_HASH} boost_${BOOST_VERSION}.tar.bz2" | sha256sum -c \
&& tar -xvf boost_${BOOST_VERSION}.tar.bz2 \
&& cd boost_${BOOST_VERSION} \
&& ./bootstrap.sh \
&& ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --with-locale threading=multi threadapi=pthread cflags="$CFLAGS" cxxflags="$CXXFLAGS" stage
ENV BOOST_ROOT /usr/local/boost_${BOOST_VERSION}
# OpenSSL
ARG OPENSSL_VERSION=1.1.1i
ARG OPENSSL_HASH=e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
RUN set -ex \
&& curl -s -O https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \
&& echo "${OPENSSL_HASH} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c \
&& tar -xzf openssl-${OPENSSL_VERSION}.tar.gz \
&& cd openssl-${OPENSSL_VERSION} \
&& ./Configure linux-x86_64 no-shared --static "$CFLAGS" \
&& make build_generated \
&& make libcrypto.a \
&& make install
ENV OPENSSL_ROOT_DIR=/usr/local/openssl-${OPENSSL_VERSION}
# ZMQ
ARG ZMQ_VERSION=v4.3.2
ARG ZMQ_HASH=a84ffa12b2eb3569ced199660bac5ad128bff1f0
RUN set -ex \
&& git clone https://github.com/zeromq/libzmq.git -b ${ZMQ_VERSION} \
&& cd libzmq \
&& test `git rev-parse HEAD` = ${ZMQ_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install \
&& ldconfig
# zmq.hpp
ARG CPPZMQ_VERSION=v4.4.1
ARG CPPZMQ_HASH=f5b36e563598d48fcc0d82e589d3596afef945ae
RUN set -ex \
&& git clone https://github.com/zeromq/cppzmq.git -b ${CPPZMQ_VERSION} \
&& cd cppzmq \
&& test `git rev-parse HEAD` = ${CPPZMQ_HASH} || exit 1 \
&& mv *.hpp /usr/local/include
# Readline
ARG READLINE_VERSION=8.0
ARG READLINE_HASH=e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461
RUN set -ex \
&& curl -s -O https://ftp.gnu.org/gnu/readline/readline-${READLINE_VERSION}.tar.gz \
&& echo "${READLINE_HASH} readline-${READLINE_VERSION}.tar.gz" | sha256sum -c \
&& tar -xzf readline-${READLINE_VERSION}.tar.gz \
&& cd readline-${READLINE_VERSION} \
&& ./configure \
&& make \
&& make install
# Sodium
ARG SODIUM_VERSION=1.0.18
ARG SODIUM_HASH=4f5e89fa84ce1d178a6765b8b46f2b6f91216677
RUN set -ex \
&& git clone https://github.com/jedisct1/libsodium.git -b ${SODIUM_VERSION} \
&& cd libsodium \
&& test `git rev-parse HEAD` = ${SODIUM_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make check \
&& make install
# Udev
ARG UDEV_VERSION=v3.2.8
ARG UDEV_HASH=d69f3f28348123ab7fa0ebac63ec2fd16800c5e0
RUN set -ex \
&& git clone https://github.com/gentoo/eudev -b ${UDEV_VERSION} \
&& cd eudev \
&& test `git rev-parse HEAD` = ${UDEV_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure --disable-gudev --disable-introspection --disable-hwdb --disable-manpages --disable-shared \
&& make \
&& make install
# Libusb
ARG USB_VERSION=v1.0.22
ARG USB_HASH=0034b2afdcdb1614e78edaa2a9e22d5936aeae5d
RUN set -ex \
&& git clone https://github.com/libusb/libusb.git -b ${USB_VERSION} \
&& cd libusb \
&& test `git rev-parse HEAD` = ${USB_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure --disable-shared \
&& make \
&& make install
# Hidapi
ARG HIDAPI_VERSION=hidapi-0.8.0-rc1
ARG HIDAPI_HASH=40cf516139b5b61e30d9403a48db23d8f915f52c
RUN set -ex \
&& git clone https://github.com/signal11/hidapi -b ${HIDAPI_VERSION} \
&& cd hidapi \
&& test `git rev-parse HEAD` = ${HIDAPI_HASH} || exit 1 \
&& ./bootstrap \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install
# Protobuf
ARG PROTOBUF_VERSION=v3.7.1
ARG PROTOBUF_HASH=6973c3a5041636c1d8dc5f7f6c8c1f3c15bc63d6
RUN set -ex \
&& git clone https://github.com/protocolbuffers/protobuf -b ${PROTOBUF_VERSION} \
&& cd protobuf \
&& test `git rev-parse HEAD` = ${PROTOBUF_HASH} || exit 1 \
&& git submodule update --init --recursive \
&& ./autogen.sh \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install \
&& ldconfig
autotools-dev \
bsdmainutils \
build-essential \
ca-certificates \
ccache \
cmake \
curl \
git \
libtool \
pkg-config \
gperf
WORKDIR /src
COPY . .
ENV USE_SINGLE_BUILDDIR=1
ARG NPROC
RUN set -ex && \
git submodule init && git submodule update && \
rm -rf build && \
if [ -z "$NPROC" ] ; \
then make -j$(nproc) release-static ; \
else make -j$NPROC release-static ; \
then make -j$(nproc) depends target=x86_64-linux-gnu ; \
else make -j$NPROC depends target=x86_64-linux-gnu ; \
fi
# runtime stage
FROM ubuntu:16.04
FROM ubuntu:20.04
RUN set -ex && \
apt-get update && \
apt-get --no-install-recommends --yes install ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt
COPY --from=builder /src/build/release/bin /usr/local/bin/
COPY --from=builder /src/build/x86_64-linux-gnu/release/bin /usr/local/bin/
# Create townforge user
RUN adduser --system --group --disabled-password townforge && \
@ -208,5 +61,6 @@ EXPOSE 18081
# switch to user townforge
USER townforge
ENTRYPOINT ["townforged", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18880", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=18881", "--non-interactive", "--confirm-external-bind"]
ENTRYPOINT ["townforged"]
CMD ["--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18880", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=18881", "--non-interactive", "--confirm-external-bind"]

View File

@ -452,7 +452,7 @@ EXTRACT_LOCAL_METHODS = NO
# are hidden.
# The default value is: NO.
EXTRACT_ANON_NSPACES = YES
EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
# undocumented members inside documented classes or files. If set to NO these
@ -805,7 +805,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = */build/* */contrib/depends/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the

View File

@ -1,5 +1,5 @@
Copyright (c) 2014-2021, The Monero Project
Copyright (c) 2019-2021, Crypto City
Copyright (c) 2014-2022, The Monero Project
Copyright (c) 2019-2022, Crypto City
All rights reserved.

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#
@ -96,15 +96,15 @@ release: cmake-release
release-test:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release $(topdir) && $(MAKE) && $(MAKE) test
cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE) && $(MAKE) test
release-all:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE)
release-static:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE)
release-townforge:
mkdir -p $(builddir)/release
@ -118,41 +118,41 @@ coverage:
release-static-linux-armv6:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-armv6" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv6" $(topdir) && $(MAKE)
release-static-linux-armv7:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-armv7" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv7" $(topdir) && $(MAKE)
release-static-android-armv7:
mkdir -p $(builddir)/release/translations
cd $(builddir)/release/translations && cmake ../../../translations && $(MAKE)
cd $(builddir)/release && CC=arm-linux-androideabi-clang CXX=arm-linux-androideabi-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG="android-armv7" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARM_MODE=ON -D CMAKE_ANDROID_ARCH_ABI="armeabi-v7a" ../.. && $(MAKE)
cd $(builddir)/release && CC=arm-linux-androideabi-clang CXX=arm-linux-androideabi-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D ANDROID=true -D BUILD_TAG="android-armv7" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARM_MODE=ON -D CMAKE_ANDROID_ARCH_ABI="armeabi-v7a" ../.. && $(MAKE)
release-static-android-armv8:
mkdir -p $(builddir)/release/translations
cd $(builddir)/release/translations && cmake ../../../translations && $(MAKE)
cd $(builddir)/release && CC=aarch64-linux-android-clang CXX=aarch64-linux-android-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG="android-armv8" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI="arm64-v8a" ../.. && $(MAKE)
cd $(builddir)/release && CC=aarch64-linux-android-clang CXX=aarch64-linux-android-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D ANDROID=true -D BUILD_TAG="android-armv8" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI="arm64-v8a" ../.. && $(MAKE)
release-static-linux-armv8:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-armv8" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv8" $(topdir) && $(MAKE)
release-static-linux-x86_64:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE)
release-static-freebsd-x86_64:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="freebsd-x64" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="freebsd-x64" $(topdir) && $(MAKE)
release-static-mac-x86_64:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="mac-x64" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="mac-x64" $(topdir) && $(MAKE)
release-static-linux-i686:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-x86" $(topdir) && $(MAKE)
cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-x86" $(topdir) && $(MAKE)
release-static-win64:
mkdir -p $(builddir)/release

View File

@ -1,7 +1,7 @@
# Townforge
Copyright (c) 2019-2021 Crypto City
Copyright (c) 2014-2021 The Monero Project.
Copyright (c) 2019-2022 Crypto City
Copyright (c) 2014-2022 The Monero Project.
Portions Copyright (c) 2012-2013 The Cryptonote developers.
## Table of Contents
@ -23,14 +23,14 @@ Portions Copyright (c) 2012-2013 The Cryptonote developers.
## Development resources
- Web: [www.townforge.net](https://www.townforge.net)
- GitHub: [https://git.townforge.net/townforge/townforge](https://git.townforge.net/townforge/townforge)
- Git: [https://git.townforge.net/townforge/townforge](https://git.townforge.net/townforge/townforge)
- Forum: [forum.townforge.net](https://forum.townforge.net)
- IRC: [##townforge on Freenode](https://webchat.freenode.net/?randomnick=1&channels=%23%23townforge&prompt=1&uio=d4)
## Vulnerability response
- If in Monero, refer to the Monero [Vulnerability Response Process](https://github.com/monero-project/meta/blob/master/VULNERABILITY_RESPONSE_PROCESS.md)
- Otherwise, contact moneromooo on Freenode IRC.
- Otherwise, contact moneromooo on irc.libera.chat IRC.
## Introduction
@ -59,7 +59,7 @@ library archives (`.a`).
| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Void pkg | Fedora pkg | Optional | Purpose |
| ------------ | ------------- | -------- | -------------------- | ------------ | ------------------ | ------------------- | -------- | --------------- |
| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
| GCC | 5 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
| CMake | 3.5 | NO | `cmake` | `cmake` | `cmake` | `cmake` | NO | |
| pkg-config | any | NO | `pkg-config` | `base-devel` | `base-devel` | `pkgconf` | NO | |
| OpenSSL | basically any | NO | `libssl-dev` | `openssl` | `libressl-devel` | `openssl-devel` | NO | sha256 sum |
@ -82,26 +82,41 @@ library archives (`.a`).
| libusb | ? | NO | `libusb-1.0-0-dev` | `libusb` | `libusb-devel` | `libusbx-devel` | YES | Hardware wallet |
| libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | `protobuf-devel` | YES | Hardware wallet |
| protoc | ? | NO | `protobuf-compiler` | `protobuf` | `protobuf` | `protobuf-compiler` | YES | Hardware wallet |
| libudev | ? | No | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
| libudev | ? | NO | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
| OpenGL[3] | ? | NO | | | | | NO | Graphics API |
| libudev | ? | No | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
| flex | ? | No | | | | `flex` | NO | Script language |
| bison | ? | No | | | | `bison` | NO | Script language |
| libudev | ? | NO | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
| flex | ? | NO | | | | `flex` | NO | Script language |
| bison | ? | NO | | | | `bison` | NO | Script language |
[1] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must
build the library binary manually. This can be done with the following command ```sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libg* /usr/lib/ ```
build the library binary manually. This can be done with the following command `sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make`
then:
* on Debian:
`sudo mv libg* /usr/lib/`
* on Ubuntu:
`sudo mv lib/libg* /usr/lib/`
[2] libnorm-dev is needed if your zmq library was built with libnorm, and not needed otherwise
[3] An OpenGL implementation may be available from your graphics card vendor, or a software implementation exists: MESA
Install all dependencies at once on Debian/Ubuntu:
``` sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev ccache doxygen graphviz libxinerama-dev libxrender-dev libxext-dev libgl1-mesa-dev xinput ```
```
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz libxinerama-dev libxrender-dev libxext-dev libgl1-mesa-dev xinput
```
Install all dependencies at once on macOS with the provided Brewfile:
``` brew update && brew bundle --file=contrib/brew/Brewfile ```
```
brew update && brew bundle --file=contrib/brew/Brewfile
```
FreeBSD 12.1 one-liner required to build dependencies:
```pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium```
```
pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium unbound
```
### Cloning the repository
@ -114,7 +129,7 @@ If you already have a repo cloned, initialize and update:
`$ cd townforge && git submodule init && git submodule update`
*Note*: If there are submodule differences between branches, you may need
to use ```git submodule sync && git submodule update``` after changing branches
to use `git submodule sync && git submodule update` after changing branches
to build successfully.
### Build instructions
@ -190,15 +205,15 @@ application.
* Download and install the [MSYS2 installer](https://www.msys2.org), either the 64-bit or the 32-bit package, depending on your system.
* Open the MSYS shell via the `MSYS2 Shell` shortcut
* Update packages using pacman:
* Update packages using pacman:
```bash
pacman -Syu
```
* Exit the MSYS shell using Alt+F4
* Exit the MSYS shell using Alt+F4
* Edit the properties for the `MSYS2 Shell` shortcut changing "msys2_shell.bat" to "msys2_shell.cmd -mingw64" for 64-bit builds or "msys2_shell.cmd -mingw32" for 32-bit builds
* Restart MSYS shell via modified shortcut and update packages again using pacman:
* Restart MSYS shell via modified shortcut and update packages again using pacman:
```bash
pacman -Syu
@ -210,13 +225,13 @@ application.
To build for 64-bit Windows:
```bash
pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake 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
pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake 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-unbound
```
To build for 32-bit Windows:
```bash
pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi
pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound
```
* Open the MingW shell via `MinGW-w64-Win64 Shell` shortcut on 64-bit Windows
@ -275,8 +290,8 @@ application.
### On FreeBSD:
The project can be built from scratch by following instructions for Linux above(but use `gmake` instead of `make`).
If you are running Townforge in a jail you need to add `sysvmem="new"` to your jail configuration, otherwise lmdb will throw the error message: `Failed to open lmdb environment: Function not implemented`.
The project can be built from scratch by following instructions for Linux above(but use `gmake` instead of `make`).
If you are running Monero in a jail, you need to add `sysvsem="new"` to your jail configuration, otherwise lmdb will throw the error message: `Failed to open lmdb environment: Function not implemented`.
### On OpenBSD:
@ -367,7 +382,7 @@ You can also cross-compile static binaries on Linux for Windows and macOS with t
* ```make depends target=aarch64-linux-android``` for 64bit android binaries
The required packages are the names for each toolchain on apt. Depending on your distro, they may have different names.
The required packages are the names for each toolchain on apt. Depending on your distro, they may have different names. The `depends` system has been tested on Ubuntu 18.04 and 20.04.
Using `depends` might also be easier to compile Townforge on Windows than using MSYS. Activate Windows Subsystem for Linux (WSL) with a distro (for example Ubuntu), install the apt build-essentials and follow the `depends` steps as depicted above.
@ -479,7 +494,7 @@ DNS_PUBLIC=tcp torsocks ./townforged --p2p-bind-ip 127.0.0.1 --no-igd --rpc-bind
## Pruning
As of May 2020, the full Monero blockchain file is about 100 GB. One can store a pruned blockchain, which is about 30 GB.
As of April 2022, the full Monero blockchain file is about 130 GB. One can store a pruned blockchain, which is about 45 GB.
A pruned blockchain can only serve part of the historical chain data to other peers, but is otherwise identical in
functionality to the full blockchain.
To use a pruned blockchain, it is best to start the initial sync with `--prune-blockchain`. However, it is also possible

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -23,7 +23,7 @@
find_path(Readline_ROOT_DIR
NAMES include/readline/readline.h
PATHS /usr/local/opt/readline/ /opt/local/ /usr/local/ /usr/
PATHS /usr/local/opt/readline/ /opt/homebrew/opt/readline/ /opt/local/ /usr/local/ /usr/
NO_DEFAULT_PATH
)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#
@ -32,7 +32,7 @@
function (get_version_tag_from_git GIT)
execute_process(COMMAND "${GIT}" rev-parse --short=9 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE RET
OUTPUT_VARIABLE COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -49,7 +49,7 @@ function (get_version_tag_from_git GIT)
# Get all the tags
execute_process(COMMAND "${GIT}" tag -l --points-at HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE RET
OUTPUT_VARIABLE TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -2,7 +2,6 @@
SOURCES_PATH ?= $(BASEDIR)/sources
BASE_CACHE ?= $(BASEDIR)/built
SDK_PATH ?= $(BASEDIR)/SDKs
FALLBACK_DOWNLOAD_PATH ?= https://downloads.getmonero.org/depends-sources
BUILD = $(shell ./config.guess)
@ -185,7 +184,6 @@ $(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_
-e 's|@build_tests@|$(build_tests)|' \
-e 's|@depends@|$(host_cmake)|' \
-e 's|@prefix@|$($(host_arch)_$(host_os)_prefix)|'\
-e 's|@sdk@|$(SDK_PATH)|'\
-e 's|@arch@|$(host_arch)|'\
$< > $@
$(AT)touch $@

View File

@ -30,7 +30,7 @@ Common `host-platform-triplets` for cross compilation are:
- `i686-w64-mingw32` for Win32
- `x86_64-w64-mingw32` for Win64
- `x86_64-apple-darwin11` for MacOSX
- `x86_64-apple-darwin11` for MacOSX x86_64
- `arm-linux-gnueabihf` for Linux ARM 32 bit
- `aarch64-linux-gnu` for Linux ARM 64 bit
- `riscv64-linux-gnu` for Linux RISCV 64 bit
@ -43,7 +43,6 @@ The following can be set when running make: make FOO=bar
```
SOURCES_PATH: downloaded sources will be placed here
BASE_CACHE: built packages will be placed here
SDK_PATH: Path where sdk's can be found (used by OSX)
FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up
DEBUG: disable some optimizations and enable more runtime checking
HOST_ID_SALT: Optional salt to use when generating host package ids
@ -59,14 +58,6 @@ download-win: run 'make download-win' to fetch all sources needed for win builds
download-linux: run 'make download-linux' to fetch all sources needed for linux builds
```
#Darwin (macos) builds:
To build with the x86_64-apple-darwin11 you require the mac os developer tools in MacOSX10.11.sdk.
Download it from apple, or search for it on github. Create a new directoty called SDKs in this
directory and place the entire MacOSX10.11.sdk folder in it. The depends build will then pick it up automatically
(without requiring SDK_PATH).
#Mingw builds
Building for 32/64bit mingw requires switching alternatives to a posix mode

View File

@ -133,6 +133,11 @@ $(1)_config_env+=$($(1)_config_env_$(host_arch)) $($(1)_config_env_$(host_arch)_
$(1)_config_env+=$($(1)_config_env_$(host_os)) $($(1)_config_env_$(host_os)_$(release_type))
$(1)_config_env+=$($(1)_config_env_$(host_arch)_$(host_os)) $($(1)_config_env_$(host_arch)_$(host_os)_$(release_type))
$(1)_build_env+=$$($(1)_build_env_$(release_type))
$(1)_build_env+=$($(1)_build_env_$(host_arch)) $($(1)_build_env_$(host_arch)_$(release_type))
$(1)_build_env+=$($(1)_build_env_$(host_os)) $($(1)_build_env_$(host_os)_$(release_type))
$(1)_build_env+=$($(1)_build_env_$(host_arch)_$(host_os)) $($(1)_build_env_$(host_arch)_$(host_os)_$(release_type))
$(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig
$(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig
$(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)"

View File

@ -1,9 +1,12 @@
OSX_MIN_VERSION=10.8
OSX_SDK_VERSION=10.11
OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk
LD64_VERSION=253.9
darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -B $(host_prefix)/native/bin
darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ -B $(host_prefix)/native/bin
LD64_VERSION=609
ifeq (aarch64, $(host_arch))
CC_target=arm64-apple-$(host_os)
else
CC_target=$(host)
endif
darwin_CC=clang -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(host_prefix)/native/SDK/ -mlinker-version=$(LD64_VERSION) -B$(host_prefix)/native/bin/$(host)-
darwin_CXX=clang++ -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(host_prefix)/native/SDK/ -mlinker-version=$(LD64_VERSION) -stdlib=libc++ -B$(host_prefix)/native/bin/$(host)-
darwin_CFLAGS=-pipe
darwin_CXXFLAGS=$(darwin_CFLAGS)
@ -15,4 +18,4 @@ darwin_release_CXXFLAGS=$(darwin_release_CFLAGS)
darwin_debug_CFLAGS=-O1
darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
darwin_native_toolchain=native_cctools
darwin_native_toolchain=native_cctools darwin_sdk

View File

@ -4,7 +4,7 @@ $(package)_download_path=https://downloads.sourceforge.net/project/boost/boost/1
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_sha256_hash=7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332
$(package)_dependencies=libiconv
$(package)_patches=fix_aroptions.patch
$(package)_patches=fix_aroptions.patch fix_arm_arch.patch
define $(package)_set_vars
$(package)_config_opts_release=variant=release
@ -13,7 +13,7 @@ $(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android
$(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared
$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
@ -30,6 +30,7 @@ endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/fix_aroptions.patch &&\
patch -p1 < $($(package)_patch_dir)/fix_arm_arch.patch &&\
echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <arflags>\"$($(package)_arflags)\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
endef

View File

@ -0,0 +1,10 @@
package=darwin_sdk
$(package)_version=11.1
$(package)_download_path=https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/
$(package)_file_name=MacOSX$($(package)_version).sdk.tar.xz
$(package)_sha256_hash=68797baaacb52f56f713400de306a58a7ca00b05c3dc6d58f0a8283bcac721f8
define $(package)_stage_cmds
mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/SDK &&\
mv * $($(package)_staging_dir)/$(host_prefix)/native/SDK
endef

View File

@ -1,8 +1,8 @@
package=expat
$(package)_version=2.2.4
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_4
$(package)_version=2.4.1
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_4_1
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=03ad85db965f8ab2d27328abcf0bc5571af6ec0a414874b2066ee3fdd372019e
$(package)_sha256_hash=2f9b6a580b94577b150a7d5617ad4643a4301a6616ff459307df3e225bcfbf40
define $(package)_set_vars
$(package)_config_opts=--enable-static
@ -11,7 +11,7 @@ $(package)_config_opts+=--prefix=$(host_prefix)
endef
define $(package)_config_cmds
$($(package)_autoconf) $($(package)_config_opts)
$($(package)_autoconf)
endef
define $(package)_build_cmds

View File

@ -1,14 +1,14 @@
package=hidapi
$(package)_version=0.9.0
$(package)_version=0.11.0
$(package)_download_path=https://github.com/libusb/hidapi/archive
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=630ee1834bdd5c5761ab079fd04f463a89585df8fcae51a7bfe4229b1e02a652
$(package)_sha256_hash=391d8e52f2d6a5cf76e2b0c079cfefe25497ba1d4659131297081fc0cd744632
$(package)_linux_dependencies=libusb eudev
$(package)_patches=missing_win_include.patch
define $(package)_set_vars
$(package)_config_opts=--enable-static --disable-shared
$(package)_config_opts+=--prefix=$(host_prefix)
$(package)_config_opts_darwin+=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
$(package)_config_opts_linux+=libudev_LIBS="-L$(host_prefix)/lib -ludev"
$(package)_config_opts_linux+=libudev_CFLAGS=-I$(host_prefix)/include
$(package)_config_opts_linux+=libusb_LIBS="-L$(host_prefix)/lib -lusb-1.0"
@ -16,9 +16,12 @@ $(package)_config_opts_linux+=libusb_CFLAGS=-I$(host_prefix)/include/libusb-1.0
$(package)_config_opts_linux+=--with-pic
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/missing_win_include.patch && ./bootstrap
endef
define $(package)_config_cmds
./bootstrap &&\
$($(package)_autoconf) $($(package)_config_opts) AR_FLAGS=$($(package)_arflags)
$($(package)_autoconf) AR_FLAGS=$($(package)_arflags)
endef
define $(package)_build_cmds

View File

@ -1,8 +1,8 @@
package=ldns
$(package)_version=1.6.17
$(package)_download_path=https://www.nlnetlabs.nl/downloads/ldns/
$(package)_version=1.7.1
$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=8b88e059452118e8949a2752a55ce59bc71fa5bc414103e17f5b6b06f9bcc8cd
$(package)_sha256_hash=8ac84c16bdca60e710eea75782356f3ac3b55680d40e1530d7cea474ac208229
$(package)_dependencies=openssl
define $(package)_set_vars

View File

@ -1,50 +1,17 @@
package=native_cctools
$(package)_version=807d6fd1be5d2224872e381870c0a75387fe05e6
$(package)_download_path=https://github.com/theuni/cctools-port/archive
$(package)_version=04663295d0425abfac90a42440a7ec02d7155fea
$(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive
$(package)_download_file=$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=a09c9ba4684670a0375e42d9d67e7f12c1f62581a27f28f7c825d6d7032ccc6a
$(package)_sha256_hash=70a7189418c2086d20c299c5d59250cf5940782c778892ccc899c66516ed240e
$(package)_build_subdir=cctools
$(package)_clang_version=3.7.1
$(package)_clang_download_path=http://llvm.org/releases/$($(package)_clang_version)
$(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz
$(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz
$(package)_clang_sha256_hash=99b28a6b48e793705228a390471991386daa33a9717cd9ca007fcdde69608fd9
$(package)_extra_sources=$($(package)_clang_file_name)
$(package)_patches=skip_otool.patch
define $(package)_fetch_cmds
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash))
endef
define $(package)_extract_cmds
mkdir -p $($(package)_extract_dir) && \
echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \
mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \
tar --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \
rm -f toolchain/lib/libc++abi.so* && \
echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \
echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \
chmod +x toolchain/bin/$(host)-dsymutil && \
tar --strip-components=1 -xf $($(package)_source)
endef
$(package)_dependencies=native_clang native_libtapi
define $(package)_set_vars
$(package)_config_opts=--target=$(host) --disable-lto-support
$(package)_config_opts=--target=$(host) --disable-lto-support --with-libtapi=$(host_prefix)
$(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib
$(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang
$(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++
endef
# If clang gets updated to a version with a fix for https://reviews.llvm.org/D50559
# then the patch that skips otool can be removed.
define $(package)_preprocess_cmds
patch -p0 < $($(package)_patch_dir)/skip_otool.patch && \
cd $($(package)_build_subdir); ./autogen.sh && \
sed -i.old "/define HAVE_PTHREADS/d" ld64/src/ld/InputFiles.h
$(package)_cc=$(host_prefix)/native/bin/clang
$(package)_cxx=$(host_prefix)/native/bin/clang++
endef
define $(package)_config_cmds
@ -57,15 +24,5 @@ endef
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install && \
cp $($(package)_extract_dir)/cctools/misc/install_name_tool $($(package)_staging_prefix_dir)/bin/ &&\
cd $($(package)_extract_dir)/toolchain && \
mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include && \
mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \
cp bin/clang $($(package)_staging_prefix_dir)/bin/ &&\
cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\
cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \
cp -rf lib/clang/$($(package)_clang_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include/ && \
cp bin/llvm-dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \
if `test -d include/c++/`; then cp -rf include/c++/ $($(package)_staging_prefix_dir)/include/; fi && \
if `test -d lib/c++/`; then cp -rf lib/c++/ $($(package)_staging_prefix_dir)/lib/; fi
cp $($(package)_extract_dir)/cctools/misc/install_name_tool $($(package)_staging_prefix_dir)/bin/
endef

View File

@ -0,0 +1,29 @@
package=native_clang
$(package)_version=9.0.0
$(package)_download_path=https://releases.llvm.org/$($(package)_version)
$(package)_download_file=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz
$(package)_file_name=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz
$(package)_sha256_hash=a23b082b30c128c9831dbdd96edad26b43f56624d0ad0ea9edec506f5385038d
define $(package)_extract_cmds
echo $($(package)_sha256_hash) $($(package)_source) | sha256sum -c &&\
mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \
tar --strip-components=1 -C toolchain -xf $($(package)_source) && \
rm -f toolchain/lib/libc++abi.so* && \
echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \
echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \
chmod +x toolchain/bin/$(host)-dsymutil
endef
define $(package)_stage_cmds
cd $($(package)_extract_dir)/toolchain && \
mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include && \
mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \
cp bin/clang $($(package)_staging_prefix_dir)/bin/ &&\
cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\
cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \
cp -rf lib/clang/$($(package)_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include/ && \
cp bin/dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \
if `test -d include/c++/`; then cp -rf include/c++/ $($(package)_staging_prefix_dir)/include/; fi && \
if `test -d lib/c++/`; then cp -rf lib/c++/ $($(package)_staging_prefix_dir)/lib/; fi
endef

View File

@ -0,0 +1,28 @@
package=native_libtapi
$(package)_version=664b8414f89612f2dfd35a9b679c345aa5389026
$(package)_download_path=https://github.com/tpoechtrager/apple-libtapi/archive
$(package)_download_file=$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=62e419c12d1c9fad67cc1cd523132bc00db050998337c734c15bc8d73cc02b61
$(package)_build_subdir=build
$(package)_dependencies=native_clang
define $(package)_config_cmds
echo -n $(build_prefix) > INSTALLPREFIX; \
CC=$(host_prefix)/native/bin/clang CXX=$(host_prefix)/native/bin/clang++ \
cmake -DCMAKE_INSTALL_PREFIX=$(build_prefix) \
-DLLVM_INCLUDE_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DTAPI_REPOSITORY_STRING="1100.0.11" \
-DTAPI_FULL_VERSION="11.0.0" \
-DCMAKE_CXX_FLAGS="-I $($(package)_extract_dir)/src/llvm/projects/clang/include -I $($(package)_build_dir)/projects/clang/include" \
$($(package)_extract_dir)/src/llvm
endef
define $(package)_build_cmds
$(MAKE) clangBasic && $(MAKE) libtapi
endef
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install-libtapi install-tapi-headers
endef

View File

@ -7,8 +7,7 @@ $(package)_patches=fallback.c
define $(package)_set_vars
$(package)_build_opts=CC="$($(package)_cc)"
$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" ARFLAGS=$($(package)_arflags) cf_cv_ar_flags=""
$(package)_config_env_darwin=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
$(package)_config_env=cf_cv_ar_flags=""
$(package)_config_opts=--prefix=$(host_prefix)
$(package)_config_opts+=--disable-shared
$(package)_config_opts+=--with-build-cc=gcc
@ -51,7 +50,7 @@ define $(package)_preprocess_cmds
endef
define $(package)_config_cmds
./configure $($(package)_config_opts)
$($(package)_autoconf)
endef
define $(package)_build_cmds

View File

@ -1,15 +1,14 @@
package=openssl
$(package)_version=1.1.1k
$(package)_version=1.1.1l
$(package)_download_path=https://www.openssl.org/source
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
$(package)_sha256_hash=0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
$(package)_patches=fix_darwin.patch
define $(package)_set_vars
$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
$(package)_config_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_config_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_build_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_build_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_config_env_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_build_env_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl
$(package)_config_opts+=no-capieng
$(package)_config_opts+=no-dso
@ -39,6 +38,7 @@ $(package)_config_opts_arm_linux=linux-generic32
$(package)_config_opts_aarch64_linux=linux-generic64
$(package)_config_opts_arm_android=--static android-arm
$(package)_config_opts_aarch64_android=--static android-arm64
$(package)_config_opts_aarch64_darwin=darwin64-arm64-cc
$(package)_config_opts_riscv64_linux=linux-generic64
$(package)_config_opts_mipsel_linux=linux-generic32
$(package)_config_opts_mips_linux=linux-generic32
@ -51,7 +51,7 @@ endef
define $(package)_preprocess_cmds
sed -i.old 's|"engines", "apps", "test", "util", "tools", "fuzz"|"engines", "tools"|' Configure && \
sed -i -e 's|cflags --sysroot.*",|cflags",|' Configurations/15-android.conf
patch -p1 < $($(package)_patch_dir)/fix_darwin.patch
endef
define $(package)_config_cmds
@ -59,11 +59,11 @@ define $(package)_config_cmds
endef
define $(package)_build_cmds
$(MAKE) -j1 build_libs libcrypto.pc libssl.pc openssl.pc
$(MAKE) build_libs
endef
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw
$(MAKE) DESTDIR=$($(package)_staging_dir) install_sw
endef
define $(package)_postprocess_cmds

View File

@ -1,6 +1,9 @@
packages:=boost openssl zeromq libiconv
packages:=boost openssl zeromq libiconv expat ldns unbound
# ccache is useless in gitian builds
ifneq ($(GITIAN),1)
native_packages := native_ccache
endif
hardware_packages := hidapi protobuf libusb
hardware_native_packages := native_protobuf
@ -8,8 +11,8 @@ hardware_native_packages := native_protobuf
android_native_packages = android_ndk
android_packages = ncurses readline sodium
darwin_native_packages = native_biplist native_ds_store native_mac_alias $(hardware_native_packages)
darwin_packages = sodium ncurses readline $(hardware_packages)
darwin_native_packages = $(hardware_native_packages)
darwin_packages = ncurses readline sodium $(hardware_packages)
# not really native...
freebsd_native_packages = freebsd_base
@ -31,6 +34,6 @@ mingw32_packages = icu4c sodium $(hardware_packages)
mingw32_native_packages = $(hardware_native_packages)
ifneq ($(build_os),darwin)
darwin_native_packages += native_cctools native_cdrkit native_libdmg-hfsplus
darwin_native_packages += darwin_sdk native_clang native_cctools native_libtapi
endif

View File

@ -5,12 +5,17 @@ $(package)_file_name=$(native_$(package)_file_name)
$(package)_sha256_hash=$(native_$(package)_sha256_hash)
$(package)_dependencies=native_$(package)
$(package)_cxxflags=-std=c++11
$(package)_patches=visibility.patch
define $(package)_set_vars
$(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc
$(package)_config_opts_linux=--with-pic
endef
define $(package)_preprocess_cmds
patch -p0 < $($(package)_patch_dir)/visibility.patch
endef
define $(package)_config_cmds
$($(package)_autoconf) AR_FLAGS=$($(package)_arflags)
endef

View File

@ -7,19 +7,16 @@ $(package)_dependencies=ncurses
define $(package)_set_vars
$(package)_build_opts=CC="$($(package)_cc)"
$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" LDFLAGS="-L$(host_prefix)/lib" ARFLAGS=$($(package)_arflags)
$(package)_config_env_darwin=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
$(package)_config_opts+=--prefix=$(host_prefix)
$(package)_config_opts+=--exec-prefix=$(host_prefix)
$(package)_config_opts+=--host=$(HOST)
$(package)_config_opts+=--disable-shared --with-curses
$(package)_config_opts_release=--disable-debug-mode
$(package)_config_opts_darwin+=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
$(package)_build_opts=CFLAGS="$($(package)_cflags) $($(package)_cppflags) -fPIC"
endef
define $(package)_config_cmds
./configure $($(package)_config_opts)
$($(package)_autoconf)
endef
define $(package)_build_cmds

View File

@ -8,15 +8,16 @@ $(package)_patches=disable-glibc-getrandom-getentropy.patch fix-whitespace.patch
define $(package)_set_vars
$(package)_config_opts=--enable-static --disable-shared
$(package)_config_opts+=--prefix=$(host_prefix)
$(package)_config_opts_android=RANLIB=$($(package)_ranlib) AR=$($(package)_ar) CC=$($(package)_cc)
$(package)_config_opts_darwin=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)"
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/disable-glibc-getrandom-getentropy.patch &&\
autoconf &&\
patch -p1 < $($(package)_patch_dir)/fix-whitespace.patch
endef
define $(package)_config_cmds
patch -p1 < $($(package)_patch_dir)/disable-glibc-getrandom-getentropy.patch &&\
./autogen.sh &&\
patch -p1 < $($(package)_patch_dir)/fix-whitespace.patch &&\
$($(package)_autoconf) $($(package)_config_opts) AR_FLAGS=$($(package)_arflags)
$($(package)_autoconf) AR_FLAGS=$($(package)_arflags)
endef
define $(package)_build_cmds

View File

@ -1,19 +1,26 @@
package=unbound
$(package)_version=1.6.8
$(package)_download_path=https://www.unbound.net/downloads/
$(package)_version=1.15.0
$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=e3b428e33f56a45417107448418865fe08d58e0e7fea199b855515f60884dd49
$(package)_sha256_hash=a480dc6c8937447b98d161fe911ffc76cfaffa2da18788781314e81339f1126f
$(package)_dependencies=openssl expat ldns
$(package)_patches=disable-glibc-reallocarray.patch
define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) --with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads
$(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) --with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_w64=--enable-static-exe --sysconfdir=/etc --prefix=$(host_prefix) --target=$(host_prefix)
$(package)_build_opts_mingw32=LDFLAGS="$($(package)_ldflags) -lpthread"
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/disable-glibc-reallocarray.patch &&\
autoconf
endef
define $(package)_config_cmds
$($(package)_autoconf) $($(package)_config_opts)
$($(package)_autoconf) ac_cv_func_getentropy=no
endef
define $(package)_build_cmds

View File

@ -1,8 +1,8 @@
package=unwind
$(package)_version=1.2
$(package)_version=1.5.0
$(package)_download_path=https://download.savannah.nongnu.org/releases/libunwind
$(package)_file_name=lib$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=1de38ffbdc88bd694d10081865871cd2bfbb02ad8ef9e1606aee18d65532b992
$(package)_sha256_hash=90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1efb1017
$(package)_patches=fix_obj_order.patch
define $(package)_preprocess_cmds
@ -12,7 +12,7 @@ endef
define $(package)_config_cmds
cp -f $(BASEDIR)/config.guess config/config.guess &&\
cp -f $(BASEDIR)/config.sub config/config.sub &&\
$($(package)_autoconf) --disable-shared --enable-static AR_FLAGS=$($(package)_arflags)
$($(package)_autoconf) --disable-shared --enable-static --disable-tests --disable-documentation AR_FLAGS=$($(package)_arflags)
endef
define $(package)_build_cmds

View File

@ -1,9 +1,9 @@
package=zeromq
$(package)_version=4.1.7
$(package)_download_path=https://github.com/zeromq/zeromq4-1/releases/download/v$($(package)_version)/
$(package)_version=4.3.4
$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=31c383cfcd3be1dc8a66e448c403029e793687e70473b89c4cc0bd626e7da299
$(package)_patches=9114d3957725acd34aa8b8d011585812f3369411.patch 9e6745c12e0b100cd38acecc16ce7db02905e27c.patch ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch
$(package)_sha256_hash=c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5
$(package)_patches=06aba27b04c5822cb88a69677382a0f053367143.patch
define $(package)_set_vars
$(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve
@ -13,10 +13,7 @@ define $(package)_set_vars
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/9114d3957725acd34aa8b8d011585812f3369411.patch && \
patch -p1 < $($(package)_patch_dir)/9e6745c12e0b100cd38acecc16ce7db02905e27c.patch && \
patch -p1 < $($(package)_patch_dir)/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch && \
./autogen.sh
patch -p1 < $($(package)_patch_dir)/06aba27b04c5822cb88a69677382a0f053367143.patch
endef
define $(package)_config_cmds
@ -24,7 +21,7 @@ define $(package)_config_cmds
endef
define $(package)_build_cmds
$(MAKE) libzmq.la
$(MAKE) src/libzmq.la
endef
define $(package)_stage_cmds

View File

@ -0,0 +1,11 @@
--- boost_1_64_0/tools/build/src/tools/darwin.jam.O 2017-04-17 03:22:26.000000000 +0100
+++ boost_1_64_0/tools/build/src/tools/darwin.jam 2022-05-04 17:26:29.984464447 +0000
@@ -505,7 +505,7 @@
if $(instruction-set) {
options = -arch$(_)$(instruction-set) ;
} else {
- options = -arch arm ;
+# options = -arch arm ;
}
}
}

View File

@ -0,0 +1,21 @@
From a77b066311da42ed7654e39c0356a3b951b2e296 Mon Sep 17 00:00:00 2001
From: selsta <selsta@sent.at>
Date: Wed, 10 Nov 2021 02:28:54 +0100
Subject: [PATCH] windows: add missing include for mingw32
---
windows/hid.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/windows/hid.c b/windows/hid.c
index 24756a4..6d8394c 100644
--- a/windows/hid.c
+++ b/windows/hid.c
@@ -33,6 +33,7 @@ typedef LONG NTSTATUS;
#endif
#ifdef __MINGW32__
+#include <devpropdef.h>
#include <ntdef.h>
#include <winbase.h>
#endif

View File

@ -1,12 +0,0 @@
--- cctools/Makefile.am.O 2016-06-09 15:06:16.000000000 +0100
+++ cctools/Makefile.am 2019-11-18 08:59:20.078663220 +0000
@@ -1,7 +1,7 @@
if ISDARWIN
-SUBDIRS=libstuff ar as misc otool ld64 $(LD_CLASSIC)
+SUBDIRS=libstuff ar as misc ld64 $(LD_CLASSIC)
else
-SUBDIRS=libstuff ar as misc libobjc2 otool ld64 $(LD_CLASSIC)
+SUBDIRS=libstuff ar as misc ld64 $(LD_CLASSIC)
endif
ACLOCAL_AMFLAGS = -I m4

View File

@ -0,0 +1,60 @@
From 96ac8f13f4d0ee96baf5724d9f96c44c34b8606c Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Tue, 24 Aug 2021 22:40:14 +0100
Subject: [PATCH] Darwin platform allows to build on releases before
Yosemite/ios 8.
issue #16407 #16408
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16409)
---
crypto/rand/rand_unix.c | 5 +----
include/crypto/rand.h | 10 ++++++++++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
index 43f1069d151d..0f4525106af7 100644
--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -34,9 +34,6 @@
#if defined(__OpenBSD__)
# include <sys/param.h>
#endif
-#if defined(__APPLE__)
-# include <CommonCrypto/CommonRandom.h>
-#endif
#if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
# include <sys/types.h>
@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen)
if (errno != ENOSYS)
return -1;
}
-# elif defined(__APPLE__)
+# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM)
if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
return (ssize_t)buflen;
diff --git a/include/crypto/rand.h b/include/crypto/rand.h
index 5350d3a93119..674f840fd13c 100644
--- a/include/crypto/rand.h
+++ b/include/crypto/rand.h
@@ -20,6 +20,16 @@
# include <openssl/rand.h>
+# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM)
+# include <Availability.h>
+# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \
+ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000)
+# define OPENSSL_APPLE_CRYPTO_RANDOM 1
+# include <CommonCrypto/CommonCryptoError.h>
+# include <CommonCrypto/CommonRandom.h>
+# endif
+# endif
+
/* forward declaration */
typedef struct rand_pool_st RAND_POOL;

View File

@ -0,0 +1,159 @@
--- src/google/protobuf/descriptor.cc.O 2018-07-30 22:16:10.000000000 +0000
+++ src/google/protobuf/descriptor.cc 2022-05-06 13:38:14.827309092 +0000
@@ -32,6 +32,9 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
#include <algorithm>
#include <functional>
#include <google/protobuf/stubs/hash.h>
@@ -7274,3 +7277,6 @@
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/extension_set.cc.O 2018-07-23 20:56:42.000000000 +0000
+++ src/google/protobuf/extension_set.cc 2022-05-06 14:48:55.369877050 +0000
@@ -32,6 +32,9 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
#include <google/protobuf/stubs/hash.h>
#include <tuple>
#include <utility>
@@ -1914,3 +1917,6 @@
} // namespace internal
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/extension_set_heavy.cc.O 2018-07-30 22:16:10.000000000 +0000
+++ src/google/protobuf/extension_set_heavy.cc 2022-05-06 14:14:27.847320946 +0000
@@ -35,6 +35,10 @@
// Contains methods defined in extension_set.h which cannot be part of the
// lite library because they use descriptors or reflection.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
+
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/coded_stream.h>
@@ -814,3 +818,6 @@
} // namespace internal
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/generated_message_reflection.cc.O 2018-07-23 20:56:42.000000000 +0000
+++ src/google/protobuf/generated_message_reflection.cc 2022-05-06 13:38:49.655540772 +0000
@@ -32,6 +32,9 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
#include <algorithm>
#include <set>
@@ -2420,3 +2423,6 @@
} // namespace internal
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/map_field.cc.O 2018-07-23 20:56:42.000000000 +0000
+++ src/google/protobuf/map_field.cc 2022-05-06 13:34:44.913905697 +0000
@@ -28,6 +28,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
+
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_field_inl.h>
@@ -462,3 +466,6 @@
} // namespace internal
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/text_format.cc.O 2018-07-30 22:16:11.000000000 +0000
+++ src/google/protobuf/text_format.cc 2022-05-06 13:34:58.881999517 +0000
@@ -32,6 +32,10 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
+
#include <algorithm>
#include <float.h>
#include <math.h>
@@ -2258,3 +2262,6 @@
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/wire_format.cc.O 2018-07-23 20:56:42.000000000 +0000
+++ src/google/protobuf/wire_format.cc 2022-05-06 13:06:23.294219228 +0000
@@ -32,6 +32,10 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
+
#include <stack>
#include <string>
#include <vector>
@@ -1445,3 +1449,7 @@
} // namespace internal
} // namespace protobuf
} // namespace google
+
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif
--- src/google/protobuf/stubs/status.cc.O 2018-07-23 20:56:42.000000000 +0000
+++ src/google/protobuf/stubs/status.cc 2022-05-06 15:18:53.393208814 +0000
@@ -27,6 +27,11 @@
// 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.
+
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility push(hidden)
+#endif
+
#include <google/protobuf/stubs/status.h>
#include <ostream>
@@ -132,3 +137,6 @@
} // namespace util
} // namespace protobuf
} // namespace google
+#if defined(__APPLE__) && defined(__arm64__)
+#pragma GCC visibility pop
+#endif

View File

@ -0,0 +1,14 @@
diff --git a/configure.ac b/configure.ac
index 5c7da197..e2b25288 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1702,6 +1702,9 @@ AC_LINK_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
#ifndef _OPENBSD_SOURCE
#define _OPENBSD_SOURCE 1
#endif
+#ifdef __linux__
+# error reallocarray() is currently disabled on Linux to support glibc < 2.26
+#endif
#include <stdlib.h>
int main(void) {
void* p = reallocarray(NULL, 10, 100);

View File

@ -1,9 +1,9 @@
--- config/ltmain.sh.O 2017-01-13 16:00:54.000000000 +0000
+++ config/ltmain.sh 2019-11-17 06:46:51.994402494 +0000
@@ -7957,6 +7957,8 @@
esac
done
--- config/ltmain.sh.0 2020-11-10 17:25:26.000000000 +0100
+++ config/ltmain.sh 2021-09-11 19:39:36.000000000 +0200
@@ -10768,6 +10768,8 @@
fi
func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
tool_oldlib=$func_to_tool_file_result
+ oldobjs=`for obj in $oldobjs; do echo $obj; done | sort`
+ oldobjs=" `echo $oldobjs`"
eval cmds=\"$old_archive_cmds\"

View File

@ -0,0 +1,22 @@
From 06aba27b04c5822cb88a69677382a0f053367143 Mon Sep 17 00:00:00 2001
From: sabotagebeats <27985126+sabotagebeats@users.noreply.github.com>
Date: Thu, 22 Jul 2021 21:53:19 -0700
Subject: [PATCH] fix: building libzmq fails with error src/clock.cpp:131:16:
error: unused variable 'nsecs_per_usec'
---
src/clock.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/clock.cpp b/src/clock.cpp
index 93da90a8e..63c0100a5 100644
--- a/src/clock.cpp
+++ b/src/clock.cpp
@@ -195,6 +195,7 @@ uint64_t zmq::clock_t::now_us ()
#else
+ LIBZMQ_UNUSED (nsecs_per_usec);
// Use POSIX gettimeofday function to get precise time.
struct timeval tv;
int rc = gettimeofday (&tv, NULL);

View File

@ -1,22 +0,0 @@
From 9114d3957725acd34aa8b8d011585812f3369411 Mon Sep 17 00:00:00 2001
From: Jeroen Ooms <jeroenooms@gmail.com>
Date: Tue, 20 Oct 2015 13:10:38 +0200
Subject: [PATCH] enable static libraries on mingw
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 393505b..e92131a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -265,7 +265,7 @@ case "${host_os}" in
libzmq_dso_visibility="no"
if test "x$enable_static" = "xyes"; then
- AC_MSG_ERROR([Building static libraries is not supported under MinGW32])
+ CPPFLAGS="-DZMQ_STATIC"
fi
# Set FD_SETSIZE to 1024

View File

@ -1,22 +0,0 @@
From 9e6745c12e0b100cd38acecc16ce7db02905e27c Mon Sep 17 00:00:00 2001
From: David Millard <dmillard10@gmail.com>
Date: Tue, 10 May 2016 13:53:53 -0700
Subject: [PATCH] Fix autotools for static MinGW builds
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 5a0fa14..def6ea7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,7 +259,7 @@ case "${host_os}" in
libzmq_dso_visibility="no"
if test "x$enable_static" = "xyes"; then
- CPPFLAGS="-DZMQ_STATIC"
+ CPPFLAGS="-DZMQ_STATIC $CPPFLAGS"
fi
# Set FD_SETSIZE to 1024

View File

@ -1,38 +0,0 @@
From ffe62d3398d5e0191f554f61049aa7ec9fc892ae Mon Sep 17 00:00:00 2001
From: Gregory Lemercier <greglemercier@free.fr>
Date: Sun, 7 Oct 2018 18:06:54 +0200
Subject: [PATCH] Fix build on arm64 architectures with some strict compilers
This patch fixes an issue that occurs on 64-bit architetures under
strict compiler rules. The code initially checked that the received
size stored in 'uint64_t' was not bigger than the max value of a
'size_t' variable, which is legitimate on 32-bit architectures where
'size_t' variables are stored on 32 bits. On 64-bit architectures,
this test no longer makes sense since 'uint64_t' and 'size_t' types
have the same size. The issue is fixed by ignoring this portion
of code when built for arm64.
---
src/v1_decoder.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/v1_decoder.cpp b/src/v1_decoder.cpp
index b002dc9d..2c8c97a7 100644
--- a/src/v1_decoder.cpp
+++ b/src/v1_decoder.cpp
@@ -114,11 +114,13 @@ int zmq::v1_decoder_t::eight_byte_size_ready ()
return -1;
}
+#ifndef __aarch64__
// Message size must fit within range of size_t data type.
if (payload_length - 1 > std::numeric_limits <size_t>::max ()) {
errno = EMSGSIZE;
return -1;
}
+#endif
const size_t msg_size = static_cast <size_t> (payload_length - 1);
--
2.20.1

View File

@ -24,6 +24,9 @@ SET(Readline_INCLUDE_DIR @prefix@/include)
SET(Readline_LIBRARY @prefix@/lib/libreadline.a)
SET(Terminfo_LIBRARY @prefix@/lib/libtinfo.a)
SET(UNBOUND_INCLUDE_DIR @prefix@/include)
SET(UNBOUND_LIBRARIES @prefix@/lib/libunbound.a)
SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
@ -66,22 +69,35 @@ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target
# specify the cross compiler to be used. Darwin uses clang provided by the SDK.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if(ARCHITECTURE STREQUAL "aarch64")
SET(CLANG_TARGET "arm64-apple-darwin11")
SET(CONF_TRIPLE "aarch64-apple-darwin11")
SET(BUILD_TAG "mac-armv8")
SET(CMAKE_OSX_ARCHITECTURES "arm64")
set(ARM ON)
set(ARM_ID "armv8-a")
else()
SET(CLANG_TARGET "x86_64-apple-darwin11")
SET(CONF_TRIPLE "x86_64-apple-darwin11")
SET(BUILD_TAG "mac-x64")
SET(CMAKE_OSX_ARCHITECTURES "x86_64")
endif()
SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-)
SET(CMAKE_C_COMPILER @prefix@/native/bin/clang)
SET(CMAKE_C_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_CXX_COMPILER @prefix@/native/bin/clang++ -stdlib=libc++)
SET(CMAKE_CXX_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_ASM_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_ASM-ATT_COMPILER_TARGET x86_64-apple-darwin11)
SET(_CMAKE_TOOLCHAIN_PREFIX x86_64-apple-darwin11-)
SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET})
SET(APPLE True)
SET(BUILD_TAG "mac-x64")
SET(BUILD_64 ON)
SET(BREW OFF)
SET(PORT OFF)
SET(CMAKE_OSX_SYSROOT "@sdk@/MacOSX10.11.sdk/")
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.08")
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_OSX_ARCHITECTURES "x86_64")
SET(CMAKE_CXX_STANDARD 14)
SET(LLVM_ENABLE_PIC OFF)
SET(LLVM_ENABLE_PIE OFF)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
@ -123,7 +139,7 @@ elseif(ARCHITECTURE STREQUAL "aarch64")
set(ARM_ID "armv8-a")
if(ANDROID)
set(BUILD_TAG "android-armv8")
else()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(BUILD_TAG "linux-armv8")
endif()
set(BUILD_64 ON)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#

View File

@ -1 +0,0 @@
/build/*

View File

@ -1,49 +0,0 @@
cmake_minimum_required(VERSION 3.5)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_DEBUG 1)
find_package(Boost COMPONENTS system filesystem thread date_time chrono regex )
include_directories( ${Boost_INCLUDE_DIRS} )
IF (MSVC)
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /nologo /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /bigobj" )
ELSE()
# set stuff for other systems
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-reorder -D_GNU_SOURCE")
ENDIF()
include_directories(.)
include_directories(../include)
include_directories(iface)
# Add folders to filters
file(GLOB_RECURSE LEVIN_GENERAL_SECTION RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.h
${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.inl
${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.cpp)
file(GLOB_RECURSE HTTP_GENERAL_SECTION RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.h
${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.inl
${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.cpp)
source_group(general FILES ${LEVIN_GENERAL_SECTION} FILES ${HTTP_GENERAL_SECTION})
#source_group(general FILES ${HTTP_GENERAL_SECTION})
add_executable(demo_http_server ${HTTP_GENERAL_SECTION} )
add_executable(demo_levin_server ${LEVIN_GENERAL_SECTION} )
target_link_libraries( demo_http_server ${Boost_LIBRARIES} )
target_link_libraries( demo_levin_server ${Boost_LIBRARIES} )
IF (NOT WIN32)
target_link_libraries (demo_http_server rt)
target_link_libraries (demo_levin_server rt)
ENDIF()

View File

@ -1,8 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// demo_http_server.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@ -1,40 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#define BOOST_FILESYSTEM_VERSION 3
#define ENABLE_RELEASE_LOGGING
#include "misc_log_ex.h"

View File

@ -1,13 +0,0 @@
#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif

View File

@ -1,30 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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 "stdafx.h"

View File

@ -1,41 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#define BOOST_FILESYSTEM_VERSION 3
#define ENABLE_RELEASE_LOGGING
#include "log_opt_defs.h"
#include "misc_log_ex.h"

View File

@ -1,13 +0,0 @@
#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif

View File

@ -1,4 +0,0 @@
mkdir build
cd build
cmake ..
#cmake -DBOOST_ROOT=/usr/local/proj/boost_1_49_0 -DBOOST_LIBRARYDIR=/usr/local/proj/boost_1_49_0/stage/lib ..

View File

@ -1,7 +0,0 @@
mkdir build
cd build
cmake "-DBoost_USE_STATIC_LIBS=TRUE" -G "Visual Studio 11 Win64" ..
cd ..
pause

View File

@ -1,225 +0,0 @@
#pragma once
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage_base.h"
namespace demo
{
struct some_test_subdata
{
std::string m_str;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_str)
END_KV_SERIALIZE_MAP()
};
struct some_test_data
{
std::string m_str;
uint64_t m_uint64;
uint32_t m_uint32;
uint16_t m_uint16;
uint8_t m_uint8;
int64_t m_int64;
int32_t m_int32;
int16_t m_int16;
int8_t m_int8;
double m_double;
bool m_bool;
std::list<std::string> m_list_of_str;
std::list<uint64_t> m_list_of_uint64_t;
std::list<uint32_t> m_list_of_uint32_t;
std::list<uint16_t> m_list_of_uint16_t;
std::list<uint8_t> m_list_of_uint8_t;
std::list<int64_t> m_list_of_int64_t;
std::list<int32_t> m_list_of_int32_t;
std::list<int16_t> m_list_of_int16_t;
std::list<int8_t> m_list_of_int8_t;
std::list<double> m_list_of_double;
std::list<bool> m_list_of_bool;
some_test_subdata m_subobj;
std::list<some_test_data> m_list_of_self;
epee::serialization::storage_entry m_storage_entry_int;
epee::serialization::storage_entry m_storage_entry_string;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_str)
KV_SERIALIZE(m_uint64)
KV_SERIALIZE(m_uint32)
KV_SERIALIZE(m_uint16)
KV_SERIALIZE(m_uint8)
KV_SERIALIZE(m_int64)
KV_SERIALIZE(m_int32)
KV_SERIALIZE(m_int16)
KV_SERIALIZE(m_int8)
KV_SERIALIZE(m_double)
KV_SERIALIZE(m_bool)
KV_SERIALIZE(m_subobj)
KV_SERIALIZE(m_list_of_str)
KV_SERIALIZE(m_list_of_uint64_t)
KV_SERIALIZE(m_list_of_uint32_t)
KV_SERIALIZE(m_list_of_uint16_t)
KV_SERIALIZE(m_list_of_uint8_t)
KV_SERIALIZE(m_list_of_int64_t)
KV_SERIALIZE(m_list_of_int32_t)
KV_SERIALIZE(m_list_of_int16_t)
KV_SERIALIZE(m_list_of_int8_t)
KV_SERIALIZE(m_list_of_double)
KV_SERIALIZE(m_list_of_bool)
KV_SERIALIZE(m_list_of_self)
KV_SERIALIZE(m_storage_entry_int)
KV_SERIALIZE(m_storage_entry_string)
END_KV_SERIALIZE_MAP()
};
/************************************************************************/
/* */
/************************************************************************/
struct COMMAND_EXAMPLE_1
{
const static int ID = 1000;
struct request_t
{
std::string example_string_data;
some_test_data sub;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(example_string_data)
KV_SERIALIZE(sub)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;
struct response_t
{
bool m_success;
std::list<some_test_data> subs;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_success)
KV_SERIALIZE(subs)
END_KV_SERIALIZE_MAP()
};
};
typedef epee::misc_utils::struct_init<response_t> response;
struct COMMAND_EXAMPLE_2
{
const static int ID = 1001;
struct request_t
{
std::string example_string_data2;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(example_string_data2)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;
struct response_t
{
bool m_success;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_success)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;
};
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
//in debug purpose
bool operator != (const some_test_subdata& a, const some_test_subdata& b)
{
return b.m_str != a.m_str;
}
bool operator == (const some_test_data& a, const some_test_data& b)
{
if( b.m_str != a.m_str
|| b.m_uint64 != a.m_uint64
|| b.m_uint32 != a.m_uint32
|| b.m_uint16 != a.m_uint16
|| b.m_uint8 != a.m_uint8
|| b.m_int64 != a.m_int64
|| b.m_int32 != a.m_int32
|| b.m_int16 != a.m_int16
|| b.m_int8 != a.m_int8
|| b.m_double != a.m_double
|| b.m_bool != a.m_bool
|| b.m_list_of_str != a.m_list_of_str
|| b.m_list_of_uint64_t != a.m_list_of_uint64_t
|| b.m_list_of_uint32_t != a.m_list_of_uint32_t
|| b.m_list_of_uint16_t != a.m_list_of_uint16_t
|| b.m_list_of_uint8_t != a.m_list_of_uint8_t
|| b.m_list_of_int64_t != a.m_list_of_int64_t
|| b.m_list_of_int32_t != a.m_list_of_int32_t
|| b.m_list_of_int16_t != a.m_list_of_int16_t
|| b.m_list_of_int8_t != a.m_list_of_int8_t
|| b.m_list_of_double != a.m_list_of_double
|| b.m_list_of_bool != a.m_list_of_bool
|| b.m_subobj != a.m_subobj
|| b.m_list_of_self != a.m_list_of_self
|| b.m_storage_entry_int.which() != a.m_storage_entry_int.which()
|| b.m_storage_entry_string.which() != a.m_storage_entry_string.which()
)
return false;
return true;
}
inline some_test_data get_test_data()
{
some_test_data s;
s.m_str = "zuzuzuzuzuz";
s.m_uint64 = 111111111111111;
s.m_uint32 = 2222222;
s.m_uint16 = 2222;
s.m_uint8 = 22;
s.m_int64 = -111111111111111;
s.m_int32 = -2222222;
s.m_int16 = -2222;
s.m_int8 = -24;
s.m_double = 0.11111;
s.m_bool = true;
s.m_list_of_str.push_back("1112121");
s.m_list_of_uint64_t.push_back(1111111111);
s.m_list_of_uint64_t.push_back(2222222222);
s.m_list_of_uint32_t.push_back(1111111);
s.m_list_of_uint32_t.push_back(2222222);
s.m_list_of_uint16_t.push_back(1111);
s.m_list_of_uint16_t.push_back(2222);
s.m_list_of_uint8_t.push_back(11);
s.m_list_of_uint8_t.push_back(22);
s.m_list_of_int64_t.push_back(-1111111111);
s.m_list_of_int64_t.push_back(-222222222);
s.m_list_of_int32_t.push_back(-1111111);
s.m_list_of_int32_t.push_back(-2222222);
s.m_list_of_int16_t.push_back(-1111);
s.m_list_of_int16_t.push_back(-2222);
s.m_list_of_int8_t.push_back(-11);
s.m_list_of_int8_t.push_back(-22);
s.m_list_of_double.push_back(0.11111);
s.m_list_of_double.push_back(0.22222);
s.m_list_of_bool.push_back(true);
s.m_list_of_bool.push_back(false);
s.m_subobj.m_str = "subszzzzzzzz";
s.m_list_of_self.push_back(s);
s.m_storage_entry_int = epee::serialization::storage_entry(uint64_t(22222));
s.m_storage_entry_string = epee::serialization::storage_entry(std::string("sdsvsdvs"));
return s;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, The Monero Project
// Copyright (c) 2019-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,4 +1,5 @@
// Copyright (c) 2020, The Monero Project
// Copyright (c) 2020-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -196,7 +196,7 @@ namespace epee
if (m_read_status == state_cancelled)
return false;
int retval = ::WaitForSingleObject(::GetStdHandle(STD_INPUT_HANDLE), 100);
DWORD retval = ::WaitForSingleObject(::GetStdHandle(STD_INPUT_HANDLE), 100);
switch (retval)
{
case WAIT_FAILED:

View File

@ -1,56 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma once
#include <atomic>
namespace epee
{
class copyable_atomic: public std::atomic<uint32_t>
{
public:
copyable_atomic()
{};
copyable_atomic(uint32_t value)
{ store(value); }
copyable_atomic(const copyable_atomic& a):std::atomic<uint32_t>(a.load())
{}
copyable_atomic& operator= (const copyable_atomic& a)
{
store(a.load());
return *this;
}
uint32_t operator++()
{
return std::atomic<uint32_t>::operator++();
}
uint32_t operator++(int fake)
{
return std::atomic<uint32_t>::operator++(fake);
}
};
}

View File

@ -36,10 +36,7 @@ namespace file_io_utils
{
bool is_file_exist(const std::string& path);
bool save_string_to_file(const std::string& path_to_file, const std::string& str);
bool get_file_time(const std::string& path_to_file, time_t& ft);
bool set_file_time(const std::string& path_to_file, const time_t& ft);
bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000);
bool append_string_to_file(const std::string& path_to_file, const std::string& str);
bool get_file_size(const std::string& path_to_file, uint64_t &size);
}
}

View File

@ -1,4 +1,5 @@
// Copyright (c) 2018, The Monero Project
// Copyright (c) 2018-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,35 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma once
std::stringstream& operator<<(std::stringstream& out, const std::wstring& ws)
{
std::string as = string_encoding::convert_to_ansii(ws);
out << as;
return out;
}

View File

@ -1,227 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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 _GZIP_ENCODING_H_
#define _GZIP_ENCODING_H_
#include "net/http_client_base.h"
#include "zlib/zlib.h"
//#include "http.h"
namespace epee
{
namespace net_utils
{
class content_encoding_gzip: public i_sub_handler
{
public:
/*! \brief
* Function content_encoding_gzip : Constructor
*
*/
inline
content_encoding_gzip(i_target_handler* powner_filter, bool is_deflate_mode = false):m_powner_filter(powner_filter),
m_is_stream_ended(false),
m_is_deflate_mode(is_deflate_mode),
m_is_first_update_in(true)
{
memset(&m_zstream_in, 0, sizeof(m_zstream_in));
memset(&m_zstream_out, 0, sizeof(m_zstream_out));
int ret = 0;
if(is_deflate_mode)
{
ret = inflateInit(&m_zstream_in);
ret = deflateInit(&m_zstream_out, Z_DEFAULT_COMPRESSION);
}else
{
ret = inflateInit2(&m_zstream_in, 0x1F);
ret = deflateInit2(&m_zstream_out, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 0x1F, 8, Z_DEFAULT_STRATEGY);
}
}
/*! \brief
* Function content_encoding_gzip : Destructor
*
*/
inline
~content_encoding_gzip()
{
inflateEnd(& m_zstream_in );
deflateEnd(& m_zstream_out );
}
/*! \brief
* Function update_in : Entry point for income data
*
*/
inline
virtual bool update_in( std::string& piece_of_transfer)
{
bool is_first_time_here = m_is_first_update_in;
m_is_first_update_in = false;
if(m_pre_decode.size())
m_pre_decode += piece_of_transfer;
else
m_pre_decode.swap(piece_of_transfer);
piece_of_transfer.clear();
std::string decode_summary_buff;
size_t ungzip_size = m_pre_decode.size() * 0x30;
std::string current_decode_buff(ungzip_size, 'X');
//Here the cycle is introduced where we unpack the buffer, the cycle is required
//because of the case where if after unpacking the data will exceed the awaited size, we will not halt with error
bool continue_unpacking = true;
bool first_step = true;
while(m_pre_decode.size() && continue_unpacking)
{
//fill buffers
m_zstream_in.next_in = (Bytef*)m_pre_decode.data();
m_zstream_in.avail_in = (uInt)m_pre_decode.size();
m_zstream_in.next_out = (Bytef*)current_decode_buff.data();
m_zstream_in.avail_out = (uInt)ungzip_size;
int flag = Z_SYNC_FLUSH;
int ret = inflate(&m_zstream_in, flag);
CHECK_AND_ASSERT_MES(ret>=0 || m_zstream_in.avail_out ||m_is_deflate_mode, false, "content_encoding_gzip::update_in() Failed to inflate. err = " << ret);
if(Z_STREAM_END == ret)
m_is_stream_ended = true;
else if(Z_DATA_ERROR == ret && is_first_time_here && m_is_deflate_mode&& first_step)
{
// some servers (notably Apache with mod_deflate) don't generate zlib headers
// insert a dummy header and try again
static char dummy_head[2] =
{
0x8 + 0x7 * 0x10,
(((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF,
};
inflateReset(&m_zstream_in);
m_zstream_in.next_in = (Bytef*) dummy_head;
m_zstream_in.avail_in = sizeof(dummy_head);
ret = inflate(&m_zstream_in, Z_NO_FLUSH);
if (ret != Z_OK)
{
LOCAL_ASSERT(0);
m_pre_decode.swap(piece_of_transfer);
return false;
}
m_zstream_in.next_in = (Bytef*)m_pre_decode.data();
m_zstream_in.avail_in = (uInt)m_pre_decode.size();
ret = inflate(&m_zstream_in, Z_NO_FLUSH);
if (ret != Z_OK)
{
LOCAL_ASSERT(0);
m_pre_decode.swap(piece_of_transfer);
return false;
}
}
//leave only unpacked part in the output buffer to start with it the next time
m_pre_decode.erase(0, m_pre_decode.size()-m_zstream_in.avail_in);
//if decoder gave nothing to return, then everything is ahead, now simply break
if(ungzip_size == m_zstream_in.avail_out)
break;
//decode_buff currently stores data parts that were unpacked, fix this size
current_decode_buff.resize(ungzip_size - m_zstream_in.avail_out);
if(decode_summary_buff.size())
decode_summary_buff += current_decode_buff;
else
current_decode_buff.swap(decode_summary_buff);
current_decode_buff.resize(ungzip_size);
first_step = false;
}
//Process these data if required
bool res = true;
res = m_powner_filter->handle_target_data(decode_summary_buff);
return true;
}
/*! \brief
* Function stop : Entry point for stop signal and flushing cached data buffer.
*
*/
inline
virtual void stop(std::string& OUT collect_remains)
{
}
protected:
private:
/*! \brief
* Pointer to parent HTTP-parser
*/
i_target_handler* m_powner_filter;
/*! \brief
* ZLIB object for income stream
*/
z_stream m_zstream_in;
/*! \brief
* ZLIB object for outcome stream
*/
z_stream m_zstream_out;
/*! \brief
* Data that could not be unpacked immediately, left to wait for the next packet of data
*/
std::string m_pre_decode;
/*! \brief
* The data are accumulated for a package in the buffer to send the web client
*/
std::string m_pre_encode;
/*! \brief
* Signals that stream looks like ended
*/
bool m_is_stream_ended;
/*! \brief
* If this flag is set, income data is in HTTP-deflate mode
*/
bool m_is_deflate_mode;
/*! \brief
* Marks that it is a first data packet
*/
bool m_is_first_update_in;
};
}
}
#endif //_GZIP_ENCODING_H_

View File

@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, The Monero Project
// Copyright (c) 2017-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,93 +0,0 @@
/*
* libEtPan! -- a mail stuff library
*
* Copyright (C) 2001, 2005 - DINH Viet Hoa
* 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 libEtPan! project 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 AUTHORS 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 AUTHORS 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.
*/
/* hmac-md5.h -- HMAC_MD5 functions
*/
/*
* $Id: hmac-md5.h,v 1.1.1.1 2005/03/18 20:17:28 zautrix Exp $
*/
#ifndef HMAC_MD5_H
#define HMAC_MD5_H 1
namespace md5
{
#define HMAC_MD5_SIZE 16
/* intermediate MD5 context */
typedef struct HMAC_MD5_CTX_s {
MD5_CTX ictx, octx;
} HMAC_MD5_CTX;
/* intermediate HMAC state
* values stored in network byte order (Big Endian)
*/
typedef struct HMAC_MD5_STATE_s {
UINT4 istate[4];
UINT4 ostate[4];
} HMAC_MD5_STATE;
/* One step hmac computation
*
* digest may be same as text or key
*/
void hmac_md5(const unsigned char *text, int text_len,
const unsigned char *key, int key_len,
unsigned char digest[HMAC_MD5_SIZE]);
/* create context from key
*/
void hmac_md5_init(HMAC_MD5_CTX *hmac,
const unsigned char *key, int key_len);
/* precalculate intermediate state from key
*/
void hmac_md5_precalc(HMAC_MD5_STATE *hmac,
const unsigned char *key, int key_len);
/* initialize context from intermediate state
*/
void hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
#define hmac_md5_update(hmac, text, text_len) MD5Update(&(hmac)->ictx, (text), (text_len))
/* finish hmac from intermediate result. Intermediate result is zeroed.
*/
void hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
HMAC_MD5_CTX *hmac);
}
#endif /* HMAC_MD5_H */

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -37,8 +37,8 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/random_generator.hpp>
#include "misc_os_dependent.h"
#include "syncobj.h"
#include "time_helper.h"
namespace epee
{

View File

@ -74,7 +74,6 @@ namespace md5
static void MD5Init(MD5_CTX * context);
static void MD5Update( MD5_CTX *context, const unsigned char *input, unsigned int inputLen );
static void MD5Final ( unsigned char digest[16], MD5_CTX *context );
static inline void hmac_md5(const unsigned char* text, int text_len, const unsigned char* key, int key_len, unsigned char *digest);
inline bool md5( unsigned char *input, int ilen, unsigned char output[16] )

View File

@ -65,7 +65,6 @@ documentation and/or software.
#endif
#include "md5global.h"
#include "md5_l.h"
#include "hmac-md5.h"
namespace md5
{
@ -89,16 +88,6 @@ namespace md5
#define S43 15
#define S44 21
/*
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
*/
static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
{
unsigned int i;
@ -107,17 +96,6 @@ namespace md5
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD5_memset (POINTER output, int value, unsigned int len)
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
}
static void MD5Transform (UINT4 state[4], unsigned char block[64]);
static unsigned char* PADDING()
@ -371,190 +349,4 @@ namespace md5
*/
memwipe ((POINTER)x, sizeof (x));
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
inline
void hmac_md5_init(HMAC_MD5_CTX *hmac,
const unsigned char *key,
int key_len)
{
unsigned char k_ipad[65]; /* inner padding -
* key XORd with ipad
*/
unsigned char k_opad[65]; /* outer padding -
* key XORd with opad
*/
unsigned char tk[16];
int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
MD5_CTX tctx;
MD5Init(&tctx);
MD5Update(&tctx, key, key_len);
MD5Final(tk, &tctx);
key = tk;
key_len = 16;
}
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in pads */
MD5_memset(k_ipad, '\0', sizeof k_ipad);
MD5_memset(k_opad, '\0', sizeof k_opad);
MD5_memcpy( k_ipad, (POINTER)key, key_len);
MD5_memcpy( k_opad, (POINTER)key, key_len);
/* XOR key with ipad and opad values */
for (i=0; i<64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
MD5Init(&hmac->ictx); /* init inner context */
MD5Update(&hmac->ictx, k_ipad, 64); /* apply inner pad */
MD5Init(&hmac->octx); /* init outer context */
MD5Update(&hmac->octx, k_opad, 64); /* apply outer pad */
/* scrub the pads and key context (if used) */
memwipe( (POINTER)&k_ipad, sizeof(k_ipad));
memwipe( (POINTER)&k_opad, sizeof(k_opad));
memwipe( (POINTER)&tk, sizeof(tk));
/* and we're done. */
}
/* The precalc and import routines here rely on the fact that we pad
* the key out to 64 bytes and use that to initialize the md5
* contexts, and that updating an md5 context with 64 bytes of data
* leaves nothing left over; all of the interesting state is contained
* in the state field, and none of it is left over in the count and
* buffer fields. So all we have to do is save the state field; we
* can zero the others when we reload it. Which is why the decision
* was made to pad the key out to 64 bytes in the first place. */
inline
void hmac_md5_precalc(HMAC_MD5_STATE *state,
const unsigned char *key,
int key_len)
{
HMAC_MD5_CTX hmac;
unsigned lupe;
hmac_md5_init(&hmac, key, key_len);
for (lupe = 0; lupe < 4; lupe++) {
state->istate[lupe] = htonl(hmac.ictx.state[lupe]);
state->ostate[lupe] = htonl(hmac.octx.state[lupe]);
}
memwipe( (POINTER)&hmac, sizeof(hmac));
}
inline
void hmac_md5_import(HMAC_MD5_CTX *hmac,
HMAC_MD5_STATE *state)
{
unsigned lupe;
MD5_memset( (POINTER)hmac, 0, sizeof(HMAC_MD5_CTX));
for (lupe = 0; lupe < 4; lupe++) {
hmac->ictx.state[lupe] = ntohl(state->istate[lupe]);
hmac->octx.state[lupe] = ntohl(state->ostate[lupe]);
}
/* Init the counts to account for our having applied
* 64 bytes of key; this works out to 0x200 (64 << 3; see
* MD5Update above...) */
hmac->ictx.count[0] = hmac->octx.count[0] = 0x200;
}
inline
void hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
HMAC_MD5_CTX *hmac)
{
MD5Final(digest, &hmac->ictx); /* Finalize inner md5 */
MD5Update(&hmac->octx, digest, 16); /* Update outer ctx */
MD5Final(digest, &hmac->octx); /* Finalize outer md5 */
}
void hmac_md5(const unsigned char* text, int text_len, const unsigned char* key, int key_len, unsigned char *digest)
{
MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding -
* key XORd with ipad
*/
unsigned char k_opad[65]; /* outer padding -
* key XORd with opad
*/
unsigned char tk[16];
int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
MD5_CTX tctx;
MD5Init(&tctx);
MD5Update(&tctx, key, key_len);
MD5Final(tk, &tctx);
key = tk;
key_len = 16;
}
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in pads */
MD5_memset(k_ipad, '\0', sizeof k_ipad);
MD5_memset(k_opad, '\0', sizeof k_opad);
MD5_memcpy( k_ipad, (POINTER)key, key_len);
MD5_memcpy( k_opad, (POINTER)key, key_len);
/* XOR key with ipad and opad values */
for (i=0; i<64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
/*
* perform inner MD5
*/
MD5Init(&context); /* init context for 1st
* pass */
MD5Update(&context, k_ipad, 64); /* start with inner pad */
MD5Update(&context, text, text_len); /* then text of datagram */
MD5Final(digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
MD5Init(&context); /* init context for 2nd
* pass */
MD5Update(&context, k_opad, 64); /* start with outer pad */
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
MD5Final(digest, &context); /* finish up 2nd pass */
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, The Monero Project
// Copyright (c) 2017-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -30,74 +30,14 @@
#include <boost/utility/value_init.hpp>
#include <boost/shared_ptr.hpp>
#include <limits>
#include <functional>
#include <vector>
namespace epee
{
#define STD_TRY_BEGIN() try {
#define STD_TRY_CATCH(where_, ret_val) \
} \
catch (const std::exception &e) \
{ \
LOG_ERROR("EXCEPTION: " << where_ << ", mes: "<< e.what()); \
return ret_val; \
} \
catch (...) \
{ \
LOG_ERROR("EXCEPTION: " << where_ ); \
return ret_val; \
}
#define AUTO_VAL_INIT(v) boost::value_initialized<decltype(v)>()
namespace misc_utils
{
template<typename t_type>
t_type get_max_t_val(t_type t)
{
return (std::numeric_limits<t_type>::max)();
}
template<typename t_iterator>
t_iterator move_it_forward(t_iterator it, size_t count)
{
while(count--)
it++;
return it;
}
template<typename t_iterator>
t_iterator move_it_backward(t_iterator it, size_t count)
{
while(count--)
it--;
return it;
}
// TEMPLATE STRUCT less
template<class _Ty>
struct less_as_pod
: public std::binary_function<_Ty, _Ty, bool>
{ // functor for operator<
bool operator()(const _Ty& _Left, const _Ty& _Right) const
{ // apply operator< to operands
return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
}
};
template<class _Ty>
bool is_less_as_pod(const _Ty& _Left, const _Ty& _Right)
{ // apply operator< to operands
return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
}
bool sleep_no_w(long ms );
bool sleep_no_w(long ms);
template <typename T>
T get_mid(const T &a, const T &b)

View File

@ -1,129 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#ifdef _WIN32
#include <winsock2.h>
#endif
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
//#ifdef _WIN32_WINNT
// #undef _WIN32_WINNT
// #define _WIN32_WINNT 0x0600
//#endif
#include <windows.h>
#endif
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif
#include <iostream>
#include <ctime>
#pragma once
namespace epee
{
namespace misc_utils
{
inline uint64_t get_ns_count()
{
#if defined(_MSC_VER)
return ::GetTickCount64() * 1000000;
#elif defined(WIN32)
static LARGE_INTEGER pcfreq = {0};
LARGE_INTEGER ticks;
if (!pcfreq.QuadPart)
QueryPerformanceFrequency(&pcfreq);
QueryPerformanceCounter(&ticks);
ticks.QuadPart *= 1000000000; /* we want nsec */
return ticks.QuadPart / pcfreq.QuadPart;
#elif defined(__MACH__)
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
return ((uint64_t)mts.tv_sec * 1000000000) + (mts.tv_nsec);
#else
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
return 0;
}
return ((uint64_t)ts.tv_sec * 1000000000) + (ts.tv_nsec);
#endif
}
inline uint64_t get_tick_count()
{
return get_ns_count() / 1000000;
}
inline int call_sys_cmd(const std::string& cmd)
{
std::cout << "# " << cmd << std::endl;
FILE * fp ;
//char tstCommand[] ="ls *";
char path[1000] = {0};
#if !defined(__GNUC__)
fp = _popen(cmd.c_str(), "r");
#else
fp = popen(cmd.c_str(), "r");
#endif
while ( fgets( path, 1000, fp ) != NULL )
std::cout << path;
#if !defined(__GNUC__)
_pclose(fp);
#else
pclose(fp);
#endif
return 0;
}
std::string get_thread_string_id();
inline bool get_gmt_time(time_t t, struct tm &tm)
{
#ifdef _WIN32
return gmtime_s(&tm, &t);
#else
return gmtime_r(&t, &tm);
#endif
}
}
}

View File

@ -1,4 +1,5 @@
// Copyright (c) 2018, The Monero Project
// Copyright (c) 2018-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -1,318 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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 _ABSTRACT_TCP_SERVER_H_
#define _ABSTRACT_TCP_SERVER_H_
#include <process.h>
#include <list>
#include <winsock2.h>
#include "winobj.h"
//#include "threads_helper.h"
#include "net_utils_base.h"
#pragma comment(lib, "Ws2_32.lib")
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
namespace epee
{
namespace net_utils
{
/************************************************************************/
/* */
/************************************************************************/
class soket_sender: public i_service_endpoint
{
public:
soket_sender(SOCKET sock):m_sock(sock){}
private:
virtual bool handle_send(const void* ptr, size_t cb)
{
if(cb != send(m_sock, (char*)ptr, (int)cb, 0))
{
int sock_err = WSAGetLastError();
LOG_ERROR("soket_sender: Failed to send " << cb << " bytes, Error=" << sock_err);
return false;
}
return true;
}
SOCKET m_sock;
};
/************************************************************************/
/* */
/************************************************************************/
template<class THandler>
class abstract_tcp_server
{
public:
abstract_tcp_server();
bool init_server(int port_no);
bool deinit_server();
bool run_server();
bool send_stop_signal();
typename THandler::config_type& get_config_object(){return m_config;}
private:
bool invoke_connection(SOCKET hnew_sock, long ip_from, int post_from);
static unsigned __stdcall ConnectionHandlerProc(void* lpParameter);
class thread_context;
typedef std::list<thread_context> connections_container;
typedef typename connections_container::iterator connections_iterator;
struct thread_context
{
HANDLE m_htread;
SOCKET m_socket;
abstract_tcp_server* powner;
connection_context m_context;
typename connections_iterator m_self_it;
};
SOCKET m_listen_socket;
int m_port;
bool m_initialized;
volatile LONG m_stop_server;
volatile LONG m_threads_count;
typename THandler::config_type m_config;
connections_container m_connections;
critical_section m_connections_lock;
};
template<class THandler>
unsigned __stdcall abstract_tcp_server<THandler>::ConnectionHandlerProc(void* lpParameter)
{
thread_context* pthread_context = (thread_context*)lpParameter;
if(!pthread_context)
return 0;
abstract_tcp_server<THandler>* pthis = pthread_context->powner;
::InterlockedIncrement(&pthis->m_threads_count);
::CoInitialize(NULL);
LOG_PRINT("Handler thread STARTED with socket=" << pthread_context->m_socket, LOG_LEVEL_2);
int res = 0;
soket_sender sndr(pthread_context->m_socket);
THandler srv(&sndr, pthread_context->powner->m_config, pthread_context->m_context);
srv.after_init_connection();
char buff[1000] = {0};
std::string ansver;
while ( (res = recv(pthread_context->m_socket, (char*)buff, 1000, 0)) > 0)
{
LOG_PRINT("Data in, " << res << " bytes", LOG_LEVEL_3);
if(!srv.handle_recv(buff, res))
break;
}
shutdown(pthread_context->m_socket, SD_BOTH);
closesocket(pthread_context->m_socket);
abstract_tcp_server* powner = pthread_context->powner;
LOG_PRINT("Handler thread with socket=" << pthread_context->m_socket << " STOPPED", LOG_LEVEL_2);
powner->m_connections_lock.lock();
::CloseHandle(pthread_context->m_htread);
pthread_context->powner->m_connections.erase(pthread_context->m_self_it);
powner->m_connections_lock.unlock();
CoUninitialize();
::InterlockedDecrement(&pthis->m_threads_count);
return 1;
}
//----------------------------------------------------------------------------------------
template<class THandler>
abstract_tcp_server<THandler>::abstract_tcp_server():m_listen_socket(INVALID_SOCKET),
m_initialized(false),
m_stop_server(0), m_port(0), m_threads_count(0)
{
}
//----------------------------------------------------------------------------------------
template<class THandler>
bool abstract_tcp_server<THandler>::init_server(int port_no)
{
m_port = port_no;
WSADATA wsad = {0};
int err = ::WSAStartup(MAKEWORD(2,2), &wsad);
if ( err != 0 || LOBYTE( wsad.wVersion ) != 2 || HIBYTE( wsad.wVersion ) != 2 )
{
LOG_ERROR("Could not find a usable WinSock DLL, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
m_initialized = true;
m_listen_socket = ::WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);
if(INVALID_SOCKET == m_listen_socket)
{
err = ::WSAGetLastError();
LOG_ERROR("Failed to create socket, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
int opt = 1;
setsockopt (m_listen_socket, SOL_SOCKET,SO_REUSEADDR, reinterpret_cast<char*>(&opt), sizeof(int));
sockaddr_in adr = {0};
adr.sin_family = AF_INET;
adr.sin_addr.s_addr = htonl(INADDR_ANY);
adr.sin_port = (u_short)htons(port_no);
err = bind(m_listen_socket, (const sockaddr*)&adr, sizeof(adr ));
if(SOCKET_ERROR == err )
{
err = ::WSAGetLastError();
LOG_PRINT("Failed to Bind, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_2);
deinit_server();
return false;
}
::InterlockedExchange(&m_stop_server, 0);
return true;
}
//----------------------------------------------------------------------------------------
template<class THandler>
bool abstract_tcp_server<THandler>::deinit_server()
{
if(!m_initialized)
return true;
if(INVALID_SOCKET != m_listen_socket)
{
shutdown(m_listen_socket, SD_BOTH);
int res = closesocket(m_listen_socket);
if(SOCKET_ERROR == res)
{
int err = ::WSAGetLastError();
LOG_ERROR("Failed to closesocket(), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
}
m_listen_socket = INVALID_SOCKET;
}
int res = ::WSACleanup();
if(SOCKET_ERROR == res)
{
int err = ::WSAGetLastError();
LOG_ERROR("Failed to WSACleanup(), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
}
m_initialized = false;
return true;
}
//----------------------------------------------------------------------------------------
template<class THandler>
bool abstract_tcp_server<THandler>::send_stop_signal()
{
InterlockedExchange(&m_stop_server, 1);
return true;
}
//----------------------------------------------------------------------------------------
template<class THandler>
bool abstract_tcp_server<THandler>::run_server()
{
int err = listen(m_listen_socket, 10000);
if(SOCKET_ERROR == err )
{
err = ::WSAGetLastError();
LOG_ERROR("Failed to listen, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
LOG_PRINT("Listening port "<< m_port << "...." , LOG_LEVEL_2);
while(!m_stop_server)
{
sockaddr_in adr_from = {0};
int adr_len = sizeof(adr_from);
fd_set read_fs = {0};
read_fs.fd_count = 1;
read_fs.fd_array[0] = m_listen_socket;
TIMEVAL tv = {0};
tv.tv_usec = 100;
int select_res = select(0, &read_fs, NULL, NULL, &tv);
if(!select_res)
continue;
SOCKET new_sock = WSAAccept(m_listen_socket, (sockaddr *)&adr_from, &adr_len, NULL, NULL);
LOG_PRINT("Accepted connection on socket=" << new_sock, LOG_LEVEL_2);
invoke_connection(new_sock, adr_from.sin_addr.s_addr, adr_from.sin_port);
}
deinit_server();
#define ABSTR_TCP_SRV_WAIT_COUNT_MAX 5000
#define ABSTR_TCP_SRV_WAIT_COUNT_INTERVAL 1000
int wait_count = 0;
while(m_threads_count && wait_count*1000 < ABSTR_TCP_SRV_WAIT_COUNT_MAX)
{
::Sleep(ABSTR_TCP_SRV_WAIT_COUNT_INTERVAL);
wait_count++;
}
LOG_PRINT("abstract_tcp_server exit with wait count=" << wait_count*ABSTR_TCP_SRV_WAIT_COUNT_INTERVAL << "(max=" << ABSTR_TCP_SRV_WAIT_COUNT_MAX <<")", LOG_LEVEL_0);
return true;
}
//----------------------------------------------------------------------------------------
template<class THandler>
bool abstract_tcp_server<THandler>::invoke_connection(SOCKET hnew_sock, const network_address &remote_address)
{
m_connections_lock.lock();
m_connections.push_back(thread_context());
m_connections_lock.unlock();
m_connections.back().m_socket = hnew_sock;
m_connections.back().powner = this;
m_connections.back().m_self_it = --m_connections.end();
m_connections.back().m_context.m_remote_address = remote_address;
m_connections.back().m_htread = threads_helper::create_thread(ConnectionHandlerProc, &m_connections.back()); // ugh, seems very risky
return true;
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
}
}
#endif //_ABSTRACT_TCP_SERVER_H_

View File

@ -44,13 +44,16 @@
#include <cassert>
#include <map>
#include <memory>
#include <condition_variable>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/array.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/thread/thread.hpp>
#include <boost/optional.hpp>
#include "byte_slice.h"
#include "net_utils_base.h"
#include "syncobj.h"
@ -88,7 +91,172 @@ namespace net_utils
{
public:
typedef typename t_protocol_handler::connection_context t_connection_context;
private:
using connection_t = connection<t_protocol_handler>;
using connection_ptr = boost::shared_ptr<connection_t>;
using ssl_support_t = epee::net_utils::ssl_support_t;
using timer_t = boost::asio::steady_timer;
using duration_t = timer_t::duration;
using ec_t = boost::system::error_code;
using handshake_t = boost::asio::ssl::stream_base::handshake_type;
using io_context_t = boost::asio::io_service;
using strand_t = boost::asio::io_service::strand;
using socket_t = boost::asio::ip::tcp::socket;
using network_throttle_t = epee::net_utils::network_throttle;
using network_throttle_manager_t = epee::net_utils::network_throttle_manager;
unsigned int host_count(int delta = 0);
duration_t get_default_timeout();
duration_t get_timeout_from_bytes_read(size_t bytes) const;
void state_status_check();
void start_timer(duration_t duration, bool add = {});
void async_wait_timer();
void cancel_timer();
void start_handshake();
void start_read();
void start_write();
void start_shutdown();
void cancel_socket();
void cancel_handler();
void interrupt();
void on_interrupted();
void terminate();
void on_terminating();
bool send(epee::byte_slice message);
bool start_internal(
bool is_income,
bool is_multithreaded,
boost::optional<network_address> real_remote
);
enum status_t {
TERMINATED,
RUNNING,
INTERRUPTED,
TERMINATING,
WASTED,
};
struct state_t {
struct stat_t {
struct {
network_throttle_t throttle{"speed_in", "throttle_speed_in"};
} in;
struct {
network_throttle_t throttle{"speed_out", "throttle_speed_out"};
} out;
};
struct data_t {
struct {
std::array<uint8_t, 0x2000> buffer;
} read;
struct {
std::deque<epee::byte_slice> queue;
bool wait_consume;
} write;
};
struct ssl_t {
bool enabled;
bool forced;
bool detected;
bool handshaked;
};
struct socket_status_t {
bool connected;
bool wait_handshake;
bool cancel_handshake;
bool wait_read;
bool handle_read;
bool cancel_read;
bool wait_write;
bool handle_write;
bool cancel_write;
bool wait_shutdown;
bool cancel_shutdown;
};
struct timer_status_t {
bool wait_expire;
bool cancel_expire;
bool reset_expire;
};
struct timers_status_t {
struct throttle_t {
timer_status_t in;
timer_status_t out;
};
timer_status_t general;
throttle_t throttle;
};
struct protocol_t {
size_t reference_counter;
bool released;
bool initialized;
bool wait_release;
bool wait_init;
size_t wait_callback;
};
std::mutex lock;
std::condition_variable_any condition;
status_t status;
socket_status_t socket;
ssl_t ssl;
timers_status_t timers;
protocol_t protocol;
stat_t stat;
data_t data;
};
struct timers_t {
timers_t(io_context_t &io_context):
general(io_context),
throttle(io_context)
{}
struct throttle_t {
throttle_t(io_context_t &io_context):
in(io_context),
out(io_context)
{}
timer_t in;
timer_t out;
};
timer_t general;
throttle_t throttle;
};
io_context_t &m_io_context;
t_connection_type m_connection_type;
t_connection_context m_conn_context{};
strand_t m_strand;
timers_t m_timers;
connection_ptr self{};
bool m_local{};
std::string m_host{};
state_t m_state{};
t_protocol_handler m_handler;
public:
struct shared_state : connection_basic_shared_state, t_protocol_handler::config_type
{
shared_state()
@ -120,7 +288,7 @@ namespace net_utils
// `real_remote` is the actual endpoint (if connection is to proxy, etc.)
bool start(bool is_income, bool is_multithreaded, network_address real_remote);
void get_context(t_connection_context& context_){context_ = context;}
void get_context(t_connection_context& context_){context_ = m_conn_context;}
void call_back_starter();
@ -142,58 +310,6 @@ namespace net_utils
virtual bool add_ref();
virtual bool release();
//------------------------------------------------------
bool do_send_chunk(byte_slice chunk); ///< will send (or queue) a part of data. internal use only
boost::shared_ptr<connection<t_protocol_handler> > safe_shared_from_this();
bool shutdown();
/// Handle completion of a receive operation.
void handle_receive(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a read operation.
void handle_read(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a write operation.
void handle_write(const boost::system::error_code& e, size_t cb);
/// reset connection timeout timer and callback
void reset_timer(boost::posix_time::milliseconds ms, bool add);
boost::posix_time::milliseconds get_default_timeout();
boost::posix_time::milliseconds get_timeout_from_bytes_read(size_t bytes);
/// host connection count tracking
unsigned int host_count(const std::string &host, int delta = 0);
/// Buffer for incoming data.
boost::array<char, 8192> buffer_;
size_t buffer_ssl_init_fill;
t_connection_context context;
// TODO what do they mean about wait on destructor?? --rfree :
//this should be the last one, because it could be wait on destructor, while other activities possible on other threads
t_protocol_handler m_protocol_handler;
//typename t_protocol_handler::config_type m_dummy_config;
size_t m_reference_count = 0; // reference count managed through add_ref/release support
boost::shared_ptr<connection<t_protocol_handler> > m_self_ref; // the reference to hold
critical_section m_self_refs_lock;
critical_section m_chunking_lock; // held while we add small chunks of the big do_send() to small do_send_chunk()
critical_section m_shutdown_lock; // held while shutting down
t_connection_type m_connection_type;
// for calculate speed (last 60 sec)
network_throttle m_throttle_speed_in;
network_throttle m_throttle_speed_out;
boost::mutex m_throttle_speed_in_mutex;
boost::mutex m_throttle_speed_out_mutex;
boost::asio::deadline_timer m_timer;
bool m_local;
bool m_ready_to_close;
std::string m_host;
public:
void setRpcStation();
};
@ -393,7 +509,7 @@ namespace net_utils
std::vector<boost::shared_ptr<boost::thread> > m_threads;
boost::thread::id m_main_thread_id;
critical_section m_threads_lock;
volatile uint32_t m_thread_index; // TODO change to std::atomic
std::atomic<uint32_t> m_thread_index;
t_connection_type m_connection_type;

File diff suppressed because it is too large Load Diff

View File

@ -1,236 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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 _LEVIN_CP_SERVER_H_
#define _LEVIN_CP_SERVER_H_
#include <winsock2.h>
#include <rpc.h>
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include "misc_log_ex.h"
//#include "threads_helper.h"
#include "syncobj.h"
#define ENABLE_PROFILING
#include "profile_tools.h"
#include "net_utils_base.h"
#include "pragma_comp_defs.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
#define LEVIN_DEFAULT_DATA_BUFF_SIZE 2000
namespace epee
{
namespace net_utils
{
template<class TProtocol>
class cp_server_impl//: public abstract_handler
{
public:
cp_server_impl(/*abstract_handler* phandler = NULL*/);
virtual ~cp_server_impl();
bool init_server(int port_no);
bool deinit_server();
bool run_server(int threads_count = 0);
bool send_stop_signal();
bool is_stop_signal();
virtual bool on_net_idle(){return true;}
size_t get_active_connections_num();
typename TProtocol::config_type& get_config_object(){return m_config;}
private:
enum overlapped_operation_type
{
op_type_recv,
op_type_send,
op_type_stop
};
struct io_data_base
{
OVERLAPPED m_overlapped;
WSABUF DataBuf;
overlapped_operation_type m_op_type;
DWORD TotalBuffBytes;
volatile LONG m_is_in_use;
char Buffer[1];
};
PRAGMA_WARNING_PUSH
PRAGMA_WARNING_DISABLE_VS(4355)
template<class TProtocol>
struct connection: public net_utils::i_service_endpoint
{
connection(typename TProtocol::config_type& ref_config):m_sock(INVALID_SOCKET), m_tprotocol_handler(this, ref_config, context), m_psend_data(NULL), m_precv_data(NULL), m_asked_to_shutdown(0), m_connection_shutwoned(0)
{
}
//connection():m_sock(INVALID_SOCKET), m_tprotocol_handler(this, m_dummy_config, context), m_psend_data(NULL), m_precv_data(NULL), m_asked_to_shutdown(0), m_connection_shutwoned(0)
//{
//}
connection<TProtocol>& operator=(const connection<TProtocol>& obj)
{
return *this;
}
bool init_buffers()
{
m_psend_data = (io_data_base*)new char[sizeof(io_data_base) + LEVIN_DEFAULT_DATA_BUFF_SIZE-1];
m_psend_data->TotalBuffBytes = LEVIN_DEFAULT_DATA_BUFF_SIZE;
m_precv_data = (io_data_base*)new char[sizeof(io_data_base) + LEVIN_DEFAULT_DATA_BUFF_SIZE-1];
m_precv_data->TotalBuffBytes = LEVIN_DEFAULT_DATA_BUFF_SIZE;
return true;
}
bool query_shutdown()
{
if(!::InterlockedCompareExchange(&m_asked_to_shutdown, 1, 0))
{
m_psend_data->m_op_type = op_type_stop;
::PostQueuedCompletionStatus(m_completion_port, 0, (ULONG_PTR)this, &m_psend_data->m_overlapped);
}
return true;
}
//bool set_config(typename TProtocol::config_type& config)
//{
// this->~connection();
// new(this) connection<TProtocol>(config);
// return true;
//}
~connection()
{
if(m_psend_data)
delete m_psend_data;
if(m_precv_data)
delete m_precv_data;
}
virtual bool handle_send(const void* ptr, size_t cb)
{
PROFILE_FUNC("[handle_send]");
if(m_psend_data->TotalBuffBytes < cb)
resize_send_buff((DWORD)cb);
ZeroMemory(&m_psend_data->m_overlapped, sizeof(OVERLAPPED));
m_psend_data->DataBuf.len = (u_long)cb;//m_psend_data->TotalBuffBytes;
m_psend_data->DataBuf.buf = m_psend_data->Buffer;
memcpy(m_psend_data->DataBuf.buf, ptr, cb);
m_psend_data->m_op_type = op_type_send;
InterlockedExchange(&m_psend_data->m_is_in_use, 1);
DWORD bytes_sent = 0;
DWORD flags = 0;
int res = 0;
{
PROFILE_FUNC("[handle_send] ::WSASend");
res = ::WSASend(m_sock, &(m_psend_data->DataBuf), 1, &bytes_sent, flags, &(m_psend_data->m_overlapped), NULL);
}
if(res == SOCKET_ERROR )
{
int err = ::WSAGetLastError();
if(WSA_IO_PENDING == err )
return true;
}
LOG_ERROR("BIG FAIL: WSASend error code not correct, res=" << res << " last_err=" << err);
::InterlockedExchange(&m_psend_data->m_is_in_use, 0);
query_shutdown();
//closesocket(m_psend_data);
return false;
}else if(0 == res)
{
::InterlockedExchange(&m_psend_data->m_is_in_use, 0);
if(!bytes_sent || bytes_sent != cb)
{
int err = ::WSAGetLastError();
LOG_ERROR("BIG FAIL: WSASend immediatly complete? but bad results, res=" << res << " last_err=" << err);
query_shutdown();
return false;
}else
{
return true;
}
}
return true;
}
bool resize_send_buff(DWORD new_size)
{
if(m_psend_data->TotalBuffBytes >= new_size)
return true;
delete m_psend_data;
m_psend_data = (io_data_base*)new char[sizeof(io_data_base) + new_size-1];
m_psend_data->TotalBuffBytes = new_size;
LOG_PRINT("Connection buffer resized up to " << new_size, LOG_LEVEL_3);
return true;
}
SOCKET m_sock;
net_utils::connection_context_base context;
TProtocol m_tprotocol_handler;
typename TProtocol::config_type m_dummy_config;
io_data_base* m_precv_data;
io_data_base* m_psend_data;
HANDLE m_completion_port;
volatile LONG m_asked_to_shutdown;
volatile LONG m_connection_shutwoned;
};
PRAGMA_WARNING_POP
bool worker_thread_member();
static unsigned CALLBACK worker_thread(void* param);
bool add_new_connection(SOCKET new_sock, long ip_from, int port_from);
bool shutdown_connection(connection<TProtocol>* pconn);
typedef std::map<SOCKET, boost::shared_ptr<connection<TProtocol> > > connections_container;
SOCKET m_listen_socket;
HANDLE m_completion_port;
connections_container m_connections;
critical_section m_connections_lock;
int m_port;
volatile LONG m_stop;
//abstract_handler* m_phandler;
bool m_initialized;
volatile LONG m_worker_thread_counter;
typename TProtocol::config_type m_config;
};
}
}
#include "abstract_tcp_server_cp.inl"
#endif //_LEVIN_SERVER_H_

View File

@ -1,607 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma comment(lib, "Ws2_32.lib")
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
namespace epee
{
namespace net_utils
{
template<class TProtocol>
cp_server_impl<TProtocol>::cp_server_impl():
m_port(0), m_stop(false),
m_worker_thread_counter(0), m_listen_socket(INVALID_SOCKET)
{
}
//-------------------------------------------------------------
template<class TProtocol>
cp_server_impl<TProtocol>::~cp_server_impl()
{
deinit_server();
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::init_server(int port_no)
{
m_port = port_no;
WSADATA wsad = {0};
int err = ::WSAStartup(MAKEWORD(2,2), &wsad);
if ( err != 0 || LOBYTE( wsad.wVersion ) != 2 || HIBYTE( wsad.wVersion ) != 2 )
{
LOG_ERROR("Could not find a usable WinSock DLL, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
m_initialized = true;
m_listen_socket = ::WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
if(INVALID_SOCKET == m_listen_socket)
{
err = ::WSAGetLastError();
LOG_ERROR("Failed to create socket, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
int opt = 1;
err = setsockopt (m_listen_socket, SOL_SOCKET,SO_REUSEADDR, reinterpret_cast<char*>(&opt), sizeof(int));
if(SOCKET_ERROR == err )
{
err = ::WSAGetLastError();
LOG_PRINT("Failed to setsockopt(SO_REUSEADDR), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_1);
deinit_server();
return false;
}
sockaddr_in adr = {0};
adr.sin_family = AF_INET;
adr.sin_addr.s_addr = htonl(INADDR_ANY);
adr.sin_port = (u_short)htons(m_port);
//binding
err = bind(m_listen_socket, (const sockaddr*)&adr, sizeof(adr ));
if(SOCKET_ERROR == err )
{
err = ::WSAGetLastError();
LOG_PRINT("Failed to Bind, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_1);
deinit_server();
return false;
}
m_completion_port = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
if(INVALID_HANDLE_VALUE == m_completion_port)
{
err = ::WSAGetLastError();
LOG_PRINT("Failed to CreateIoCompletionPort, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_1);
deinit_server();
return false;
}
return true;
}
//-------------------------------------------------------------
//-------------------------------------------------------------
static int CALLBACK CPConditionFunc(
IN LPWSABUF lpCallerId,
IN LPWSABUF lpCallerData,
IN OUT LPQOS lpSQOS,
IN OUT LPQOS lpGQOS,
IN LPWSABUF lpCalleeId,
OUT LPWSABUF lpCalleeData,
OUT GROUP FAR *g,
IN DWORD_PTR dwCallbackData
)
{
/*cp_server_impl* pthis = (cp_server_impl*)dwCallbackData;
if(!pthis)
return CF_REJECT;*/
/*if(pthis->get_active_connections_num()>=FD_SETSIZE-1)
{
LOG_PRINT("Maximum connections count overfull.", LOG_LEVEL_2);
return CF_REJECT;
}*/
return CF_ACCEPT;
}
//-------------------------------------------------------------
template<class TProtocol>
size_t cp_server_impl<TProtocol>::get_active_connections_num()
{
return m_connections.size();
}
//-------------------------------------------------------------
template<class TProtocol>
unsigned CALLBACK cp_server_impl<TProtocol>::worker_thread(void* param)
{
if(!param)
return 0;
cp_server_impl<TProtocol>* pthis = (cp_server_impl<TProtocol>*)param;
pthis->worker_thread_member();
return 1;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::worker_thread_member()
{
LOG_PRINT("Worker thread STARTED", LOG_LEVEL_1);
bool stop_handling = false;
while(!stop_handling)
{
PROFILE_FUNC("[worker_thread]Worker Loop");
DWORD bytes_transfered = 0;
connection<TProtocol>* pconnection = 0;
io_data_base* pio_data = 0;
{
PROFILE_FUNC("[worker_thread]GetQueuedCompletionStatus");
BOOL res = ::GetQueuedCompletionStatus (m_completion_port, &bytes_transfered , (PULONG_PTR)&pconnection, (LPOVERLAPPED *)&pio_data, INFINITE);
if (res == 0)
{
// check return code for error
int err = GetLastError();
LOG_PRINT("GetQueuedCompletionStatus failed with error " << err << " " << log_space::get_win32_err_descr(err), LOG_LEVEL_1);
if(pio_data)
::InterlockedExchange(&pio_data->m_is_in_use, 0);
continue;
}
}
if(pio_data)
::InterlockedExchange(&pio_data->m_is_in_use, 0);
if(!bytes_transfered && !pconnection && !pio_data)
{
//signal to stop
break;
}
if(!pconnection || !pio_data)
{
LOG_PRINT("BIG FAIL: pconnection or pio_data is empty: pconnection=" << pconnection << " pio_data=" << pio_data, LOG_LEVEL_0);
break;
}
if(::InterlockedCompareExchange(&pconnection->m_connection_shutwoned, 0, 0))
{
LOG_ERROR("InterlockedCompareExchange(&pconnection->m_connection_shutwoned, 0, 0)");
//DebugBreak();
}
if(pio_data->m_op_type == op_type_stop)
{
if(!pconnection)
{
LOG_ERROR("op_type=op_type_stop, but pconnection is empty!!!");
continue;
}
shutdown_connection(pconnection);
continue;//
}
else if(pio_data->m_op_type == op_type_send)
{
continue;
//do nothing, just queuing request
}else if(pio_data->m_op_type == op_type_recv)
{
PROFILE_FUNC("[worker_thread]m_tprotocol_handler.handle_recv");
if(bytes_transfered)
{
bool res = pconnection->m_tprotocol_handler.handle_recv(pio_data->Buffer, bytes_transfered);
if(!res)
pconnection->query_shutdown();
}
else
{
pconnection->query_shutdown();
continue;
}
}
//preparing new request,
{
PROFILE_FUNC("[worker_thread]RECV Request small loop");
int res = 0;
while(true)
{
LOG_PRINT("Prepearing data for WSARecv....", LOG_LEVEL_3);
ZeroMemory(&pio_data->m_overlapped, sizeof(OVERLAPPED));
pio_data->DataBuf.len = pio_data->TotalBuffBytes;
pio_data->DataBuf.buf = pio_data->Buffer;
pio_data->m_op_type = op_type_recv;
//calling WSARecv() and go to completion waiting
DWORD bytes_recvd = 0;
DWORD flags = 0;
LOG_PRINT("Calling WSARecv....", LOG_LEVEL_3);
::InterlockedExchange(&pio_data->m_is_in_use, 1);
res = WSARecv(pconnection->m_sock, &(pio_data->DataBuf), 1, &bytes_recvd , &flags, &(pio_data->m_overlapped), NULL);
if(res == SOCKET_ERROR )
{
int err = ::WSAGetLastError();
if(WSA_IO_PENDING == err )
{//go pending, ok
LOG_PRINT("WSARecv return WSA_IO_PENDING", LOG_LEVEL_3);
break;
}
LOG_ERROR("BIG FAIL: WSARecv error code not correct, res=" << res << " last_err=" << err);
::InterlockedExchange(&pio_data->m_is_in_use, 0);
pconnection->query_shutdown();
break;
}
break;
/*else if(0 == res)
{
if(!bytes_recvd)
{
::InterlockedExchange(&pio_data->m_is_in_use, 0);
LOG_PRINT("WSARecv return 0, bytes_recvd=0, graceful close.", LOG_LEVEL_3);
int err = ::WSAGetLastError();
//LOG_ERROR("BIG FAIL: WSARecv error code not correct, res=" << res << " last_err=" << err);
//pconnection->query_shutdown();
break;
}else
{
LOG_PRINT("WSARecv return immediatily 0, bytes_recvd=" << bytes_recvd, LOG_LEVEL_3);
//pconnection->m_tprotocol_handler.handle_recv(pio_data->Buffer, bytes_recvd);
}
}*/
}
}
}
LOG_PRINT("Worker thread STOPED", LOG_LEVEL_1);
::InterlockedDecrement(&m_worker_thread_counter);
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::shutdown_connection(connection<TProtocol>* pconn)
{
PROFILE_FUNC("[shutdown_connection]");
if(!pconn)
{
LOG_ERROR("Attempt to remove null pptr connection!");
return false;
}
else
{
LOG_PRINT("Shutting down connection ("<< pconn << ")", LOG_LEVEL_3);
}
m_connections_lock.lock();
connections_container::iterator it = m_connections.find(pconn->m_sock);
m_connections_lock.unlock();
if(it == m_connections.end())
{
LOG_ERROR("Failed to find closing socket=" << pconn->m_sock);
return false;
}
SOCKET sock = it->second->m_sock;
{
PROFILE_FUNC("[shutdown_connection] shutdown, close");
::shutdown(it->second->m_sock, SD_SEND );
}
size_t close_sock_wait_count = 0;
{
LOG_PRINT("Entered to 'in_use wait zone'", LOG_LEVEL_3);
PROFILE_FUNC("[shutdown_connection] wait for in_use");
while(::InterlockedCompareExchange(&it->second->m_precv_data->m_is_in_use, 1, 1))
{
Sleep(100);
close_sock_wait_count++;
}
LOG_PRINT("First step to 'in_use wait zone'", LOG_LEVEL_3);
while(::InterlockedCompareExchange(&it->second->m_psend_data->m_is_in_use, 1, 1))
{
Sleep(100);
close_sock_wait_count++;
}
LOG_PRINT("Leaved 'in_use wait zone'", LOG_LEVEL_3);
}
::closesocket(it->second->m_sock);
::InterlockedExchange(&it->second->m_connection_shutwoned, 1);
m_connections_lock.lock();
m_connections.erase(it);
m_connections_lock.unlock();
LOG_PRINT("Socked " << sock << " closed, wait_count=" << close_sock_wait_count, LOG_LEVEL_2);
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::run_server(int threads_count = 0)
{
int err = listen(m_listen_socket, 100);
if(SOCKET_ERROR == err )
{
err = ::WSAGetLastError();
LOG_ERROR("Failed to listen, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
if(!threads_count)
{
SYSTEM_INFO si = {0};
::GetSystemInfo(&si);
threads_count = si.dwNumberOfProcessors + 2;
}
for(int i = 0; i != threads_count; i++)
{
boost::thread(boost::bind(&cp_server_impl::worker_thread_member, this));
//HANDLE h_thread = threads_helper::create_thread(worker_thread, this);
InterlockedIncrement(&m_worker_thread_counter);
//::CloseHandle(h_thread);
}
LOG_PRINT("Numbers of worker threads started: " << threads_count, LOG_LEVEL_1);
m_stop = false;
while(!m_stop)
{
PROFILE_FUNC("[run_server] main_loop");
TIMEVAL tv = {0};
tv.tv_sec = 0;
tv.tv_usec = 100;
fd_set sock_set;
sock_set.fd_count = 1;
sock_set.fd_array[0] = m_listen_socket;
int select_res = 0;
{
PROFILE_FUNC("[run_server] select");
select_res = select(0, &sock_set, &sock_set, NULL, &tv);
}
if(SOCKET_ERROR == select_res)
{
err = ::WSAGetLastError();
LOG_ERROR("Failed to select, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
return false;
}
if(!select_res)
{
on_net_idle();
continue;
}
else
{
sockaddr_in adr_from = {0};
int adr_len = sizeof(adr_from);
SOCKET new_sock = INVALID_SOCKET;
{
PROFILE_FUNC("[run_server] WSAAccept");
new_sock = ::WSAAccept(m_listen_socket, (sockaddr *)&adr_from, &adr_len, CPConditionFunc, (DWORD_PTR)this);
}
if(INVALID_SOCKET == new_sock)
{
if(m_stop)
break;
int err = ::WSAGetLastError();
LOG_PRINT("Failed to WSAAccept, err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_2);
continue;
}
LOG_PRINT("Accepted connection (new socket=" << new_sock << ")", LOG_LEVEL_2);
{
PROFILE_FUNC("[run_server] Add new connection");
add_new_connection(new_sock, adr_from.sin_addr.s_addr, adr_from.sin_port);
}
}
}
LOG_PRINT("Closing connections("<< m_connections.size() << ") and waiting...", LOG_LEVEL_2);
m_connections_lock.lock();
for(connections_container::iterator it = m_connections.begin(); it != m_connections.end(); it++)
{
::shutdown(it->second->m_sock, SD_BOTH);
::closesocket(it->second->m_sock);
}
m_connections_lock.unlock();
size_t wait_count = 0;
while(m_connections.size() && wait_count < 100)
{
::Sleep(100);
wait_count++;
}
LOG_PRINT("Connections closed OK (wait_count=" << wait_count << ")", LOG_LEVEL_2);
LOG_PRINT("Stopping worker threads("<< m_worker_thread_counter << ").", LOG_LEVEL_2);
for(int i = 0; i<m_worker_thread_counter; i++)
{
::PostQueuedCompletionStatus(m_completion_port, 0, 0, 0);
}
wait_count = 0;
while(InterlockedCompareExchange(&m_worker_thread_counter, 0, 0) && wait_count < 100)
{
Sleep(100);
wait_count++;
}
LOG_PRINT("Net Server STOPPED, wait_count = " << wait_count, LOG_LEVEL_1);
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::add_new_connection(SOCKET new_sock, const network_address &address_from)
{
PROFILE_FUNC("[add_new_connection]");
LOG_PRINT("Add new connection zone: entering lock", LOG_LEVEL_3);
m_connections_lock.lock();
boost::shared_ptr<connection<TProtocol> > ptr;
ptr.reset(new connection<TProtocol>(m_config));
connection<TProtocol>& conn = *ptr.get();
m_connections[new_sock] = ptr;
LOG_PRINT("Add new connection zone: leaving lock", LOG_LEVEL_3);
m_connections_lock.unlock();
conn.init_buffers();
conn.m_sock = new_sock;
conn.context.m_remote_address = address_from;
conn.m_completion_port = m_completion_port;
{
PROFILE_FUNC("[add_new_connection] CreateIoCompletionPort");
::CreateIoCompletionPort((HANDLE)new_sock, m_completion_port, (ULONG_PTR)&conn, 0);
}
//if(NULL == ::CreateIoCompletionPort((HANDLE)new_sock, m_completion_port, (ULONG_PTR)&conn, 0))
//{
// int err = ::GetLastError();
// LOG_PRINT("Failed to CreateIoCompletionPort(associate socket and completion port), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"", LOG_LEVEL_2);
// return false;
//}
conn.m_tprotocol_handler.after_init_connection();
{
PROFILE_FUNC("[add_new_connection] starting loop");
int res = 0;
while(true)//res!=SOCKET_ERROR)
{
PROFILE_FUNC("[add_new_connection] in loop time");
conn.m_precv_data->TotalBuffBytes = LEVIN_DEFAULT_DATA_BUFF_SIZE;
ZeroMemory(&conn.m_precv_data->m_overlapped, sizeof(OVERLAPPED));
conn.m_precv_data->DataBuf.len = conn.m_precv_data->TotalBuffBytes;
conn.m_precv_data->DataBuf.buf = conn.m_precv_data->Buffer;
conn.m_precv_data->m_op_type = op_type_recv;
InterlockedExchange(&conn.m_precv_data->m_is_in_use, 1);
DWORD bytes_recvd = 0;
DWORD flags = 0;
::InterlockedExchange(&conn.m_precv_data->m_is_in_use, 1);
{
PROFILE_FUNC("[add_new_connection] ::WSARecv");
res = ::WSARecv(conn.m_sock, &(conn.m_precv_data->DataBuf), 1, &bytes_recvd , &flags, &(conn.m_precv_data->m_overlapped), NULL);
}
if(res == SOCKET_ERROR )
{
int err = ::WSAGetLastError();
if(WSA_IO_PENDING == err )
{
break;
}
LOG_ERROR("BIG FAIL: WSARecv error code not correct, res=" << res << " last_err=" << err << " " << log_space::get_win32_err_descr(err));
::InterlockedExchange(&conn.m_precv_data->m_is_in_use, 0);
conn.query_shutdown();
//shutdown_connection(&conn);
break;
}
break;
/*else if(0 == res)
{
if(!bytes_recvd)
{
PROFILE_FUNC("[add_new_connection] shutdown_connection");
::InterlockedExchange(&conn.m_precv_data->m_is_in_use, 0);
conn.query_shutdown();
//shutdown_connection(&conn);
break;
}else
{
PROFILE_FUNC("[add_new_connection] handle_recv");
}
}*/
}
}
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::deinit_server()
{
if(!m_initialized)
return true;
if(INVALID_SOCKET != m_listen_socket)
{
shutdown(m_listen_socket, SD_BOTH);
int res = closesocket(m_listen_socket);
if(SOCKET_ERROR == res)
{
int err = ::WSAGetLastError();
LOG_ERROR("Failed to closesocket(), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
}
m_listen_socket = INVALID_SOCKET;
}
int res = ::WSACleanup();
if(SOCKET_ERROR == res)
{
int err = ::WSAGetLastError();
LOG_ERROR("Failed to WSACleanup(), err = " << err << " \"" << socket_errors::get_socket_error_text(err) <<"\"");
}
m_initialized = false;
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::send_stop_signal()
{
::InterlockedExchange(&m_stop, 1);
return true;
}
//-------------------------------------------------------------
template<class TProtocol>
bool cp_server_impl<TProtocol>::is_stop_signal()
{
return m_stop?true:false;
}
//-------------------------------------------------------------
}
}

View File

@ -1,4 +1,5 @@
// Copyright (c) 2018, The Monero Project
// Copyright (c) 2018-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -8,7 +8,7 @@
// ! (how ever if in some wonderful juristdictions that is not the case, then why not make another sub-class withat that members and licence it as epee part)
// ! Working on above premise, IF this is valid in your juristdictions, then consider this code as released as:
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//
@ -106,7 +106,7 @@ class connection_basic { // not-templated base class for rapid developmet of som
std::unique_ptr< connection_basic_pimpl > mI; // my Implementation
// moved here from orginal connecton<> - common member variables that do not depend on template in connection<>
volatile uint32_t m_want_close_connection;
std::atomic<bool> m_want_close_connection;
std::atomic<bool> m_was_shutdown;
critical_section m_send_que_lock;
std::deque<byte_slice> m_send_que;

View File

@ -1,4 +1,5 @@
// Copyright (c) 2018, The Monero Project
// Copyright (c) 2018-2022, The Monero Project
//
// All rights reserved.
//
@ -63,3 +64,13 @@ namespace net_utils
} // net_utils
} // epee
namespace std
{
template<> struct hash<epee::net_utils::zone>
{
std::size_t operator()(const epee::net_utils::zone _z) const
{
return static_cast<std::size_t>(_z);
}
};
} // std

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//

View File

@ -39,18 +39,12 @@
#include "net_helper.h"
#include "http_client_base.h"
#ifdef HTTP_ENABLE_GZIP
#include "gzip_encoding.h"
#endif
#include "string_tools.h"
#include "string_tools_lexical.h"
#include "reg_exp_definer.h"
#include "abstract_http_client.h"
#include "http_base.h"
#include "http_auth.h"
#include "to_nonconst_iterator.h"
#include "net_parse_helpers.h"
#include "syncobj.h"
@ -763,13 +757,9 @@ namespace net_utils
boost::smatch result; // 12 3
if(boost::regex_search( m_response_info.m_header_info.m_content_encoding, result, rexp_match_gzip, boost::match_default) && result[0].matched)
{
#ifdef HTTP_ENABLE_GZIP
m_pcontent_encoding_handler.reset(new content_encoding_gzip(this, result[3].matched));
#else
m_pcontent_encoding_handler.reset(new do_nothing_sub_handler(this));
LOG_ERROR("GZIP encoding not supported in this build, please add zlib to your project and define HTTP_ENABLE_GZIP");
LOG_ERROR("GZIP encoding not supported");
return false;
#endif
}
else
{

View File

@ -1,180 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
//
#pragma once
#include <wininet.h>
#include <atlutil.h>
#pragma comment(lib, "Wininet.lib")
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
namespace epee
{
namespace net_utils
{
inline
bool http_ssl_invoke(const std::string& url, const std::string usr, const std::string psw, std::string& http_response_body, bool use_post = false)
{
bool final_res = false;
ATL::CUrl url_obj;
BOOL crack_rss = url_obj.CrackUrl(string_encoding::convert_to_t<std::basic_string<TCHAR> >(url).c_str());
HINTERNET hinet = ::InternetOpenA(SHARED_JOBSCOMMON_HTTP_AGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(!hinet)
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetOpenA, \nError: " << err << " " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
return false;
}
DWORD dwFlags = 0;
DWORD dwBuffLen = sizeof(dwFlags);
if(usr.size())
{
dwFlags |= INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID|
INTERNET_FLAG_PRAGMA_NOCACHE | SECURITY_FLAG_IGNORE_UNKNOWN_CA|INTERNET_FLAG_SECURE;
}else
{
dwFlags |= INTERNET_FLAG_PRAGMA_NOCACHE;
}
int port = url_obj.GetPortNumber();
BOOL res = FALSE;
HINTERNET hsession = ::InternetConnectA(hinet, string_encoding::convert_to_ansii(url_obj.GetHostName()).c_str(), port/*INTERNET_DEFAULT_HTTPS_PORT*/, usr.c_str(), psw.c_str(), INTERNET_SERVICE_HTTP, dwFlags, NULL);
if(hsession)
{
const std::string uri = string_encoding::convert_to_ansii(url_obj.GetUrlPath()) + string_encoding::convert_to_ansii(url_obj.GetExtraInfo());
HINTERNET hrequest = ::HttpOpenRequestA(hsession, use_post?"POST":NULL, uri.c_str(), NULL, NULL,NULL, dwFlags, NULL);
if(hrequest)
{
while(true)
{
res = ::HttpSendRequestA(hrequest, NULL, 0, NULL, 0);
if(!res)
{
//ERROR_INTERNET_INVALID_CA 45
//ERROR_INTERNET_INVALID_URL (INTERNET_ERROR_BASE + 5)
int err = ::GetLastError();
LOG_PRINT("Failed to call HttpSendRequestA, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
break;
}
DWORD code = 0;
DWORD buf_len = sizeof(code);
DWORD index = 0;
res = ::HttpQueryInfo(hrequest, HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE, &code, &buf_len, &index);
if(!res)
{
//ERROR_INTERNET_INVALID_CA 45
//ERROR_INTERNET_INVALID_URL (INTERNET_ERROR_BASE + 5)
int err = ::GetLastError();
LOG_PRINT("Failed to call HttpQueryInfo, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
break;
}
if(code < 200 || code > 299)
{
LOG_PRINT("Wrong server response, HttpQueryInfo returned statuse code" << code , LOG_LEVEL_0);
break;
}
char buff[100000] = {0};
DWORD readed = 0;
while(true)
{
res = ::InternetReadFile(hrequest, buff, sizeof(buff), &readed);
if(!res)
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetReadFile, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
break;
}
if(readed)
{
http_response_body.append(buff, readed);
}
else
break;
}
if(!res)
break;
//we success
final_res = true;
res = ::InternetCloseHandle(hrequest);
if(!res)
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetCloseHandle, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
}
break;
}
}
else
{
//ERROR_INTERNET_INVALID_CA
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetOpenUrlA, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
return false;
}
res = ::InternetCloseHandle(hsession);
if(!res)
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetCloseHandle, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
}
}else
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetConnectA(" << string_encoding::convert_to_ansii(url_obj.GetHostName()) << ", port " << port << " \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
}
res = ::InternetCloseHandle(hinet);
if(!res)
{
int err = ::GetLastError();
LOG_PRINT("Failed to call InternetCloseHandle, \nError: " << log_space::get_win32_err_descr(err), LOG_LEVEL_0);
}
return final_res;
}
}
}

View File

@ -33,7 +33,6 @@
#include <boost/optional/optional.hpp>
#include <string>
#include "net_utils_base.h"
#include "to_nonconst_iterator.h"
#include "http_auth.h"
#include "http_base.h"
@ -56,6 +55,7 @@ namespace net_utils
std::string m_folder;
std::vector<std::string> m_access_control_origins;
boost::optional<login> m_user;
size_t m_max_content_length{std::numeric_limits<size_t>::max()};
critical_section m_lock;
};
@ -142,6 +142,7 @@ namespace net_utils
config_type& m_config;
bool m_want_close;
size_t m_newlines;
size_t m_bytes_read;
protected:
i_service_endpoint* m_psnd_hndlr;
t_connection_context& m_conn_context;

Some files were not shown because too many files have changed in this diff Show More