From c4ee41d11b6bb6c7954ad5f9ddb0141e8fd8c113 Mon Sep 17 00:00:00 2001 From: Keivan-sf Date: Tue, 7 Nov 2023 16:29:53 +0330 Subject: [PATCH] Add inbound config strcutures --- src/parser/config_models/mod.rs | 26 ++++++++++++++++++++++++++ src/parser/mod.rs | 7 ++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/parser/config_models/mod.rs b/src/parser/config_models/mod.rs index 8d43b81..2806176 100644 --- a/src/parser/config_models/mod.rs +++ b/src/parser/config_models/mod.rs @@ -108,7 +108,33 @@ pub struct Outbound { pub tag: String, } +#[derive(Serialize, Deserialize)] +pub struct InboundSettings { + pub udp: bool, +} + +#[derive(Serialize, Deserialize)] +#[allow(non_snake_case)] +pub struct SniffingSettings { + pub enabled: Option, + pub destOverride: Option>, + pub domainsExcluded: Option>, + pub metadataOnly: Option, + pub routeOnly: Option, +} + +#[derive(Serialize, Deserialize)] +pub struct Inbound { + pub listen: String, + pub port: u16, + pub protocol: String, + pub settings: InboundSettings, + pub sniffing: Option, + pub tag: String, +} + #[derive(Serialize, Deserialize)] pub struct Config { pub outbounds: Vec, + pub inbounds: Option>, } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 5815c7f..4e861de 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -5,16 +5,17 @@ pub mod config_models; mod uri_identifier; mod vless; -pub fn create_json_config(uri: &str) -> String { - let config = create_config(uri); +pub fn create_json_config(uri: &str, socks_port: Option) -> String { + let config = create_config(uri, socks_port); let serialized = serde_json::to_string(&config).unwrap(); return serialized; } -pub fn create_config(uri: &str) -> Config { +pub fn create_config(uri: &str, socks_port: Option) -> Config { let outbound_object = create_outbound_object(uri); let config = Config { outbounds: vec![outbound_object], + inbounds: None, }; return config; }