mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
CMake flag define for adnl tunnel
This commit is contained in:
parent
a4c73c10b9
commit
0c5eff2a98
3 changed files with 20 additions and 7 deletions
|
@ -115,6 +115,7 @@ if (TON_USE_GO_TUNNEL)
|
||||||
add_library(tunnel STATIC IMPORTED)
|
add_library(tunnel STATIC IMPORTED)
|
||||||
set_target_properties(tunnel PROPERTIES IMPORTED_LOCATION "${TUNNEL_GO_LIB_PATH}")
|
set_target_properties(tunnel PROPERTIES IMPORTED_LOCATION "${TUNNEL_GO_LIB_PATH}")
|
||||||
set(TUNNEL_LIB_IF_USED "tunnel")
|
set(TUNNEL_LIB_IF_USED "tunnel")
|
||||||
|
add_compile_definitions(TON_USE_GO_TUNNEL)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Missing ADNL Tunnel library (Go), but enabled: ${TUNNEL_GO_LIB_PATH}")
|
message(FATAL_ERROR "Missing ADNL Tunnel library (Go), but enabled: ${TUNNEL_GO_LIB_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
16
README.md
16
README.md
|
@ -152,16 +152,18 @@ Tests are executed by running `ctest` in the build directory. See `doc/Tests.md`
|
||||||
|
|
||||||
## Using ADNL tunnel
|
## Using ADNL tunnel
|
||||||
|
|
||||||
### Before node compilation
|
### At node compilation
|
||||||
1. Clone https://github.com/ton-blockchain/adnl-tunnel and install golang 1.23 or newer
|
1. Clone https://github.com/ton-blockchain/adnl-tunnel and install golang 1.23.3 or newer
|
||||||
* `cd adnl-tunnel`
|
* `cd adnl-tunnel`
|
||||||
* `make library`
|
* `make library`
|
||||||
* It will build `libtunnel.a`
|
* It will build `libtunnel.a`
|
||||||
2. Copy `libtunnel.a` to ton src directory root (usually `/usr/src/ton`)
|
2. Copy `libtunnel.a` to ton src directory root (usually `/usr/src/ton`).
|
||||||
3. On the first step of ton node compilation run cmake with option `-DTON_USE_GO_TUNNEL=ON` to enable tunnel.
|
3. On the first step of ton node compilation run cmake with option `-DTON_USE_GO_TUNNEL=ON` to enable tunnel.
|
||||||
4. Build ton node as usual.
|
4. Build ton node as usual.
|
||||||
|
|
||||||
### Before startup
|
### At node startup
|
||||||
1. Create `tunnel-config.json` in any place.
|
1. Run validator-engine with `--tunnel-config /path/to/tunnel-config.json` startup argument.
|
||||||
2. Fill it with desired tunnel configuration and wallet keys. See example.
|
2. It will create example tunnel config file at specified path (`/path/to/tunnel-config.json`).
|
||||||
3Add `--tunnel-config /path/to/tunnel-config.json` argument to validator-engine startup command.
|
3. Fill it with desired tunnel configuration, enable payments and top up wallet address if needed.
|
||||||
|
4. Run validator-engine `--tunnel-config /path/to/tunnel-config.json` again, and follow instructions in console if any.
|
||||||
|
5. When setup is completed and node started, you can stop it and run in daemon mode as usual.
|
|
@ -20,7 +20,9 @@
|
||||||
#include "td/net/FdListener.h"
|
#include "td/net/FdListener.h"
|
||||||
#include "td/net/TcpListener.h"
|
#include "td/net/TcpListener.h"
|
||||||
|
|
||||||
|
#ifdef TON_USE_GO_TUNNEL
|
||||||
#include "td/net/tunnel/libtunnel.h"
|
#include "td/net/tunnel/libtunnel.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "td/utils/BufferedFd.h"
|
#include "td/utils/BufferedFd.h"
|
||||||
#include "td/utils/filesystem.h"
|
#include "td/utils/filesystem.h"
|
||||||
|
@ -90,8 +92,10 @@ void UdpServerTunnelImpl::send(td::UdpMessage &&message) {
|
||||||
|
|
||||||
|
|
||||||
if (out_buf_msg_num_ == TUNNEL_BUFFER_SZ_PACKETS) {
|
if (out_buf_msg_num_ == TUNNEL_BUFFER_SZ_PACKETS) {
|
||||||
|
#ifdef TON_USE_GO_TUNNEL
|
||||||
WriteTunnel(tunnel_index_, out_buf_, out_buf_msg_num_);
|
WriteTunnel(tunnel_index_, out_buf_, out_buf_msg_num_);
|
||||||
LOG(DEBUG) << "Sending messages by fulfillment " << TUNNEL_BUFFER_SZ_PACKETS;
|
LOG(DEBUG) << "Sending messages by fulfillment " << TUNNEL_BUFFER_SZ_PACKETS;
|
||||||
|
#endif
|
||||||
|
|
||||||
out_buf_offset_ = 0;
|
out_buf_offset_ = 0;
|
||||||
out_buf_msg_num_ = 0;
|
out_buf_msg_num_ = 0;
|
||||||
|
@ -101,8 +105,10 @@ void UdpServerTunnelImpl::send(td::UdpMessage &&message) {
|
||||||
|
|
||||||
void UdpServerTunnelImpl::alarm() {
|
void UdpServerTunnelImpl::alarm() {
|
||||||
if (out_buf_msg_num_ > 0 && Time::now()-last_batch_at_ >= TUNNEL_ALARM_EVERY) {
|
if (out_buf_msg_num_ > 0 && Time::now()-last_batch_at_ >= TUNNEL_ALARM_EVERY) {
|
||||||
|
#ifdef TON_USE_GO_TUNNEL
|
||||||
WriteTunnel(tunnel_index_, out_buf_, out_buf_msg_num_);
|
WriteTunnel(tunnel_index_, out_buf_, out_buf_msg_num_);
|
||||||
LOG(DEBUG) << "Sending messages by alarm " << out_buf_msg_num_;
|
LOG(DEBUG) << "Sending messages by alarm " << out_buf_msg_num_;
|
||||||
|
#endif
|
||||||
|
|
||||||
out_buf_offset_ = 0;
|
out_buf_offset_ = 0;
|
||||||
out_buf_msg_num_ = 0;
|
out_buf_msg_num_ = 0;
|
||||||
|
@ -113,6 +119,7 @@ void UdpServerTunnelImpl::alarm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServerTunnelImpl::start_up() {
|
void UdpServerTunnelImpl::start_up() {
|
||||||
|
#ifdef TON_USE_GO_TUNNEL
|
||||||
auto global_conf_data_R = td::read_file(global_config_);
|
auto global_conf_data_R = td::read_file(global_config_);
|
||||||
if (global_conf_data_R.is_error()) {
|
if (global_conf_data_R.is_error()) {
|
||||||
LOG(FATAL) << global_conf_data_R.move_as_error_prefix("failed to read global config: ");
|
LOG(FATAL) << global_conf_data_R.move_as_error_prefix("failed to read global config: ");
|
||||||
|
@ -135,6 +142,9 @@ void UdpServerTunnelImpl::start_up() {
|
||||||
on_ready_.set_value(std::move(ip));
|
on_ready_.set_value(std::move(ip));
|
||||||
|
|
||||||
alarm_timestamp() = td::Timestamp::in(TUNNEL_ALARM_EVERY);
|
alarm_timestamp() = td::Timestamp::in(TUNNEL_ALARM_EVERY);
|
||||||
|
#else
|
||||||
|
LOG(FATAL) << "Tunnel was not enabled during node building, rebuild with cmake flag -DTON_USE_GO_TUNNEL=ON";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServerTunnelImpl::on_recv_batch(void *next, uint8_t *data, size_t num) {
|
void UdpServerTunnelImpl::on_recv_batch(void *next, uint8_t *data, size_t num) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue