1use serde::{self, Deserialize, Serialize};
2use serde_repr::*;
3use std::collections::HashMap;
4use super::preferences_serialize;
5
6#[derive(Debug, Clone, Deserialize)]
8pub struct BuildInfoResponse {
9 pub qt: String,
10 pub libtorrent: String,
11 pub boost: String,
12 pub openssl: String,
13 pub bitness: u32,
14}
15
16#[serde_with::skip_serializing_none]
18#[derive(Debug, Clone, Default, Deserialize, Serialize)]
19pub struct Preferences {
20 pub locale: Option<String>,
21 pub start_paused_enabled: Option<bool>,
23 pub auto_delete_mode: Option<i64>,
24 pub preallocate_all: Option<bool>,
25 pub incomplete_files_ext: Option<bool>,
26 pub auto_tmm_enabled: Option<bool>,
27 pub torrent_changed_tmm_enabled: Option<bool>,
28 pub save_path_changed_tmm_enabled: Option<bool>,
29 pub category_changed_tmm_enabled: Option<bool>,
30 pub save_path: Option<String>,
31 pub temp_path_enabled: Option<bool>,
32 pub temp_path: Option<String>,
33 pub scan_dirs: Option<HashMap<String, i64>>,
34 pub export_dir: Option<String>,
35 pub export_dir_fin: Option<String>,
36 pub mail_notification_enabled: Option<bool>,
37 pub mail_notification_sender: Option<String>,
38 pub mail_notification_email: Option<String>,
39 pub mail_notification_smtp: Option<String>,
40 pub mail_notification_ssl_enabled: Option<bool>,
41 pub mail_notification_auth_enabled: Option<bool>,
42 pub mail_notification_username: Option<String>,
43 pub mail_notification_password: Option<String>,
44 pub autorun_enabled: Option<bool>,
45 pub autorun_program: Option<String>,
46 pub queueing_enabled: Option<bool>,
47 pub max_active_downloads: Option<i64>,
48 pub max_active_torrents: Option<i64>,
49 pub max_active_uploads: Option<i64>,
50 pub dont_count_slow_torrents: Option<bool>,
51 pub slow_torrent_dl_rate_threshold: Option<i64>,
52 pub slow_torrent_ul_rate_threshold: Option<i64>,
53 pub slow_torrent_inactive_timer: Option<i64>,
54 pub max_ratio_enabled: Option<bool>,
55 pub max_ratio: Option<f64>,
56 pub max_ratio_act: Option<MaxRatioAct>,
57 pub listen_port: Option<i64>,
58 pub upnp: Option<bool>,
59 pub random_port: Option<bool>,
60 pub dl_limit: Option<i64>,
61 pub up_limit: Option<i64>,
62 pub max_connec: Option<i64>,
63 pub max_connec_per_torrent: Option<i64>,
64 pub max_uploads: Option<i64>,
65 pub max_uploads_per_torrent: Option<i64>,
66 pub stop_tracker_timeout: Option<i64>,
67 pub enable_piece_extent_affinity: Option<bool>,
68 pub bittorrent_protocol: Option<BittorrentProtocol>,
69 pub limit_utp_rate: Option<bool>,
70 pub limit_tcp_overhead: Option<bool>,
71 pub limit_lan_peers: Option<bool>,
72 pub alt_dl_limit: Option<i64>,
73 pub alt_up_limit: Option<i64>,
74 pub scheduler_enabled: Option<bool>,
75 pub schedule_from_hour: Option<i64>,
76 pub schedule_from_min: Option<i64>,
77 pub schedule_to_hour: Option<i64>,
78 pub schedule_to_min: Option<i64>,
79 pub scheduler_days: Option<SchedulerDays>,
80 pub dht: Option<bool>,
81 pub pex: Option<bool>,
82 pub lsd: Option<bool>,
83 pub encryption: Option<Encryption>,
84 pub anonymous_mode: Option<bool>,
85 pub proxy_type: Option<ProxyType>,
86 pub proxy_ip: Option<String>,
87 pub proxy_port: Option<i64>,
88 pub proxy_peer_connections: Option<bool>,
89 pub proxy_auth_enabled: Option<bool>,
90 pub proxy_username: Option<String>,
91 pub proxy_password: Option<String>,
92 pub proxy_torrents_only: Option<bool>,
93 pub ip_filter_enabled: Option<bool>,
94 pub ip_filter_path: Option<String>,
95 pub ip_filter_trackers: Option<bool>,
96 pub web_ui_domain_list: Option<String>,
97 pub web_ui_address: Option<String>,
98 pub web_ui_port: Option<i64>,
99 pub web_ui_upnp: Option<bool>,
100 pub web_ui_username: Option<String>,
101 #[serde(skip_deserializing)]
102 pub web_ui_password: Option<String>,
103 pub web_ui_csrf_protection_enabled: Option<bool>,
104 pub web_ui_clickjacking_protection_enabled: Option<bool>,
105 pub web_ui_secure_cookie_enabled: Option<bool>,
106 pub web_ui_max_auth_fail_count: Option<i64>,
107 pub web_ui_ban_duration: Option<i64>,
108 pub web_ui_session_timeout: Option<i64>,
109 pub web_ui_host_header_validation_enabled: Option<bool>,
110 pub bypass_local_auth: Option<bool>,
111 pub bypass_auth_subnet_whitelist_enabled: Option<bool>,
112 pub bypass_auth_subnet_whitelist: Option<String>,
113 pub alternative_webui_enabled: Option<bool>,
114 pub alternative_webui_path: Option<String>,
115 pub use_https: Option<bool>,
116 pub web_ui_https_key_path: Option<String>,
117 pub web_ui_https_cert_path: Option<String>,
118 pub dyndns_enabled: Option<bool>,
119 pub dyndns_service: Option<DynDnsService>,
120 pub dyndns_username: Option<String>,
121 pub dyndns_password: Option<String>,
122 pub dyndns_domain: Option<String>,
123 pub rss_refresh_interval: Option<i64>,
124 pub rss_max_articles_per_feed: Option<i64>,
125 pub rss_processing_enabled: Option<bool>,
126 pub rss_auto_downloading_enabled: Option<bool>,
127 pub rss_download_repack_proper_episodes: Option<bool>,
128 pub rss_smart_episode_filters: Option<String>,
129 pub add_trackers_enabled: Option<bool>,
130 pub add_trackers: Option<String>,
131 pub web_ui_use_custom_http_headers_enabled: Option<bool>,
132 pub web_ui_custom_http_headers: Option<String>,
133 pub max_seeding_time_enabled: Option<bool>,
134 pub max_seeding_time: Option<i64>,
135 pub announce_ip: Option<String>,
136 pub announce_to_all_tiers: Option<bool>,
137 pub announce_to_all_trackers: Option<bool>,
138 pub async_io_threads: Option<i64>,
139 #[serde(rename = "banned_IPs")]
140 pub banned_ips: Option<String>,
141 pub checking_memory_use: Option<i64>,
142 pub current_interface_address: Option<String>,
143 pub current_network_interface: Option<String>,
144 pub disk_cache: Option<i64>,
145 pub disk_cache_ttl: Option<i64>,
146 pub embedded_tracker_port: Option<i64>,
147 pub enable_coalesce_read_write: Option<bool>,
148 pub enable_embedded_tracker: Option<bool>,
149 pub enable_multi_connections_from_same_ip: Option<bool>,
150 pub enable_upload_suggestions: Option<bool>,
152 pub file_pool_size: Option<i64>,
153 pub outgoing_ports_max: Option<i64>,
154 pub outgoing_ports_min: Option<i64>,
155 pub recheck_completed_torrents: Option<bool>,
156 pub resolve_peer_countries: Option<bool>,
157 pub save_resume_data_interval: Option<i64>,
158 pub send_buffer_low_watermark: Option<i64>,
159 pub send_buffer_watermark: Option<i64>,
160 pub send_buffer_watermark_factor: Option<i64>,
161 pub socket_backlog_size: Option<i64>,
162 pub upload_choking_algorithm: Option<UploadChokingAlgorithm>,
163 pub upload_slots_behavior: Option<UploadSlotsBehavior>,
164 pub upnp_lease_duration: Option<i64>,
165 pub utp_tcp_mixed_mode: Option<UtpTcpMixedMode>,
166}
167
168#[derive(Debug, Clone, Default, Serialize)]
175pub struct SetPreferencesForm {
176 #[serde(with = "preferences_serialize")]
177 pub json: Preferences,
178}
179
180#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
183#[repr(u8)]
184pub enum SchedulerDays {
185 EveryDay = 0,
186 EveryWeekday = 1,
187 EveryWeekend = 2,
188 EveryMonday = 3,
189 EveryTuesday = 4,
190 EveryWednesday = 5,
191 EveryThursday = 6,
192 EveryFriday = 7,
193 EverySaturday = 8,
194 EverySunday = 9,
195}
196
197#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
200#[repr(u8)]
201pub enum Encryption {
202 PreferEncryption = 0,
203 ForceEncryptionOn = 1,
204 ForceEncryptionOff = 2,
205}
206
207#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
210#[repr(u8)]
211pub enum ProxyType {
212 Disabled = 0,
213 Http = 1,
214 Socks5 = 2,
215 HttpWithAuth = 3,
216 Socks5WithAuth = 4,
217 Socks4WithAuth = 5,
218}
219
220#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
223#[repr(u8)]
224pub enum DynDnsService {
225 DyDNS = 0,
226 NOIP = 1,
227}
228
229#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
232#[repr(u8)]
233pub enum MaxRatioAct {
234 Pause = 0,
235 Remove = 1,
236}
237
238#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
241#[repr(u8)]
242pub enum BittorrentProtocol {
243 TCPUTP = 0,
244 TCP = 1,
245 UTP = 2,
246}
247
248#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
251#[repr(u8)]
252pub enum UploadChokingAlgorithm {
253 RoundRobin = 0,
254 FastestUpload = 1,
255 AntiLeech = 2,
256}
257
258#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
261#[repr(u8)]
262pub enum UploadSlotsBehavior {
263 FixedSlots = 0,
264 RateBased = 1,
265}
266
267#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
270#[repr(u8)]
271pub enum UtpTcpMixedMode {
272 PreferTCP = 0,
273 PeerProportional = 1,
274}