-
-
Notifications
You must be signed in to change notification settings - Fork 387
Expand file tree
/
Copy pathSettingsRepo.h
More file actions
295 lines (261 loc) · 11.2 KB
/
Copy pathSettingsRepo.h
File metadata and controls
295 lines (261 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#pragma once
#include "Database.h"
#include "include/global/Const.hpp"
#include <QMutexLocker>
#include <QJsonObject>
#include <QMap>
#include <QKeySequence>
#include <atomic>
#ifdef Q_OS_WIN
#include "include/sys/windows/WinVersion.h"
#endif
namespace Configs {
class SettingsRepo {
private:
Database& db;
QMap<QString, bool*> boolMap;
QMap<QString, int*> intMap;
QMap<QString, QString*> stringMap;
QMap<QString, QStringList*> stringListMap;
void initMaps();
void createTables() const;
void loadAllSettings();
void saveAllSettings() const;
public:
bool noSave = false;
explicit SettingsRepo(Database& database);
// Save all settings to database (like old Save() method)
bool Save();
// Public fields (mirroring DataStore interface for direct access)
// Running (not saved to DB, runtime state only)
QString core_socket_name = "";
int started_id = NoProfileId;
bool core_running = false;
bool prepare_exit = false;
bool spmode_vpn = false;
bool spmode_system_proxy = false;
QString appdataDir = "";
QStringList ignoreConnTag = {};
int imported_count = 0;
bool refreshing_group_list = false;
bool refreshing_group = false;
std::atomic<int> resolve_count = 0;
// Flags (not saved to DB, runtime flags only)
QStringList argv = {};
bool flag_use_appdata = false;
bool flag_many = false;
bool flag_tray = false;
bool flag_debug = false;
bool flag_restart_tun_on = false;
bool flag_dns_set = false;
// Saved settings (mirroring DataStore "Saved" section)
// Misc
QString mainWindowGeometry;
QString log_level = "info";
QString test_latency_url = "http://cp.cloudflare.com/";
int url_test_timeout_ms = 3000;
bool disable_tray = false;
int test_concurrent = 10;
bool disable_traffic_stats = false;
int current_group = 0; // group id
QString mux_protocol = "smux";
bool mux_padding = false;
int mux_concurrency = 8;
bool mux_default_on = false;
// TLS fragment: which implementation profiles use ("built-in" = sing-box
// tls.fragment, "custom" = hiddify dialer-level tls_fragment), and whether
// profiles left on "Keep Default" should be fragmented.
QString fragment_implementation = "built-in";
bool fragment_default_on = false;
// Custom (hiddify) fragment parameters, each a "min-max" range: bytes per
// ClientHello fragment, and milliseconds to sleep between bursts. Only the
// custom implementation uses these.
QString fragment_size = "10-100";
QString fragment_sleep = "2-5";
// TLS tricks (mixed-case SNI): default for profiles left on "Keep Default".
bool tls_tricks_default_on = false;
QString theme = "0";
int language = 0;
QString font = "";
int font_size = 0;
QString mw_size = "";
bool log_enable_include = false;
bool log_enable_exclude = false;
QStringList log_include_keyword = {};
QStringList log_include_regex = {};
QStringList log_exclude_keyword = {};
QStringList log_exclude_regex = {};
bool log_auto_scroll = true;
bool start_minimal = false;
int max_log_line = 200;
// On-disk diagnostic log only; log_level is the core's browser verbosity.
QString log_file_level = "debug";
QString splitter_state = "";
bool enable_stats = true;
int stats_tab = 0; // either connection or log
// Traffic-statistics module: days of hour-resolution history to retain
// (the 48h minute-resolution window is fixed). Clamped to >= 1 in use.
int traffic_stats_retention_days = 90;
bool disable_traffic_aggregation = false;
int speed_test_mode = TestConfig::FULL;
int speed_test_timeout_ms = 5000;
QString simple_dl_url = "http://cachefly.cachefly.net/1mb.test";
bool allow_beta_update = false;
bool show_system_dns = false;
bool use_custom_icons = false;
bool skip_delete_confirmation = false;
// Fold each config's security into the proxy table's Type column.
bool show_config_security = false;
// Proxy table column whose filter field was last used; -1 until one is.
int last_filter_column = -1;
// throne:// URL scheme: mirror of what we last wrote to the OS (registry/desktop/bundle).
// Re-registered on startup only when the current state differs (e.g. install moved).
QString url_scheme_mirror = "";
// Network
bool net_use_proxy = false;
bool net_insecure = false;
bool reset_proxy_on_disable_sp = false;
// Subscription
QString user_agent = ""; // set at main.cpp
// Auto-update interval in minutes; sign encodes the enable checkbox (negative =
// disabled), magnitude is the interval (ignored if < 30). *_last is the epoch-seconds
// of the last auto-update sweep, used to decide when the next one is due.
int sub_auto_update = -30;
qint64 sub_auto_update_last = 0;
bool sub_clear = false;
bool sub_show_change_popup = true;
bool sub_send_hwid = false;
QString sub_custom_hwid_params = "";
bool allow_stopping_active_profile = false;
// Security
bool skip_cert = false;
QString utlsFingerprint = "";
bool disable_run_admin = false; // windows only
bool use_mozilla_certs = false;
// Remember
bool remember_system_proxy = false;
bool remember_tun = false;
int remember_id = NoProfileId;
bool remember_enable = false;
bool windows_set_admin = false;
QMap<QString, QKeySequence> shortcuts;
// Routing
int current_route_id = 1;
// Remote routing-profile auto-update, same sign-encoded-interval scheme as
// sub_auto_update (negative = disabled, magnitude = minutes). Default: daily.
int route_auto_update = -1440;
qint64 route_auto_update_last = 0;
QString remote_dns = "https://8.8.8.8/dns-query";
QString remote_dns_strategy = "";
QString direct_dns = "localhost";
QString direct_dns_strategy = "";
int dns_cache_capacity = 65536;
bool dns_disable_cache = false;
bool dns_disable_expire = false;
bool dns_reverse_mapping = false;
bool enable_dns_routing = true;
bool use_dns_object = false;
QString dns_object = "";
QString dns_final_out = "remote";
QString resolve_domain_strategy = "";
QString default_domain_strategy = "";
int ruleset_mirror = Mirrors::CLOUDFLARE;
// Socks & HTTP Inbound
bool disable_mixed_inbound = false;
QString inbound_address = "127.0.0.1";
int inbound_socks_port = 2080; // Mixed, actually
bool random_inbound_port = false;
QString custom_inbound = "{\"inbounds\": []}";
QString proxy_scheme = "{ip}:{port}";
bool inbound_auth = false;
QString inbound_user = "";
QString inbound_pass = "";
// Routing
QString custom_route_global = "{\"rules\": []}";
QString active_routing = "Default";
bool adblock_enable = false;
// VPN
bool fake_dns = false;
bool enable_tun_routing = false;
#ifdef Q_OS_MACOS
QString vpn_implementation = "gvisor";
bool vpn_strict_route = false;
#elif defined(Q_OS_WIN)
QString vpn_implementation = WinVersion::IsBuildNumGreaterOrEqual(BuildNumber::Windows_10_1507) ? "system" : "gvisor";
bool vpn_strict_route = WinVersion::IsBuildNumGreaterOrEqual(BuildNumber::Windows_10_1507);
#else
QString vpn_implementation = "system";
bool vpn_strict_route = false;
#endif
// Linux only: emit `auto_redirect` on the Tun inbound. Newer kernels need it for the
// system/mixed stacks to pass traffic, at the cost of this host acting as a gateway.
bool vpn_auto_redirect = true;
int vpn_mtu = 1500;
bool disable_private_range_bypass = false;
bool vpn_ipv6 = false;
bool kill_switch_enabled = false;
QString vpn_tun_ipv4_cidr = "172.19.0.1/24";
QString vpn_tun_ipv6_cidr = "fdfe:dcba:9876::1/96";
bool disable_privilege_req = false;
// NTP
bool enable_ntp = false;
QString ntp_server_address = "";
int ntp_server_port = 0;
QString ntp_interval = "";
QString ntp_outbound = "direct"; // "direct" or "proxy"
// Warp
bool enable_warp = false;
QString warp_private_key = "";
QString warp_public_key = "";
QStringList warp_ifc_addrs = {};
QString warp_ep = "";
QStringList warp_reserved = {};
// Hijack
bool enable_dns_server = false;
bool dns_server_listen_lan = false;
int dns_server_listen_port = 53;
QString dns_v4_resp = "127.0.0.1";
QString dns_v6_resp = "::1";
QStringList dns_server_rules = {};
bool enable_redirect = false;
QString redirect_listen_address = "127.0.0.1";
int redirect_listen_port = 443;
// System dns
bool system_dns_set = false;
// Hotkey
QString hotkey_mainwindow = "";
QString hotkey_group = "";
QString hotkey_route = "";
QString hotkey_system_proxy_menu = "";
QString hotkey_toggle_system_proxy = "";
// Core
int core_box_clash_api = -9090;
QString core_box_clash_listen_addr = "127.0.0.1";
QString core_box_clash_api_secret = "";
QString core_box_underlying_dns = "";
int core_dns_in_port = 5533;
// Xray
QString xray_log_level = "warning";
int xray_mux_concurrency = 8;
bool xray_mux_default_on = false;
Xray::XrayVlessPreference xray_vless_preference = Xray::XhttpAndReality;
// Download URLs for the Xray routing data files (geoip.dat / geosite.dat).
// Needed when a full Xray config's routing references geoip:/geosite: tags.
// Fetched on demand into GetBasePath(), which the core exposes to Xray via
// the XRAY_LOCATION_ASSET env var.
QString xray_geoip_url = "https://github.com/Loyalsoldier/v2ray-rules-dat/raw/release/geoip.dat";
QString xray_geosite_url = "https://github.com/Loyalsoldier/v2ray-rules-dat/raw/release/geosite.dat";
// Extra Core Paths
QStringList extraCorePaths = {};
// Bind address/interface custom entry history (last 5 per field)
QStringList dial_bind_interface_history = {};
QStringList dial_inet4_bind_address_history = {};
QStringList dial_inet6_bind_address_history = {};
// Methods
void UpdateStartedId(int id);
[[nodiscard]] QString GetUserAgent(bool isDefault = false) const;
// Extra Core Paths methods
[[nodiscard]] QStringList GetExtraCorePaths() const;
bool AddExtraCorePath(const QString &path);
};
}