Add tls setting to vless outbound

This commit is contained in:
Keivan-sf
2023-10-19 10:04:12 +03:30
parent 63c71208ea
commit b5dd8dfcc6
2 changed files with 36 additions and 17 deletions

View File

@@ -26,34 +26,33 @@ pub enum OutboundSettings {
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[derive(Serialize, Deserialize)]
pub struct TlsSettings { pub struct TlsSettings {
pub allowInsecure: bool, pub allowInsecure: Option<bool>,
pub certificates: u8, pub serverName: Option<String>,
pub serverName: String, pub enableSessionResumption: Option<bool>,
// u8 is a dummy type here pub disableSystemRoot: Option<bool>,
pub alpn: u8, pub minVersion: Option<String>,
pub enableSessionResumption: bool, pub maxVersion: Option<String>,
pub disableSystemRoot: bool, pub cipherSuites: Option<String>,
pub minVersion: String, pub preferServerCipherSuites: Option<bool>,
pub maxVersion: String, pub fingerprint: Option<String>,
pub cipherSuites: String, pub rejectUnknownSni: Option<bool>,
pub preferServerCipherSuites: bool,
pub fingerprint: String,
pub rejectUnknownSni: bool,
pub pinnedPeerCertificateChainSha256: u8,
pub pinnedPeerCertificatePublicKeySha256: u8,
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[derive(Serialize, Deserialize)]
pub struct StreamSettings { pub struct StreamSettings {
pub network: String, pub network: String,
pub security: String, pub security: String,
pub tlsSettings: TlsSettings, pub tlsSettings: Option<TlsSettings>,
} }
#[allow(non_snake_case)]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct Outbound { pub struct Outbound {
pub settings: OutboundSettings, pub settings: OutboundSettings,
pub streamSettings: StreamSettings,
pub protocol: String, pub protocol: String,
pub tag: String, pub tag: String,
} }

View File

@@ -1,13 +1,33 @@
use querystring; use querystring;
mod models; mod models;
use crate::parser::config_models::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::process::exit; use std::process::exit;
use crate::parser::config_models::*;
fn create_outbound_object(data: models::VlessData) -> Outbound { fn create_outbound_object(data: models::VlessData) -> Outbound {
return Outbound { return Outbound {
protocol: String::from("vless"), protocol: String::from("vless"),
tag: String::from("proxy"), tag: String::from("proxy"),
streamSettings: StreamSettings {
network: data.query.r#type,
security: data.query.security.clone(),
tlsSettings: if data.query.security == String::from("tls") {
Some(TlsSettings {
rejectUnknownSni: None,
enableSessionResumption: None,
minVersion: None,
maxVersion: None,
cipherSuites: None,
disableSystemRoot: None,
preferServerCipherSuites: None,
fingerprint: Some(String::from("")),
serverName: Some(data.query.sni),
allowInsecure: Some(false),
})
} else {
None
},
},
settings: OutboundSettings::Vless(VlessOutboundSettings { settings: OutboundSettings::Vless(VlessOutboundSettings {
vnext: vec![VlessServerObject { vnext: vec![VlessServerObject {
port: data.address_data.port, port: data.address_data.port,