Ditch ToSocksAddress for the standard From/TryFrom.

This induces an added `Send` in the Network trait and its
implementations, but provides us the ability to use standard functions
with obvious extensions. So that's nice. I've also added some additional
testing to sanity check the conversions.
This commit is contained in:
2021-07-05 20:35:56 -07:00
parent d1143a414c
commit ca2eddf515
4 changed files with 145 additions and 52 deletions

View File

@@ -6,7 +6,7 @@ pub mod standard;
pub mod stream;
use crate::messages::ServerResponseStatus;
pub use crate::network::address::{SOCKSv5Address, ToSOCKSAddress};
pub use crate::network::address::SOCKSv5Address;
pub use crate::network::standard::Builtin;
use async_trait::async_trait;
use futures::{AsyncRead, AsyncWrite};
@@ -19,17 +19,17 @@ pub trait Network {
type UdpSocket;
type Error: fmt::Debug + fmt::Display + Into<ServerResponseStatus>;
async fn connect<A: ToSOCKSAddress>(
async fn connect<A: Into<SOCKSv5Address>>(
&mut self,
addr: A,
port: u16,
) -> Result<Self::Stream, Self::Error>;
async fn udp_socket<A: ToSOCKSAddress>(
async fn udp_socket<A: Into<SOCKSv5Address>>(
&mut self,
addr: A,
port: Option<u16>,
) -> Result<Self::UdpSocket, Self::Error>;
async fn listen<A: ToSOCKSAddress>(
async fn listen<A: Into<SOCKSv5Address>>(
&mut self,
addr: A,
port: Option<u16>,