mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
ADNL Tunnel library integration
This commit is contained in:
parent
2a68c8610b
commit
4737d5f83d
13 changed files with 348 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -24,3 +24,4 @@ libsodium-1.0.18-stable-msvc.zip
|
||||||
libmicrohttpd-0.9.77-w32-bin.zip
|
libmicrohttpd-0.9.77-w32-bin.zip
|
||||||
openssl-3.1.4.zip
|
openssl-3.1.4.zip
|
||||||
readline-5.0-1-lib.zip
|
readline-5.0-1-lib.zip
|
||||||
|
libtunnel.a
|
|
@ -105,6 +105,20 @@ option(TON_USE_ASAN "Use \"ON\" to enable AddressSanitizer." OFF)
|
||||||
option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF)
|
option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF)
|
||||||
option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF)
|
option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF)
|
||||||
set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=")
|
set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=")
|
||||||
|
option(TON_USE_GO_TUNNEL "Use \"ON\" to enable ADNL Tunnel over shared Go library." ON)
|
||||||
|
|
||||||
|
if (TON_USE_GO_TUNNEL)
|
||||||
|
set(TUNNEL_GO_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libtunnel.a")
|
||||||
|
if (EXISTS "${TUNNEL_GO_LIB_PATH}")
|
||||||
|
message(STATUS "Found ADNL Tunnel library (Go): ${TUNNEL_GO_LIB_PATH}")
|
||||||
|
|
||||||
|
add_library(tunnel STATIC IMPORTED)
|
||||||
|
set_target_properties(tunnel PROPERTIES IMPORTED_LOCATION "${TUNNEL_GO_LIB_PATH}")
|
||||||
|
set(TUNNEL_LIB_IF_USED "tunnel")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Missing ADNL Tunnel library (Go), but enabled: ${TUNNEL_GO_LIB_PATH}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
#BEGIN M1 support
|
#BEGIN M1 support
|
||||||
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
|
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
|
||||||
|
|
|
@ -76,6 +76,35 @@ size_t AdnlNetworkManagerImpl::add_listening_udp_port(td::uint16 port) {
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t AdnlNetworkManagerImpl::add_tunnel_udp_port(td::uint16 port, td::Promise<td::IPAddress> on_ready) {
|
||||||
|
auto it = port_2_socket_.find(port);
|
||||||
|
if (it != port_2_socket_.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
class Callback : public td::UdpServer::Callback {
|
||||||
|
public:
|
||||||
|
Callback(td::actor::ActorShared<AdnlNetworkManagerImpl> manager, size_t idx)
|
||||||
|
: manager_(std::move(manager)), idx_(idx) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
td::actor::ActorShared<AdnlNetworkManagerImpl> manager_;
|
||||||
|
size_t idx_;
|
||||||
|
void on_udp_message(td::UdpMessage udp_message) override {
|
||||||
|
td::actor::send_closure_later(manager_, &AdnlNetworkManagerImpl::receive_udp_message, std::move(udp_message),
|
||||||
|
idx_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto idx = udp_sockets_.size();
|
||||||
|
auto X = td::UdpServer::create_via_tunnel("udp tunnel server", port,
|
||||||
|
std::make_unique<Callback>(actor_shared(this), idx), std::move(on_ready));
|
||||||
|
X.ensure();
|
||||||
|
port_2_socket_[port] = idx;
|
||||||
|
udp_sockets_.push_back(UdpSocketDesc{port, X.move_as_ok()});
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
void AdnlNetworkManagerImpl::add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) {
|
void AdnlNetworkManagerImpl::add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) {
|
||||||
auto port = td::narrow_cast<td::uint16>(addr.get_port());
|
auto port = td::narrow_cast<td::uint16>(addr.get_port());
|
||||||
size_t idx = add_listening_udp_port(port);
|
size_t idx = add_listening_udp_port(port);
|
||||||
|
@ -92,6 +121,23 @@ void AdnlNetworkManagerImpl::add_self_addr(td::IPAddress addr, AdnlCategoryMask
|
||||||
out_desc_[priority].push_back(std::move(d));
|
out_desc_[priority].push_back(std::move(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlNetworkManagerImpl::add_tunnel(td::uint16 port, AdnlCategoryMask cat_mask, td::uint32 priority,
|
||||||
|
td::Promise<td::IPAddress> on_ready) {
|
||||||
|
size_t idx = add_tunnel_udp_port(port, std::move(on_ready));
|
||||||
|
|
||||||
|
add_in_addr(InDesc{port, nullptr, cat_mask}, idx);
|
||||||
|
auto d = OutDesc{port, td::IPAddress{}, nullptr, idx};
|
||||||
|
for (auto &it : out_desc_[priority]) {
|
||||||
|
if (it == d) {
|
||||||
|
it.cat_mask |= cat_mask;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.cat_mask = cat_mask;
|
||||||
|
out_desc_[priority].push_back(std::move(d));
|
||||||
|
}
|
||||||
|
|
||||||
void AdnlNetworkManagerImpl::add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
void AdnlNetworkManagerImpl::add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
||||||
AdnlCategoryMask cat_mask, td::uint32 priority) {
|
AdnlCategoryMask cat_mask, td::uint32 priority) {
|
||||||
size_t idx = add_listening_udp_port(local_port);
|
size_t idx = add_listening_udp_port(local_port);
|
||||||
|
|
|
@ -70,6 +70,8 @@ class AdnlNetworkManager : public td::actor::Actor {
|
||||||
|
|
||||||
virtual void install_callback(std::unique_ptr<Callback> callback) = 0;
|
virtual void install_callback(std::unique_ptr<Callback> callback) = 0;
|
||||||
|
|
||||||
|
virtual void add_tunnel(td::uint16 port, AdnlCategoryMask cat_mask, td::uint32 priority,
|
||||||
|
td::Promise<td::IPAddress> on_ready) = 0;
|
||||||
virtual void add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) = 0;
|
virtual void add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) = 0;
|
||||||
virtual void add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
virtual void add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
||||||
AdnlCategoryMask cat_mask, td::uint32 priority) = 0;
|
AdnlCategoryMask cat_mask, td::uint32 priority) = 0;
|
||||||
|
|
|
@ -95,6 +95,10 @@ class AdnlNetworkManagerImpl : public AdnlNetworkManager {
|
||||||
size_t in_desc{std::numeric_limits<size_t>::max()};
|
size_t in_desc{std::numeric_limits<size_t>::max()};
|
||||||
bool allow_proxy{false};
|
bool allow_proxy{false};
|
||||||
};
|
};
|
||||||
|
struct TunnelDesc {
|
||||||
|
size_t index{};
|
||||||
|
td::IPAddress address;
|
||||||
|
};
|
||||||
|
|
||||||
OutDesc *choose_out_iface(td::uint8 cat, td::uint32 priority);
|
OutDesc *choose_out_iface(td::uint8 cat, td::uint32 priority);
|
||||||
|
|
||||||
|
@ -127,6 +131,8 @@ class AdnlNetworkManagerImpl : public AdnlNetworkManager {
|
||||||
in_desc_.push_back(std::move(desc));
|
in_desc_.push_back(std::move(desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_tunnel(td::uint16 port, AdnlCategoryMask cat_mask, td::uint32 priority,
|
||||||
|
td::Promise<td::IPAddress> on_ready) override;
|
||||||
void add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) override;
|
void add_self_addr(td::IPAddress addr, AdnlCategoryMask cat_mask, td::uint32 priority) override;
|
||||||
void add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
void add_proxy_addr(td::IPAddress addr, td::uint16 local_port, std::shared_ptr<AdnlProxy> proxy,
|
||||||
AdnlCategoryMask cat_mask, td::uint32 priority) override;
|
AdnlCategoryMask cat_mask, td::uint32 priority) override;
|
||||||
|
@ -141,6 +147,7 @@ class AdnlNetworkManagerImpl : public AdnlNetworkManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t add_tunnel_udp_port(td::uint16 port, td::Promise<td::IPAddress> on_ready);
|
||||||
size_t add_listening_udp_port(td::uint16 port);
|
size_t add_listening_udp_port(td::uint16 port);
|
||||||
void receive_udp_message(td::UdpMessage message, size_t idx);
|
void receive_udp_message(td::UdpMessage message, size_t idx);
|
||||||
void proxy_register(OutDesc &desc);
|
void proxy_register(OutDesc &desc);
|
||||||
|
|
|
@ -12,7 +12,7 @@ set(TDNET_SOURCE
|
||||||
|
|
||||||
add_library(tdnet STATIC ${TDNET_SOURCE})
|
add_library(tdnet STATIC ${TDNET_SOURCE})
|
||||||
target_include_directories(tdnet PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(tdnet PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
target_link_libraries(tdnet PUBLIC tdactor)
|
target_link_libraries(tdnet PUBLIC tdactor ${TUNNEL_LIB_IF_USED})
|
||||||
|
|
||||||
add_executable(tcp_ping_pong example/tcp_ping_pong.cpp)
|
add_executable(tcp_ping_pong example/tcp_ping_pong.cpp)
|
||||||
target_link_libraries(tcp_ping_pong PRIVATE tdactor tdnet)
|
target_link_libraries(tcp_ping_pong PRIVATE tdactor tdnet)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -37,6 +37,10 @@ class UdpServer : public td::actor::Actor {
|
||||||
static Result<actor::ActorOwn<UdpServer>> create(td::Slice name, int32 port, std::unique_ptr<Callback> callback);
|
static Result<actor::ActorOwn<UdpServer>> create(td::Slice name, int32 port, std::unique_ptr<Callback> callback);
|
||||||
static Result<actor::ActorOwn<UdpServer>> create_via_tcp(td::Slice name, int32 port,
|
static Result<actor::ActorOwn<UdpServer>> create_via_tcp(td::Slice name, int32 port,
|
||||||
std::unique_ptr<Callback> callback);
|
std::unique_ptr<Callback> callback);
|
||||||
|
static Result<actor::ActorOwn<UdpServer>> create_via_tunnel(td::Slice name, int32 port,
|
||||||
|
std::unique_ptr<Callback> callback,
|
||||||
|
td::Promise<td::IPAddress> on_ready);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|
104
tdnet/td/net/tunnel/libtunnel.h
Normal file
104
tdnet/td/net/tunnel/libtunnel.h
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
||||||
|
|
||||||
|
/* package command-line-arguments */
|
||||||
|
|
||||||
|
|
||||||
|
#line 1 "cgo-builtin-export-prolog"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
||||||
|
#define GO_CGO_EXPORT_PROLOGUE_H
|
||||||
|
|
||||||
|
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||||
|
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Start of preamble from import "C" comments. */
|
||||||
|
|
||||||
|
|
||||||
|
#line 3 "lib.go"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t index;
|
||||||
|
int ip;
|
||||||
|
int port;
|
||||||
|
} Tunnel;
|
||||||
|
|
||||||
|
// next - is pointer to class instance or callback to call method from node code
|
||||||
|
typedef void (*RecvCallback)(void* next, char * data, size_t num);
|
||||||
|
|
||||||
|
typedef void (*PullSendCallback)(void* next, char * data, size_t num);
|
||||||
|
|
||||||
|
|
||||||
|
// we need it because we cannot call C func by pointer directly from go
|
||||||
|
static inline void on_recv_batch_ready(RecvCallback cb, void* next, void* data, size_t num) {
|
||||||
|
cb(next, (char*)data, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
#line 1 "cgo-generated-wrapper"
|
||||||
|
|
||||||
|
|
||||||
|
/* End of preamble from import "C" comments. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Start of boilerplate cgo prologue. */
|
||||||
|
#line 1 "cgo-gcc-export-header-prolog"
|
||||||
|
|
||||||
|
#ifndef GO_CGO_PROLOGUE_H
|
||||||
|
#define GO_CGO_PROLOGUE_H
|
||||||
|
|
||||||
|
typedef signed char GoInt8;
|
||||||
|
typedef unsigned char GoUint8;
|
||||||
|
typedef short GoInt16;
|
||||||
|
typedef unsigned short GoUint16;
|
||||||
|
typedef int GoInt32;
|
||||||
|
typedef unsigned int GoUint32;
|
||||||
|
typedef long long GoInt64;
|
||||||
|
typedef unsigned long long GoUint64;
|
||||||
|
typedef GoInt64 GoInt;
|
||||||
|
typedef GoUint64 GoUint;
|
||||||
|
typedef size_t GoUintptr;
|
||||||
|
typedef float GoFloat32;
|
||||||
|
typedef double GoFloat64;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <complex.h>
|
||||||
|
typedef _Fcomplex GoComplex64;
|
||||||
|
typedef _Dcomplex GoComplex128;
|
||||||
|
#else
|
||||||
|
typedef float _Complex GoComplex64;
|
||||||
|
typedef double _Complex GoComplex128;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
static assertion to make sure the file is being used on architecture
|
||||||
|
at least with matching size of GoInt.
|
||||||
|
*/
|
||||||
|
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
||||||
|
|
||||||
|
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||||
|
typedef _GoString_ GoString;
|
||||||
|
#endif
|
||||||
|
typedef void *GoMap;
|
||||||
|
typedef void *GoChan;
|
||||||
|
typedef struct { void *t; void *v; } GoInterface;
|
||||||
|
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* End of boilerplate cgo prologue. */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//goland:noinspection ALL
|
||||||
|
extern Tunnel PrepareTunnel(RecvCallback onRecv, void* next, char* configJson, int configJsonLen, char* networkConfigJson, int networkConfigJsonLen);
|
||||||
|
extern int WriteTunnel(size_t tunIdx, char* data, size_t num);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -648,7 +648,7 @@ engine.validator.fullNodeMaster port:int adnl:int256 = engine.validator.FullNode
|
||||||
engine.validator.fullNodeSlave ip:int port:int adnl:PublicKey = engine.validator.FullNodeSlave;
|
engine.validator.fullNodeSlave ip:int port:int adnl:PublicKey = engine.validator.FullNodeSlave;
|
||||||
engine.validator.fullNodeConfig ext_messages_broadcast_disabled:Bool = engine.validator.FullNodeConfig;
|
engine.validator.fullNodeConfig ext_messages_broadcast_disabled:Bool = engine.validator.FullNodeConfig;
|
||||||
engine.validator.extraConfig state_serializer_enabled:Bool = engine.validator.ExtraConfig;
|
engine.validator.extraConfig state_serializer_enabled:Bool = engine.validator.ExtraConfig;
|
||||||
engine.validator.config out_port:int addrs:(vector engine.Addr) adnl:(vector engine.adnl)
|
engine.validator.config out_port:int tunnel_enabled:int addrs:(vector engine.Addr) adnl:(vector engine.adnl)
|
||||||
dht:(vector engine.dht)
|
dht:(vector engine.dht)
|
||||||
validators:(vector engine.validator) fullnode:int256 fullnodeslaves:(vector engine.validator.fullNodeSlave)
|
validators:(vector engine.validator) fullnode:int256 fullnodeslaves:(vector engine.validator.fullNodeSlave)
|
||||||
fullnodemasters:(vector engine.validator.fullNodeMaster)
|
fullnodemasters:(vector engine.validator.fullNodeMaster)
|
||||||
|
|
Binary file not shown.
|
@ -88,6 +88,7 @@ Config::Config() {
|
||||||
Config::Config(const ton::ton_api::engine_validator_config &config) {
|
Config::Config(const ton::ton_api::engine_validator_config &config) {
|
||||||
full_node = ton::PublicKeyHash::zero();
|
full_node = ton::PublicKeyHash::zero();
|
||||||
out_port = static_cast<td::uint16>(config.out_port_);
|
out_port = static_cast<td::uint16>(config.out_port_);
|
||||||
|
tunnel_enabled = true; //static_cast<td::uint8>(config.tunnel_enabled_);
|
||||||
if (!out_port) {
|
if (!out_port) {
|
||||||
out_port = 3278;
|
out_port = 3278;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +279,7 @@ ton::tl_object_ptr<ton::ton_api::engine_validator_config> Config::tl() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ton::create_tl_object<ton::ton_api::engine_validator_config>(
|
return ton::create_tl_object<ton::ton_api::engine_validator_config>(
|
||||||
out_port, std::move(addrs_vec), std::move(adnl_vec), std::move(dht_vec), std::move(val_vec),
|
out_port, 0, std::move(addrs_vec), std::move(adnl_vec), std::move(dht_vec), std::move(val_vec),
|
||||||
full_node.tl(), std::move(full_node_slaves_vec), std::move(full_node_masters_vec),
|
full_node.tl(), std::move(full_node_slaves_vec), std::move(full_node_masters_vec),
|
||||||
std::move(full_node_config_obj), std::move(extra_config_obj), std::move(liteserver_vec), std::move(control_vec),
|
std::move(full_node_config_obj), std::move(extra_config_obj), std::move(liteserver_vec), std::move(control_vec),
|
||||||
std::move(shards_vec), std::move(gc_vec));
|
std::move(shards_vec), std::move(gc_vec));
|
||||||
|
@ -1848,6 +1849,39 @@ void ValidatorEngine::start_adnl() {
|
||||||
adnl_ = ton::adnl::Adnl::create(db_root_, keyring_.get());
|
adnl_ = ton::adnl::Adnl::create(db_root_, keyring_.get());
|
||||||
td::actor::send_closure(adnl_, &ton::adnl::Adnl::register_network_manager, adnl_network_manager_.get());
|
td::actor::send_closure(adnl_, &ton::adnl::Adnl::register_network_manager, adnl_network_manager_.get());
|
||||||
|
|
||||||
|
if (config_.tunnel_enabled) {
|
||||||
|
auto on_tunnel_ready = td::PromiseCreator::lambda([SelfId = actor_id(this), this, ip](td::Result<td::IPAddress> R) {
|
||||||
|
R.ensure();
|
||||||
|
auto addr = R.move_as_ok();
|
||||||
|
|
||||||
|
LOG(INFO) << "Tunnel ready, addr: " << addr;
|
||||||
|
|
||||||
|
add_addr(Config::Addr{}, Config::AddrCats{
|
||||||
|
.in_addr = addr,
|
||||||
|
.is_tunnel = true,
|
||||||
|
.cats = {0, 1, 2, 3},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto &adnl : config_.adnl_ids) {
|
||||||
|
add_adnl(adnl.first, adnl.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
td::actor::send_closure(adnl_, &ton::adnl::Adnl::add_static_nodes_from_config, std::move(adnl_static_nodes_));
|
||||||
|
td::actor::send_closure(SelfId, &ValidatorEngine::started_adnl);
|
||||||
|
});
|
||||||
|
|
||||||
|
ton::adnl::AdnlCategoryMask cat_mask;
|
||||||
|
cat_mask[0] = true;
|
||||||
|
cat_mask[1] = true;
|
||||||
|
cat_mask[2] = true;
|
||||||
|
cat_mask[3] = true;
|
||||||
|
|
||||||
|
td::actor::send_closure(adnl_network_manager_, &ton::adnl::AdnlNetworkManager::add_tunnel, 3433,
|
||||||
|
std::move(cat_mask), 0, std::move(on_tunnel_ready));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &addr : config_.addrs) {
|
for (auto &addr : config_.addrs) {
|
||||||
add_addr(addr.first, addr.second);
|
add_addr(addr.first, addr.second);
|
||||||
}
|
}
|
||||||
|
@ -1867,6 +1901,8 @@ void ValidatorEngine::add_addr(const Config::Addr &addr, const Config::AddrCats
|
||||||
for (auto cat : cats.priority_cats) {
|
for (auto cat : cats.priority_cats) {
|
||||||
cat_mask[cat] = true;
|
cat_mask[cat] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cats.is_tunnel) {
|
||||||
if (!cats.proxy) {
|
if (!cats.proxy) {
|
||||||
td::actor::send_closure(adnl_network_manager_, &ton::adnl::AdnlNetworkManager::add_self_addr, addr.addr,
|
td::actor::send_closure(adnl_network_manager_, &ton::adnl::AdnlNetworkManager::add_self_addr, addr.addr,
|
||||||
std::move(cat_mask), cats.cats.size() ? 0 : 1);
|
std::move(cat_mask), cats.cats.size() ? 0 : 1);
|
||||||
|
@ -1875,6 +1911,7 @@ void ValidatorEngine::add_addr(const Config::Addr &addr, const Config::AddrCats
|
||||||
static_cast<td::uint16>(addr.addr.get_port()), cats.proxy, std::move(cat_mask),
|
static_cast<td::uint16>(addr.addr.get_port()), cats.proxy, std::move(cat_mask),
|
||||||
cats.cats.size() ? 0 : 1);
|
cats.cats.size() ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td::uint32 ts = static_cast<td::uint32>(td::Clocks::system());
|
td::uint32 ts = static_cast<td::uint32>(td::Clocks::system());
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct Config {
|
||||||
};
|
};
|
||||||
struct AddrCats {
|
struct AddrCats {
|
||||||
td::IPAddress in_addr;
|
td::IPAddress in_addr;
|
||||||
|
bool is_tunnel;
|
||||||
std::shared_ptr<ton::adnl::AdnlProxy> proxy;
|
std::shared_ptr<ton::adnl::AdnlProxy> proxy;
|
||||||
std::set<AdnlCategory> cats;
|
std::set<AdnlCategory> cats;
|
||||||
std::set<AdnlCategory> priority_cats;
|
std::set<AdnlCategory> priority_cats;
|
||||||
|
@ -78,6 +79,7 @@ struct Config {
|
||||||
|
|
||||||
std::map<ton::PublicKeyHash, td::uint32> keys_refcnt;
|
std::map<ton::PublicKeyHash, td::uint32> keys_refcnt;
|
||||||
td::uint16 out_port;
|
td::uint16 out_port;
|
||||||
|
bool tunnel_enabled;
|
||||||
std::map<Addr, AddrCats> addrs;
|
std::map<Addr, AddrCats> addrs;
|
||||||
std::map<ton::PublicKeyHash, AdnlCategory> adnl_ids;
|
std::map<ton::PublicKeyHash, AdnlCategory> adnl_ids;
|
||||||
std::set<ton::PublicKeyHash> dht_ids;
|
std::set<ton::PublicKeyHash> dht_ids;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue