Skip to content

Commit b77a0c1

Browse files
committed
wip on making CyphertSession accepting socket2
1 parent 058c869 commit b77a0c1

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/session.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,35 @@ pub type NoiseSession<E, D, S> = NetProtocol<NoiseState<E, D>, S>;
4747
pub type Socks5Session<S> = NetProtocol<socks5::Socks5, S>;
4848

4949
#[cfg(feature = "eidolon")]
50-
pub type CypherSession<I, D, T = TcpStream> =
50+
pub type CypherSession<I, D, T> =
5151
EidolonSession<I, NoiseSession<x25519::PrivateKey, D, Socks5Session<T>>>;
5252

5353
#[cfg(feature = "eidolon")]
5454
pub type EidolonReader<S> = NetReader<S>;
5555
#[cfg(feature = "eidolon")]
5656
pub type EidolonWriter<I, S> = NetWriter<EidolonRuntime<I>, S>;
5757
#[cfg(feature = "eidolon")]
58-
pub type CypherReader<D, T = TcpStream> =
59-
EidolonReader<NoiseSession<x25519::PrivateKey, D, Socks5Session<T>>>;
58+
pub type CypherReader<D, T> = EidolonReader<NoiseSession<x25519::PrivateKey, D, Socks5Session<T>>>;
6059
#[cfg(feature = "eidolon")]
61-
pub type CypherWriter<I, D, T = TcpStream> =
60+
pub type CypherWriter<I, D, T> =
6261
EidolonWriter<I, NoiseSession<x25519::PrivateKey, D, Socks5Session<T>>>;
6362

6463
#[cfg(feature = "eidolon")]
65-
impl<I: EcSign, D: Digest> CypherSession<I, D> {
64+
impl<I: EcSign, D: Digest, T: NetSession> CypherSession<I, D, T> {
6665
#[cfg(feature = "reactor")]
6766
pub fn connect_nonblocking<const HASHLEN: usize>(
6867
remote_addr: NetAddr<HostName>,
6968
cert: Cert<I::Sig>,
7069
allowed_ids: Vec<I::Pk>,
7170
signer: I,
72-
proxy_addr: NetAddr<InetHost>,
71+
proxy_addr: <T::Connection as NetConnection>::Addr,
7372
force_proxy: bool,
7473
timeout: Duration,
7574
) -> io::Result<Self> {
7675
let connection = if force_proxy {
77-
TcpStream::connect_nonblocking(proxy_addr, timeout)?
76+
T::Connection::connect_nonblocking(proxy_addr, timeout)?
7877
} else {
79-
TcpStream::connect_nonblocking(remote_addr.connection_addr(proxy_addr), timeout)?
78+
T::Connection::connect_nonblocking(remote_addr.connection_addr(proxy_addr), timeout)?
8079
};
8180
Ok(Self::with_config::<HASHLEN>(
8281
remote_addr,
@@ -164,7 +163,7 @@ impl<I: EcSign, D: Digest> CypherSession<I, D> {
164163

165164
fn with_config<const HASHLEN: usize>(
166165
remote_addr: NetAddr<HostName>,
167-
connection: TcpStream,
166+
connection: T,
168167
direction: Direction,
169168
cert: Cert<I::Sig>,
170169
allowed_ids: Vec<I::Pk>,

0 commit comments

Comments
 (0)