Skip to content

Commit 1367cd7

Browse files
authored
Merge pull request #1 from basiliscos/0.2.0-dev
0.2.0-dev
2 parents d048a9c + cc0a692 commit 1367cd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3994
-521
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ find_package(OpenSSL REQUIRED)
2424
find_package(Protobuf REQUIRED)
2525
find_package(ZLIB REQUIRED)
2626

27-
set(SYNCSPIRIT_VERSION "v0.1.0")
27+
set(SYNCSPIRIT_VERSION "v0.2.0")
2828

2929
configure_file(misc/syncspirit-config.h.in include/syncspirit-config.h @ONLY)
3030
set(Protobuf_IMPORT_DIRS ${syncspirit_SOURCE_DIR}/src)
@@ -97,6 +97,7 @@ add_library(syncspirit_lib
9797
src/model/diff/modify/local_update.cpp
9898
src/model/diff/modify/lock_file.cpp
9999
src/model/diff/modify/new_file.cpp
100+
src/model/diff/modify/relay_connect_request.cpp
100101
src/model/diff/modify/share_folder.cpp
101102
src/model/diff/modify/update_contact.cpp
102103
src/model/diff/modify/update_peer.cpp
@@ -128,18 +129,21 @@ add_library(syncspirit_lib
128129
src/net/dialer_actor.cpp
129130
src/net/global_discovery_actor.cpp
130131
src/net/http_actor.cpp
132+
src/net/initiator_actor.cpp
131133
src/net/local_discovery_actor.cpp
132134
src/net/messages.cpp
133135
src/net/net_supervisor.cpp
134136
src/net/peer_actor.cpp
135137
src/net/peer_supervisor.cpp
138+
src/net/relay_actor.cpp
136139
src/net/resolver_actor.cpp
137140
src/net/names.cpp
138141
src/net/ssdp_actor.cpp
139142
src/net/upnp_actor.cpp
140143
src/proto/bep_support.cpp
141144
src/proto/discovery_support.cpp
142145
src/proto/luhn32.cpp
146+
src/proto/relay_support.cpp
143147
src/proto/upnp_support.cpp
144148
src/transport/stream.cpp
145149
src/transport/http.cpp
@@ -164,6 +168,8 @@ set(BUILD_SHARED_LIBS false CACHE BOOL "BUILD_SHARED_LIBS")
164168
set(LZ4_BUILD_CLI false CACHE BOOL "LZ4_BUILD_CLI")
165169
set(LZ4_BUILD_LEGACY_LZ4C false CACHE BOOL "LZ4_BUILD_LEGACY_LZ4C")
166170
set(MDBX_BUILD_TOOLS false CACHE BOOL "MDBX_BUILD_TOOLS")
171+
set(MDBX_ENABLE_TESTS false CACHE BOOL "MDBX_ENABLE_TESTS")
172+
set(MDBX_BUILD_CXX false CACHE BOOL "MDBX_BUILD_CXX")
167173

168174
cmake_policy(SET CMP0077 NEW)
169175
set(PUGIXML_NO_EXCEPTIONS on)

README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
# syncspirit
22

3-
sites: [github](https://github.com/basiliscos/syncspirit), [abf](https://github.com/basiliscos/syncspirit)
3+
sites: [github](https://github.com/basiliscos/syncspirit), [abf](https://github.com/basiliscos/syncspirit),
4+
[gitflic](https://gitflic.ru/project/basiliscos/syncspirit)
45

56
`syncspirit` is a continuous file synchronization program, which synchronizes files between devices.
67
It is build using C++ [rotor](github.com/basiliscos/cpp-rotor) actor framework. It implements
78
[BEP-protocol](https://docs.syncthing.net/specs/bep-v1.html) for files syncrhonization, or,
89
simplistically speaking, it is [syncthing](https://syncthing.net)-compatible syncrhonization
9-
program.
10+
program, which uses [syncthing](https://syncthing.net) infrastructure (for global discovery
11+
and relaying)
1012

1113
Despite of being functional `syncspirit` is much less feature-rich then [syncthing](https://syncthing.net)
1214
and still is in heavy development.
1315

1416

1517
# status
1618

17-
[x] downloading files from peer devices (aka all folders are receive only)
19+
- [x] downloading files from peer devices (aka all folders are receive only)
1820

19-
[x] [global peer discovery](https://docs.syncthing.net/specs/globaldisco-v3.html)
21+
- [x] [global peer discovery](https://docs.syncthing.net/specs/globaldisco-v3.html)
2022

21-
[x] [local (LAN) peer discovery](https://docs.syncthing.net/specs/localdisco-v4.html)
23+
- [x] [local (LAN) peer discovery](https://docs.syncthing.net/specs/localdisco-v4.html)
2224

23-
[x] upnp & nat passthough
25+
- [x] upnp & nat passthough
2426

25-
[x] certificates generation
27+
- [x] certificates generation
2628

29+
- [x] relay transport
2730

2831
# missing features
2932

3033
This list is probably incomplete, here are the most important changes
3134

32-
[ ] relay transport
35+
- [ ] full-powered files synchronization (aka send and receive)
3336

34-
[ ] full-powered files synchronization (aka send and receive)
37+
- [ ] conflict resolution
3538

36-
[ ] conflict resolution
39+
- [ ] ignoring files
3740

38-
[ ] ingoring files
41+
- [ ] [QUIC transport](https://en.wikipedia.org/wiki/QUIC)
3942

40-
[ ] [QUIC transport](https://en.wikipedia.org/wiki/QUIC)
43+
- [ ] introducer support
4144

42-
[ ] introducer support
45+
- [ ] outgoing messages compression
4346

44-
[ ] outgoing messages compression
47+
- [ ] [untrusted devices encryption](https://docs.syncthing.net/specs/untrusted.html)
4548

46-
[ ] [untrusted devices encryption](https://docs.syncthing.net/specs/untrusted.html)
47-
48-
[ ] ...
49+
- [ ] ...
4950

5051
# run
5152

@@ -63,7 +64,7 @@ the output should be like
6364
[![asciicast](https://asciinema.org/a/474217.svg)](https://asciinema.org/a/474217)
6465

6566
i.e. it records some peer, adds a folder, then shares the folder with the peer device, connects to
66-
the peer and downloads all files into `/tmp/my_dir/data` . The peer device Currently can be
67+
the peer and downloads all files into `/tmp/my_dir/data` . The peer device currently can be
6768
only [syncthing](https://syncthing.net). Then `syncspirit` either exits after 2 minutes of inactivity
6869
or when you press `ctrl+c`. The output is successful, because I previousy authorized this device
6970
with [syncthing](https://syncthing.net) web interface, and shared the folder with this device
@@ -92,7 +93,7 @@ classical desktop and client-server application models. I think,
9293
"core" into multiple different user interfaces (GUIs).
9394

9495
Currently, there syncspirit has only "daemon-ui", i.e. a simple non-interactive application,
95-
which shows synchronization log, and the only possible just stop it. However, as soon
96+
which shows synchronization log, and the only possibility is just to stop it. However, as soon
9697
as the "core" will be complete, there are plans to develop multiple `syncspirit` UIs:
9798
[wx-widgets](https://www.wxwidgets.org/), qt, gtk, may be native, may be even native mobile UIs...
9899

@@ -117,6 +118,14 @@ after the core completion.
117118

118119
# changes
119120

121+
## 0.2.0 (22-May-2022)
122+
- [feature] implement [relay transport](https://docs.syncthing.net/specs/relay-v1.html),
123+
the relay is randombly chosen from the public relays [pool](https://relays.syncthing.net/endpoint)
124+
- [feature] output binary is compressed via [upx](https://upx.github.io)
125+
- [feature] small optimization, use thread less in overall program
126+
- [bugfix] sometimes fs::scan_actor request timeout ocurrs, which is fatal
127+
- [bugfix] global discovery sometimes skipped announcements
128+
120129
## 0.1.0 (18-Arp-2022)
121130
- initial release
122131

docs/config.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ timeout = 5000
7070
# the amount of hasher threads
7171
hasher_threads = 3
7272

73+
[relay]
74+
enabled = true
75+
# where pick the list of relay servers pool
76+
discovery_url = 'https://relays.syncthing.net/endpoint'
77+
rx_buff_size = 1048576
78+
7379
[upnp]
7480
enabled = true
7581
# do output of upnp requests

misc/ubuntu14.04.toolchain

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(TOOLCHAIN_HOME "/home/b/x-tools/x86_64-ubuntu14.04-linux-gnu")
2+
set(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/x86_64-ubuntu14.04-linux-gnu-gcc)
3+
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/x86_64-ubuntu14.04-linux-gnu-g++)
4+
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
5+
set(CMAKE_FIND_ROOT_PATH
6+
${TOOLCHAIN_HOME}/x86_64-ubuntu14.04-linux-gnu/sysroot/
7+
/home/b/development/cpp/syncspirit-cross/sysroot
8+
)

src/config/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "global_announce.h"
1212
#include "local_announce.h"
1313
#include "log.h"
14+
#include "relay.h"
1415
#include "upnp.h"
1516
#include <boost/filesystem.hpp>
1617

@@ -31,6 +32,7 @@ struct main_t {
3132
dialer_config_t dialer_config;
3233
fs_config_t fs_config;
3334
db_config_t db_config;
35+
relay_config_t relay_config;
3436

3537
std::uint32_t timeout;
3638
std::string device_name;

src/config/relay.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
// SPDX-FileCopyrightText: 2022 Ivan Baidakou
3+
4+
#pragma once
5+
6+
#include <string>
7+
8+
namespace syncspirit::config {
9+
10+
struct relay_config_t {
11+
bool enabled;
12+
std::string discovery_url;
13+
std::uint32_t rx_buff_size;
14+
};
15+
16+
} // namespace syncspirit::config

src/config/utils.cpp

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,6 @@ static const std::string home_path = "~/.config/syncspirit";
2222

2323
namespace syncspirit::config {
2424

25-
bool operator==(const bep_config_t &lhs, const bep_config_t &rhs) noexcept {
26-
return lhs.rx_buff_size == rhs.rx_buff_size && lhs.connect_timeout == rhs.connect_timeout &&
27-
lhs.request_timeout == rhs.request_timeout && lhs.tx_timeout == rhs.tx_timeout &&
28-
lhs.rx_timeout == rhs.rx_timeout && lhs.blocks_max_requested == rhs.blocks_max_requested;
29-
}
30-
31-
bool operator==(const dialer_config_t &lhs, const dialer_config_t &rhs) noexcept {
32-
return lhs.enabled == rhs.enabled && lhs.redial_timeout == rhs.redial_timeout;
33-
}
34-
35-
bool operator==(const fs_config_t &lhs, const fs_config_t &rhs) noexcept {
36-
return lhs.temporally_timeout == rhs.temporally_timeout && lhs.mru_size == rhs.mru_size;
37-
}
38-
39-
bool operator==(const db_config_t &lhs, const db_config_t &rhs) noexcept {
40-
return lhs.upper_limit == rhs.upper_limit && lhs.uncommited_threshold == rhs.uncommited_threshold;
41-
}
42-
43-
bool operator==(const global_announce_config_t &lhs, const global_announce_config_t &rhs) noexcept {
44-
return lhs.enabled == rhs.enabled && lhs.announce_url == rhs.announce_url && lhs.device_id == rhs.device_id &&
45-
lhs.cert_file == rhs.cert_file && lhs.key_file == rhs.key_file && lhs.rx_buff_size == rhs.rx_buff_size &&
46-
lhs.timeout == rhs.timeout && lhs.reannounce_after == rhs.reannounce_after;
47-
}
48-
49-
bool operator==(const local_announce_config_t &lhs, const local_announce_config_t &rhs) noexcept {
50-
return lhs.enabled == rhs.enabled && lhs.port == rhs.port && lhs.frequency == rhs.frequency;
51-
}
52-
53-
bool operator==(const log_config_t &lhs, const log_config_t &rhs) noexcept {
54-
return lhs.name == rhs.name && lhs.level == rhs.level && lhs.sinks == rhs.sinks;
55-
}
56-
57-
bool operator==(const main_t &lhs, const main_t &rhs) noexcept {
58-
return lhs.local_announce_config == rhs.local_announce_config && lhs.upnp_config == rhs.upnp_config &&
59-
lhs.global_announce_config == rhs.global_announce_config && lhs.bep_config == rhs.bep_config &&
60-
lhs.db_config == rhs.db_config && lhs.timeout == rhs.timeout && lhs.device_name == rhs.device_name &&
61-
lhs.config_path == rhs.config_path && lhs.log_configs == rhs.log_configs &&
62-
lhs.hasher_threads == rhs.hasher_threads;
63-
}
64-
65-
bool operator==(const upnp_config_t &lhs, const upnp_config_t &rhs) noexcept {
66-
return lhs.enabled == rhs.enabled && lhs.max_wait == rhs.max_wait && lhs.external_port == rhs.external_port &&
67-
lhs.rx_buff_size == rhs.rx_buff_size && lhs.debug == rhs.debug;
68-
}
69-
7025
using device_name_t = outcome::result<std::string>;
7126

7227
static std::string expand_home(const std::string &path, const char *home) {
@@ -282,6 +237,30 @@ config_result_t get_config(std::istream &config, const boost::filesystem::path &
282237
c.debug = debug.value();
283238
};
284239

240+
// relay
241+
{
242+
auto t = root_tbl["relay"];
243+
auto &c = cfg.relay_config;
244+
245+
auto enabled = t["enabled"].value<bool>();
246+
if (!enabled) {
247+
return "relay/enabled is incorrect or missing";
248+
}
249+
c.enabled = enabled.value();
250+
251+
auto discovery_url = t["discovery_url"].value<std::string>();
252+
if (!discovery_url) {
253+
return "upnp/discovery_url is incorrect or missing";
254+
}
255+
c.discovery_url = discovery_url.value();
256+
257+
auto rx_buff_size = t["rx_buff_size"].value<std::uint32_t>();
258+
if (!rx_buff_size) {
259+
return "relay/rx_buff_size is incorrect or missing";
260+
}
261+
c.rx_buff_size = rx_buff_size.value();
262+
};
263+
285264
// bep
286265
{
287266
auto t = root_tbl["bep"];
@@ -467,6 +446,11 @@ outcome::result<void> serialize(const main_t cfg, std::ostream &out) noexcept {
467446
{"upper_limit", cfg.db_config.upper_limit},
468447
{"uncommited_threshold", cfg.db_config.uncommited_threshold},
469448
}}},
449+
{"relay", toml::table{{
450+
{"enabled", cfg.relay_config.enabled},
451+
{"discovery_url", cfg.relay_config.discovery_url},
452+
{"rx_buff_size", cfg.relay_config.rx_buff_size},
453+
}}},
470454
}};
471455
// clang-format on
472456
out << tbl;
@@ -559,8 +543,12 @@ outcome::result<main_t> generate_config(const boost::filesystem::path &config_pa
559543
0x400000000, /* upper_limit, 16Gb */
560544
150, /* uncommited_threshold */
561545
};
546+
cfg.relay_config = relay_config_t {
547+
true, /* enabled */
548+
"https://relays.syncthing.net/endpoint", /* discovery url */
549+
1024 * 1024, /* rx buff size */
550+
};
562551
return cfg;
563552
}
564553

565-
566554
}

src/config/utils.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ namespace outcome = boost::outcome_v2;
1313

1414
// comparators
1515

16-
SYNCSPIRIT_API bool operator==(const bep_config_t &lhs, const bep_config_t &rhs) noexcept;
17-
SYNCSPIRIT_API bool operator==(const dialer_config_t &lhs, const dialer_config_t &rhs) noexcept;
18-
SYNCSPIRIT_API bool operator==(const fs_config_t &lhs, const fs_config_t &rhs) noexcept;
19-
SYNCSPIRIT_API bool operator==(const db_config_t &lhs, const db_config_t &rhs) noexcept;
20-
SYNCSPIRIT_API bool operator==(const global_announce_config_t &lhs, const global_announce_config_t &rhs) noexcept;
21-
SYNCSPIRIT_API bool operator==(const local_announce_config_t &lhs, const local_announce_config_t &rhs) noexcept;
22-
SYNCSPIRIT_API bool operator==(const main_t &lhs, const main_t &rhs) noexcept;
23-
SYNCSPIRIT_API bool operator==(const upnp_config_t &lhs, const upnp_config_t &rhs) noexcept;
24-
25-
// misc
26-
2716
using config_result_t = outcome::outcome<main_t, std::string>;
2817

2918
SYNCSPIRIT_API config_result_t get_config(std::istream &config, const boost::filesystem::path &config_path);

src/constants.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ namespace syncspirit::constants {
77
const char *client_name = "syncspirit";
88
const char *issuer_name = "syncthing";
99
const char *protocol_name = "bep/1.0";
10+
const char *relay_protocol_name = "bep-relay";
1011
const char *client_version = "v0.01";
1112
} // namespace syncspirit::constants

0 commit comments

Comments
 (0)