Skip to content

Commit

Permalink
SS Functionality & Core updates
Browse files Browse the repository at this point in the history
  • Loading branch information
n3alz committed Dec 28, 2020
1 parent d089538 commit 6dcb187
Show file tree
Hide file tree
Showing 189 changed files with 16,632 additions and 3,102 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@
/tags
log/
./log
blue
rog

# vim swap files
*.swp
Expand Down
20 changes: 17 additions & 3 deletions CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2019, uPlexa Team
# Copyright (c) 2018-2020 uPlexa Team
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
Expand Down Expand Up @@ -105,6 +105,10 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)

# On Darwin, ensure the user-defined paths are used to find PCSC
# before falling back to the system frameworks.
set(CMAKE_FIND_FRAMEWORK "LAST")

# ARCH defines the target architecture, either by an explicit identifier or
# one of the following two keywords. By default, ARCH a value of 'native':
# target arch = host arch, binary is not portable. When ARCH is set to the
Expand Down Expand Up @@ -187,7 +191,7 @@ if(NOT MANUAL_SUBMODULES)
message(FATAL_ERROR "Submodule '${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --force ${relative_path}\nor run cmake with -DMANUAL_SUBMODULES=1")
endif()
endfunction ()

message(STATUS "Checking submodules")
check_submodule(external/miniupnp)
check_submodule(external/unbound)
Expand Down Expand Up @@ -514,6 +518,16 @@ else (HIDAPI_FOUND)
message(STATUS "Could not find HIDAPI")
endif()

# Protobuf, optional. Required for TREZOR.
include(FindProtobuf)
find_package(Protobuf)
if(Protobuf_FOUND)
set(HAVE_PROTOBUF 1)
add_definitions(-DHAVE_PROTOBUF=1)
else(Protobuf_FOUND)
message(STATUS "Could not find Protobuf")
endif()

if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
Expand Down Expand Up @@ -895,7 +909,7 @@ endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;crypt32)
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;crypt32;bcrypt)
if(DEPENDS)
set(ICU_LIBRARIES ${Boost_LOCALE_LIBRARY} sicuio sicuin sicuuc sicudt sicutu iconv)
else()
Expand Down
17 changes: 13 additions & 4 deletions Makefile
@@ -1,4 +1,4 @@
# Copyright (c) 2018, uPlexa Team
# Copyright (c) 2018-2020, uPlexa Team
#
# All rights reserved.
#
Expand Down Expand Up @@ -28,6 +28,11 @@

ANDROID_STANDALONE_TOOLCHAIN_PATH ?= /usr/local/toolchain

dotgit=$(shell ls -d .git/config)
ifneq ($(dotgit), .git/config)
USE_SINGLE_BUILDDIR=1
endif

subbuilddir:=$(shell echo `uname | sed -e 's|[:/\\ \(\)]|_|g'`/`git branch | grep '\* ' | cut -f2- -d' '| sed -e 's|[:/\\ \(\)]|_|g'`)
ifeq ($(USE_SINGLE_BUILDDIR),)
builddir := build/"$(subbuilddir)"
Expand All @@ -41,6 +46,10 @@ endif
all: release-all
depends:
cd contrib/depends && $(MAKE) HOST=$(target) && cd ../.. && mkdir -p build/$(target)/release
cd build/$(target)/release && cmake -DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/contrib/depends/$(target)/share/toolchain.cmake ../../.. && $(MAKE)
cmake-debug:
mkdir -p $(builddir)/debug
cd $(builddir)/debug && cmake -D CMAKE_BUILD_TYPE=Debug $(topdir)
Expand All @@ -65,11 +74,11 @@ debug-static-all:
debug-static-win64:
mkdir -p $(builddir)/debug
cd $(builddir)/debug && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys64 $(topdir) && $(MAKE)
debug-static-win32:
mkdir -p $(builddir)/debug
cd $(builddir)/debug && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x32" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 $(topdir) && $(MAKE)
cmake-release:
mkdir -p $(builddir)/release
cd $(builddir)/release && cmake -D CMAKE_BUILD_TYPE=Release $(topdir)
Expand Down Expand Up @@ -158,6 +167,6 @@ clean-all:
rm -rf ./build
tags:
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest tests
.PHONY: all cmake-debug debug debug-test debug-all cmake-release release release-test release-all clean tags
1 change: 0 additions & 1 deletion contrib/CMakeLists.txt
@@ -1,4 +1,3 @@

# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
Expand Down
16 changes: 8 additions & 8 deletions contrib/epee/CMakeLists.txt
@@ -1,22 +1,21 @@

# Copyright (c) 2014-2019, The Monero Project
#
# Copyright (c) 2014-2018, The Monero Project
#
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
Expand All @@ -28,3 +27,4 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

add_subdirectory(src)

1 change: 1 addition & 0 deletions contrib/epee/demo/.gitignore
@@ -0,0 +1 @@
/build/*
3 changes: 1 addition & 2 deletions contrib/epee/include/fnv1.h
@@ -1,5 +1,4 @@

// Copyright (c) 2014-2019, The Monero Project
// Copyright (c) 2018, The Monero Project
//
// All rights reserved.
//
Expand Down
3 changes: 1 addition & 2 deletions contrib/epee/include/hex.h
@@ -1,5 +1,4 @@
// Copyright (c) 2017-2018, uPlexa Team
// Copyright (c) 2014-2019, The Monero Project
// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
Expand Down
3 changes: 1 addition & 2 deletions contrib/epee/include/memwipe.h
@@ -1,5 +1,4 @@
// Copyright (c) 2017-2018, uPlexa Team
// Copyright (c) 2014-2019, The Monero Project
// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
Expand Down
3 changes: 2 additions & 1 deletion contrib/epee/include/misc_language.h
Expand Up @@ -147,7 +147,8 @@ namespace misc_utils
{}
~call_befor_die()
{
m_func();
try { m_func(); }
catch (...) { /* ignore */ }
}
};

Expand Down
2 changes: 2 additions & 0 deletions contrib/epee/include/misc_log_ex.h
Expand Up @@ -32,7 +32,9 @@

#include "easylogging++.h"

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "default"

#define MAX_LOG_FILE_SIZE 104850000 // 100 MB - 7600 bytes
#define MAX_LOG_FILES 50

Expand Down
3 changes: 1 addition & 2 deletions contrib/epee/include/mlocker.h
@@ -1,5 +1,4 @@

// Copyright (c) 2014-2019, The Monero Project
// Copyright (c) 2018, The Monero Project
//
// All rights reserved.
//
Expand Down
21 changes: 14 additions & 7 deletions contrib/epee/include/net/abstract_tcp_server2.h
Expand Up @@ -198,8 +198,8 @@ namespace net_utils
std::map<std::string, t_connection_type> server_type_map;
void create_server_type_map();

bool init_server(uint32_t port, const std::string address = "0.0.0.0");
bool init_server(const std::string port, const std::string& address = "0.0.0.0");
bool init_server(uint32_t port, const std::string address = "0.0.0.0", uint32_t port_ipv6 = 0, const std::string address_v6 = "::", bool no_ipv6 = false);
bool init_server(const std::string port, const std::string& address = "0.0.0.0", const std::string& port_ipv6 = "", const std::string address_v6 = "::", bool no_ipv6 = false);

/// Run the server's io_service loop.
bool run_server(size_t threads_count, bool wait = true, const boost::thread::attributes& attrs = boost::thread::attributes());
Expand Down Expand Up @@ -227,6 +227,7 @@ namespace net_utils
typename t_protocol_handler::config_type& get_config_object(){return m_config;}

int get_binded_port(){return m_port;}
int get_binded_port_ipv6(){return m_port_ipv6;}

long get_connections_count() const
{
Expand All @@ -246,7 +247,6 @@ namespace net_utils
m_timer(io_serice)
{}
boost::asio::deadline_timer m_timer;
uint64_t m_period;
};

template <class t_handler>
Expand All @@ -262,25 +262,27 @@ namespace net_utils
{
return m_handler();
}
uint64_t m_period;
};

template<class t_handler>
bool add_idle_handler(t_handler t_callback, uint64_t timeout_ms)
{
boost::shared_ptr<idle_callback_conext_base> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
boost::shared_ptr<idle_callback_conext<t_handler>> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
//needed call handler here ?...
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
return true;
}

bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext_base> ptr)
template<class t_handler>
bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext<t_handler>> ptr)
{
//if handler return false - he don't want to be called anymore
if(!ptr->call_handler())
return true;
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
return true;
}

Expand All @@ -299,6 +301,7 @@ namespace net_utils
bool worker_thread();
/// Handle completion of an asynchronous accept operation.
void handle_accept(const boost::system::error_code& e);
void handle_accept_v6(const boost::system::error_code& e);

bool is_thread_worker();

Expand All @@ -308,12 +311,15 @@ namespace net_utils

/// Acceptor used to listen for incoming connections.
boost::asio::ip::tcp::acceptor acceptor_;
boost::asio::ip::tcp::acceptor acceptor_v6;

std::atomic<bool> m_stop_signal_sent;
uint32_t m_port;
uint32_t m_port_ipv6;
std::atomic<long> m_sock_count;
std::atomic<long> m_sock_number;
std::string m_address;
std::string m_address_v6;
std::string m_thread_name_prefix; //TODO: change to enum server_type, now used
size_t m_threads_count;
i_connection_filter* m_pfilter;
Expand All @@ -326,6 +332,7 @@ namespace net_utils

/// The next connection to be accepted
connection_ptr new_connection_;
connection_ptr new_connection_v6;

boost::mutex connections_mutex;
std::set<connection_ptr> connections_;
Expand Down

0 comments on commit 6dcb187

Please sign in to comment.