@@ -22,51 +22,6 @@ static const std::string home_path = "~/.config/syncspirit";
2222
2323namespace 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-
7025using device_name_t = outcome::result<std::string>;
7126
7227static 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}
0 commit comments