1use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6use syncthing_macros::New;
7
8#[derive(Serialize, Deserialize, Debug)]
9pub struct Size {
10 pub value: f64,
11 pub unit: String,
12}
13
14#[derive(Serialize, Deserialize, Debug)]
15#[serde(rename_all = "camelCase")]
16pub struct Configuration {
17 pub version: u64,
18 pub folders: Vec<FolderConfiguration>,
19 pub devices: Vec<DeviceConfiguration>,
20 pub gui: GuiConfiguration,
21 pub ldap: LDAPConfiguration,
22 pub remote_ignored_devices: Vec<ObservedDevice>,
23 pub defaults: Defaults,
24}
25
26#[derive(Serialize, Deserialize, Debug, New)]
27#[serde(rename_all = "camelCase")]
28pub struct FolderConfiguration {
29 #[required]
30 pub id: String,
31 pub label: String,
32 pub filesystem_type: FilesystemType,
33 #[required]
34 pub path: String,
35 #[serde(rename = "type")]
36 pub folder_type: FolderType,
37 pub devices: Vec<FolderDeviceConfiguration>,
38 pub rescan_interval_s: i64,
39 pub fs_watcher_enabled: bool,
40 pub fs_watcher_delay_s: f64,
41 pub fs_watcher_timeout_s: f64,
42 pub ignore_perms: bool,
43 pub auto_normalize: bool,
44 pub min_disk_free: Size,
45 pub versioning: VersioningConfiguration,
46 pub copiers: i64,
47 pub puller_max_pending_ki_b: i64,
48 pub hashers: i64,
49 pub order: PullOrder,
50 pub ignore_delete: bool,
51 pub scan_progress_interval_s: i64,
52 pub puller_pause_s: i64,
53 pub max_conflicts: i64,
54 pub disable_sparse_files: bool,
55 pub disable_temp_indexes: bool,
56 pub paused: bool,
57 pub weak_hash_threshold_pct: i64,
58 pub marker_name: String,
59 pub copy_ownership_from_parent: bool,
60 pub mod_time_window_s: i64,
61 pub max_concurrent_writes: i64,
62 pub disable_fsync: bool,
63 pub block_pull_order: BlockPullOrder,
64 pub copy_range_method: CopyRangeMethod,
65 #[serde(rename = "caseSensitiveFS")]
66 pub case_sensitive_fs: bool,
67 pub junctions_as_dirs: bool,
68 pub sync_ownership: bool,
69 pub send_ownership: bool,
70 pub sync_xattrs: bool,
71 pub send_xattrs: bool,
72 pub xattr_filter: XattrFilter,
73}
74
75#[derive(Serialize, Deserialize, Debug)]
76#[serde(rename_all = "lowercase")]
77pub enum FilesystemType {
78 Basic,
79 Fake,
80}
81
82#[derive(Serialize, Deserialize, Debug)]
83#[serde(rename_all = "lowercase")]
84pub enum FolderType {
85 SendReceive,
86 SendOnly,
87 ReceiveOnly,
88 ReceiveEncrypted,
89}
90
91#[derive(Serialize, Deserialize, Debug)]
92#[serde(rename_all = "camelCase")]
93pub struct FolderDeviceConfiguration {
94 #[serde(rename = "deviceID")]
95 pub device_id: String,
96 pub introduced_by: String,
97 pub encryption_password: String,
98}
99
100#[derive(Serialize, Deserialize, Debug)]
101#[serde(rename_all = "camelCase")]
102pub struct VersioningConfiguration {
103 #[serde(rename = "type")]
104 pub config_type: String,
105 pub params: HashMap<String, String>,
106 pub cleanup_interval_s: i64,
107 pub fs_path: String,
108 pub fs_type: FilesystemType,
109}
110
111#[derive(Serialize, Deserialize, Debug)]
112#[serde(rename_all = "camelCase")]
113pub enum PullOrder {
114 Random,
115 Alphabetic,
116 SmallestFirst,
117 LargestFirst,
118 OldestFirst,
119 NewestFirst,
120}
121
122#[derive(Serialize, Deserialize, Debug)]
123#[serde(rename_all = "camelCase")]
124pub enum BlockPullOrder {
125 Standard,
126 Random,
127 InOrder,
128}
129
130#[derive(Serialize, Deserialize, Debug)]
131#[serde(rename_all = "lowercase")]
132pub enum CopyRangeMethod {
133 Standard,
134 #[serde(rename = "copy_file_range")]
135 CopyFileRange,
136 Ioctl,
137 SendFile,
138 #[serde(rename = "duplicate_extents")]
139 DuplicateExtents,
140 All,
141}
142
143#[derive(Serialize, Deserialize, Debug)]
144#[serde(rename_all = "camelCase")]
145pub struct XattrFilter {
146 pub entries: Vec<String>,
147 pub max_single_entry_size: u64,
148 pub max_total_size: u64,
149}
150
151#[derive(Serialize, Deserialize, Debug, New)]
152#[serde(rename_all = "camelCase")]
153pub struct DeviceConfiguration {
154 #[required]
155 #[serde(rename = "deviceID")]
156 pub device_id: String,
157 pub name: String,
158 pub addresses: Vec<String>, pub compression: Compression,
162 pub cert_name: String,
163 pub introducer: bool,
164 pub skip_introduction_removals: bool,
165 pub introduced_by: String,
166 pub paused: bool,
167 pub allowed_networks: Vec<String>,
168 pub auto_accept_folders: bool,
169 pub max_send_kbps: i64,
170 pub max_recv_kbps: i64,
171 pub ignored_folders: Vec<ObservedFolder>,
172 pub max_request_ki_b: i64,
173 pub untrusted: bool,
174 #[serde(rename = "remoteGUIPort")]
175 pub remote_gui_port: i64,
176 pub num_connections: i64,
177}
178
179#[derive(Serialize, Deserialize, Debug)]
180#[serde(rename_all = "camelCase")]
181pub enum Compression {
182 Metadata,
183 Always,
184 Never,
185}
186
187#[derive(Serialize, Deserialize, Debug)]
188#[serde(rename_all = "camelCase")]
189pub struct ObservedFolder {
190 pub time: chrono::DateTime<chrono::Utc>,
191 pub id: String,
192 pub label: String,
193}
194
195#[derive(Serialize, Deserialize, Debug)]
196#[serde(rename_all = "camelCase")]
197pub struct GuiConfiguration {
198 pub enabled: bool,
199 pub address: String,
200 pub unix_socket_permissions: String,
201 pub user: String,
202 pub password: String,
203 pub auth_mode: AuthMode,
204 #[serde(rename = "useTLS")]
206 pub use_tls: bool,
207 pub api_key: String,
208 pub insecure_admin_access: bool,
209 pub theme: String,
210 pub debugging: bool,
211 pub insecure_skip_hostcheck: bool,
212 pub insecure_allow_frame_loading: bool,
213 pub send_basic_auth_prompt: bool,
214}
215
216#[derive(Serialize, Deserialize, Debug)]
217pub enum AuthMode {
218 #[serde(rename = "static")]
219 StaticAuth,
220 #[serde(rename = "ldap")]
221 LDAP,
222}
223
224#[derive(Serialize, Deserialize, Debug)]
225#[serde(rename_all = "camelCase")]
226pub struct LDAPConfiguration {
227 pub address: String,
228 #[serde(rename = "bindDN")]
229 pub bind_dn: String,
230 pub transport: LDAPTransport,
231 pub insecure_skip_verify: bool,
232 #[serde(rename = "searchBaseDN")]
233 pub search_base_dn: String,
234 pub search_filter: String,
235}
236
237#[derive(Serialize, Deserialize, Debug)]
238#[serde(rename_all = "lowercase")]
239pub enum LDAPTransport {
240 Plain,
241 NonTLS,
242 TLS,
243 StartTLS,
244}
245
246#[derive(Serialize, Deserialize, Debug)]
247#[serde(rename_all = "camelCase")]
248pub struct OptionsConfiguration {
249 pub listen_address: Vec<String>,
250 pub global_announce_servers: Vec<String>,
251 pub global_annouce_enabled: bool,
252 pub local_announce_enabled: bool,
253 pub local_announce_port: i64,
254 #[serde(rename = "localAnnounceMCAddr")]
255 pub local_announce_mc_addr: String,
256 pub max_send_kbps: i64,
257 pub max_recv_kbps: i64,
258 pub reconnection_interval_s: i64,
259 pub relays_enabled: bool,
260 pub relay_reconnect_interval_m: i64,
261 pub start_browser: bool,
262 pub nat_enabled: bool,
263 pub nat_lease_minutes: i64,
264 pub nat_renewal_minutes: i64,
265 pub nat_timeout_seconds: i64,
266 pub ur_accepted: i64,
267 pub ur_screen: i64,
268 pub ur_unique_id: String,
269 #[serde(rename = "urURL")]
270 pub ur_url: String,
271 pub ur_post_insecurely: bool,
272 pub ur_initial_dleay_s: i64,
273 pub auto_upgraade_interval_h: i64,
274 pub upgrade_to_pre_releases: bool,
275 pub keep_temporaries_h: i64,
276 pub cache_ignored_files: bool,
277 pub progress_update_inteval_s: i64,
278 pub limit_bandwidth_in_lan: bool,
279 pub min_home_disk_free: Size,
280 #[serde(rename = "releasesURL")]
281 pub releases_url: String,
282 pub always_local_nets: Vec<String>,
283 pub overwrite_remote_device_names_on_connect: bool,
284 pub temp_index_min_blocks: i64,
285 #[serde(rename = "unackedNotificationIDs")]
286 pub unacked_notifications_ids: Vec<String>,
287 pub traffic_class: i64,
288 pub set_low_priority: bool,
289 pub max_folder_concurrency: i64,
290 #[serde(rename = "crURL")]
291 pub cr_url: String,
292 pub crash_reporting_enabled: bool,
293 pub stun_keepalive_start_s: i64,
294 pub stun_keepalive_min_s: i64,
295 pub stun_servers: Vec<String>,
296 pub database_tuning: Tuning,
297 pub max_concurrent_incoming_requests_ki_b: i64,
298 #[serde(rename = "announceLANAddresses")]
299 pub announce_lan_addresses: bool,
300 pub send_full_index_on_upgrade: bool,
301 pub feature_flags: Vec<String>,
302 pub audit_enabled: bool,
303 pub audit_file: String,
304 pub connection_limit_enough: i64,
305 pub connection_limit_max: i64,
306 pub connection_priority_tcp_lan: i64,
307 pub connection_priority_quic_lan: i64,
308 pub connection_priority_tcp_wan: i64,
309 pub connection_priority_quic_wan: i64,
310 pub connection_priority_relay: i64,
311 pub connection_priority_upgrade_threshold: i64,
312}
313
314#[derive(Serialize, Deserialize, Debug)]
315#[serde(rename_all = "camelCase")]
316pub enum Tuning {
317 Small,
318 Large,
319 Auto,
320}
321
322#[derive(Serialize, Deserialize, Debug)]
323#[serde(rename_all = "camelCase")]
324pub struct ObservedDevice {
325 pub time: chrono::DateTime<chrono::Utc>,
326 #[serde(rename = "deviceID")]
327 pub device_id: String,
328 pub name: String,
329 pub address: String,
330}
331
332#[derive(Serialize, Deserialize, Debug)]
333#[serde(rename_all = "camelCase")]
334pub struct Defaults {
335 pub folder: FolderConfiguration,
336 pub device: DeviceConfiguration,
337 pub ignores: Ignores,
338}
339
340#[derive(Serialize, Deserialize, Debug)]
341#[serde(rename_all = "camelCase")]
342pub struct Ignores {
343 pub lines: Vec<String>,
344}