libsubconverter/models/
extra_settings.rs

1use crate::Settings;
2
3use super::RegexMatchConfigs;
4
5/// Settings for subscription export operations
6#[derive(Debug, Clone)]
7pub struct ExtraSettings {
8    /// Whether to enable the rule generator
9    pub enable_rule_generator: bool,
10    /// Whether to overwrite original rules
11    pub overwrite_original_rules: bool,
12    /// Rename operations to apply
13    pub rename_array: RegexMatchConfigs,
14    /// Emoji operations to apply
15    pub emoji_array: RegexMatchConfigs,
16    /// Whether to add emoji
17    pub add_emoji: bool,
18    /// Whether to remove emoji
19    pub remove_emoji: bool,
20    /// Whether to append proxy type
21    pub append_proxy_type: bool,
22    /// Whether to output as node list
23    pub nodelist: bool,
24    /// Whether to sort nodes
25    pub sort_flag: bool,
26    /// Whether to filter deprecated nodes
27    pub filter_deprecated: bool,
28    /// Whether to use new field names in Clash
29    pub clash_new_field_name: bool,
30    /// Whether to use scripts in Clash
31    pub clash_script: bool,
32    /// Path to Surge SSR binary
33    pub surge_ssr_path: String,
34    /// Prefix for managed configs
35    pub managed_config_prefix: String,
36    /// QuantumultX device ID
37    pub quanx_dev_id: String,
38    /// UDP support flag
39    pub udp: Option<bool>,
40    /// TCP Fast Open support flag
41    pub tfo: Option<bool>,
42    /// Skip certificate verification flag
43    pub skip_cert_verify: Option<bool>,
44    /// TLS 1.3 support flag
45    pub tls13: Option<bool>,
46    /// Whether to use classical ruleset in Clash
47    pub clash_classical_ruleset: bool,
48    /// Script for sorting nodes
49    pub sort_script: String,
50    /// Style for Clash proxies output
51    pub clash_proxies_style: String,
52    /// Style for Clash proxy groups output
53    pub clash_proxy_groups_style: String,
54    /// Whether the export is authorized
55    pub authorized: bool,
56    /// JavaScript runtime context (not implemented in Rust version)
57    pub js_context: Option<()>,
58}
59
60impl Default for ExtraSettings {
61    fn default() -> Self {
62        let global = Settings::current();
63
64        ExtraSettings {
65            enable_rule_generator: global.enable_rule_gen,
66            overwrite_original_rules: global.overwrite_original_rules,
67            rename_array: Vec::new(),
68            emoji_array: Vec::new(),
69            add_emoji: false,
70            remove_emoji: false,
71            append_proxy_type: false,
72            nodelist: false,
73            sort_flag: false,
74            filter_deprecated: false,
75            clash_new_field_name: true,
76            clash_script: false,
77            surge_ssr_path: global.surge_ssr_path.clone(),
78            managed_config_prefix: String::new(),
79            quanx_dev_id: String::new(),
80            udp: None,
81            tfo: None,
82            skip_cert_verify: None,
83            tls13: None,
84            clash_classical_ruleset: false,
85            sort_script: String::new(),
86            clash_proxies_style: if global.clash_proxies_style.is_empty() {
87                "flow".to_string()
88            } else {
89                global.clash_proxies_style.clone()
90            },
91            clash_proxy_groups_style: if global.clash_proxy_groups_style.is_empty() {
92                "flow".to_string()
93            } else {
94                global.clash_proxy_groups_style.clone()
95            },
96            authorized: false,
97            js_context: None,
98        }
99    }
100}