mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-05-06 13:38:04 +03:00
default port - 42666
This commit is contained in:
parent
6ad49cb22a
commit
54e0b13ba7
12
src/proto.rs
12
src/proto.rs
@ -6,16 +6,22 @@ pub trait RacStream: Read + Write + Unpin + Send + Sync + Debug {}
|
||||
impl<T: Read + Write + Unpin + Send + Sync + Debug> RacStream for T {}
|
||||
|
||||
pub fn connect(host: &str, ssl: bool) -> Result<Box<dyn RacStream>, Box<dyn Error>> {
|
||||
let host = if host.contains(":") {
|
||||
host.to_string()
|
||||
} else {
|
||||
format!("{host}:42666")
|
||||
};
|
||||
|
||||
Ok(if ssl {
|
||||
let ip: String = host.split_once(":")
|
||||
.map(|o| o.0)
|
||||
.unwrap_or(host).to_string();
|
||||
.map(|o| o.0.to_string())
|
||||
.unwrap_or(host.clone());
|
||||
|
||||
Box::new(TlsConnector::builder()
|
||||
.danger_accept_invalid_certs(true)
|
||||
.danger_accept_invalid_hostnames(true)
|
||||
.build()?
|
||||
.connect(&ip, connect(host, false)?)?)
|
||||
.connect(&ip, connect(&host, false)?)?)
|
||||
} else {
|
||||
Box::new(TcpStream::connect(host)?)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user