pub struct ProxySocket<S> { /* private fields */ }
Expand description
UDP client for communicating with ShadowSocks’ server
Implementations§
Source§impl ProxySocket<UdpSocket>
impl ProxySocket<UdpSocket>
Sourcepub async fn connect(
context: SharedContext,
svr_cfg: &ServerConfig,
) -> ProxySocketResult<Self>
pub async fn connect( context: SharedContext, svr_cfg: &ServerConfig, ) -> ProxySocketResult<Self>
Create a client to communicate with Shadowsocks’ UDP server (outbound)
Sourcepub async fn connect_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: &ConnectOpts,
) -> ProxySocketResult<Self>
pub async fn connect_with_opts( context: SharedContext, svr_cfg: &ServerConfig, opts: &ConnectOpts, ) -> ProxySocketResult<Self>
Create a client to communicate with Shadowsocks’ UDP server (outbound)
Sourcepub async fn bind(
context: SharedContext,
svr_cfg: &ServerConfig,
) -> ProxySocketResult<Self>
pub async fn bind( context: SharedContext, svr_cfg: &ServerConfig, ) -> ProxySocketResult<Self>
Create a ProxySocket
binding to a specific address (inbound)
Sourcepub async fn bind_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: AcceptOpts,
) -> ProxySocketResult<Self>
pub async fn bind_with_opts( context: SharedContext, svr_cfg: &ServerConfig, opts: AcceptOpts, ) -> ProxySocketResult<Self>
Create a ProxySocket
binding to a specific address (inbound)
Source§impl<S> ProxySocket<S>
impl<S> ProxySocket<S>
Sourcepub fn from_socket(
socket_type: UdpSocketType,
context: SharedContext,
svr_cfg: &ServerConfig,
socket: S,
) -> Self
pub fn from_socket( socket_type: UdpSocketType, context: SharedContext, svr_cfg: &ServerConfig, socket: S, ) -> Self
Create a ProxySocket
from a I/O object that impls DatagramTransport
Sourcepub fn set_send_timeout(&mut self, t: Option<Duration>)
pub fn set_send_timeout(&mut self, t: Option<Duration>)
Set send
timeout, None
will clear timeout
Sourcepub fn set_recv_timeout(&mut self, t: Option<Duration>)
pub fn set_recv_timeout(&mut self, t: Option<Duration>)
Set recv
timeout, None
will clear timeout
Source§impl<S> ProxySocket<S>where
S: DatagramSend,
impl<S> ProxySocket<S>where
S: DatagramSend,
Sourcepub async fn send(
&self,
addr: &Address,
payload: &[u8],
) -> ProxySocketResult<usize>
pub async fn send( &self, addr: &Address, payload: &[u8], ) -> ProxySocketResult<usize>
Send a UDP packet to addr through proxy
Sourcepub async fn send_with_ctrl(
&self,
addr: &Address,
control: &UdpSocketControlData,
payload: &[u8],
) -> ProxySocketResult<usize>
pub async fn send_with_ctrl( &self, addr: &Address, control: &UdpSocketControlData, payload: &[u8], ) -> ProxySocketResult<usize>
Send a UDP packet to addr through proxy with ControlData
Sourcepub fn poll_send(
&self,
addr: &Address,
payload: &[u8],
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<usize>>
pub fn poll_send( &self, addr: &Address, payload: &[u8], cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<usize>>
poll family functions
Send a UDP packet to addr through proxy
NOTE: the send_timeout
is ignored.
Sourcepub fn poll_send_with_ctrl(
&self,
addr: &Address,
control: &UdpSocketControlData,
payload: &[u8],
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<usize>>
pub fn poll_send_with_ctrl( &self, addr: &Address, control: &UdpSocketControlData, payload: &[u8], cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<usize>>
poll family functions
Send a UDP packet to addr through proxy with ControlData
NOTE: the send_timeout
is ignored.
Sourcepub fn poll_send_to(
&self,
target: SocketAddr,
addr: &Address,
payload: &[u8],
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<usize>>
pub fn poll_send_to( &self, target: SocketAddr, addr: &Address, payload: &[u8], cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<usize>>
poll family functions
Send a UDP packet to addr through proxy target
NOTE: the send_timeout
is ignored.
Sourcepub fn poll_send_to_with_ctrl(
&self,
target: SocketAddr,
addr: &Address,
control: &UdpSocketControlData,
payload: &[u8],
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<usize>>
pub fn poll_send_to_with_ctrl( &self, target: SocketAddr, addr: &Address, control: &UdpSocketControlData, payload: &[u8], cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<usize>>
poll family functions
Send a UDP packet to addr through proxy target
with ControlData
NOTE: the send_timeout
is ignored.
Sourcepub fn poll_send_ready(
&self,
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<()>>
pub fn poll_send_ready( &self, cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<()>>
poll family functions
Check if socket is ready to send
, or writable.
Sourcepub async fn send_to(
&self,
target: SocketAddr,
addr: &Address,
payload: &[u8],
) -> ProxySocketResult<usize>
pub async fn send_to( &self, target: SocketAddr, addr: &Address, payload: &[u8], ) -> ProxySocketResult<usize>
Send a UDP packet to target through proxy target
Sourcepub async fn send_to_with_ctrl(
&self,
target: SocketAddr,
addr: &Address,
control: &UdpSocketControlData,
payload: &[u8],
) -> ProxySocketResult<usize>
pub async fn send_to_with_ctrl( &self, target: SocketAddr, addr: &Address, control: &UdpSocketControlData, payload: &[u8], ) -> ProxySocketResult<usize>
Send a UDP packet to target through proxy target
Source§impl<S> ProxySocket<S>where
S: DatagramReceive,
impl<S> ProxySocket<S>where
S: DatagramReceive,
Sourcepub async fn recv(
&self,
recv_buf: &mut [u8],
) -> ProxySocketResult<(usize, Address, usize)>
pub async fn recv( &self, recv_buf: &mut [u8], ) -> ProxySocketResult<(usize, Address, usize)>
Receive packet from Shadowsocks’ UDP server
This function will use recv_buf
to store intermediate data, so it has to be big enough to store the whole shadowsocks’ packet
It is recommended to allocate a buffer to have at least 65536 bytes.
Sourcepub async fn recv_with_ctrl(
&self,
recv_buf: &mut [u8],
) -> ProxySocketResult<(usize, Address, usize, Option<UdpSocketControlData>)>
pub async fn recv_with_ctrl( &self, recv_buf: &mut [u8], ) -> ProxySocketResult<(usize, Address, usize, Option<UdpSocketControlData>)>
Receive packet from Shadowsocks’ UDP server
This function will use recv_buf
to store intermediate data, so it has to be big enough to store the whole shadowsocks’ packet
It is recommended to allocate a buffer to have at least 65536 bytes.
Sourcepub async fn recv_from(
&self,
recv_buf: &mut [u8],
) -> ProxySocketResult<(usize, SocketAddr, Address, usize)>
pub async fn recv_from( &self, recv_buf: &mut [u8], ) -> ProxySocketResult<(usize, SocketAddr, Address, usize)>
Receive packet from Shadowsocks’ UDP server
This function will use recv_buf
to store intermediate data, so it has to be big enough to store the whole shadowsocks’ packet
It is recommended to allocate a buffer to have at least 65536 bytes.
Sourcepub async fn recv_from_with_ctrl(
&self,
recv_buf: &mut [u8],
) -> ProxySocketResult<(usize, SocketAddr, Address, usize, Option<UdpSocketControlData>)>
pub async fn recv_from_with_ctrl( &self, recv_buf: &mut [u8], ) -> ProxySocketResult<(usize, SocketAddr, Address, usize, Option<UdpSocketControlData>)>
Receive packet from Shadowsocks’ UDP server
This function will use recv_buf
to store intermediate data, so it has to be big enough to store the whole shadowsocks’ packet
It is recommended to allocate a buffer to have at least 65536 bytes.
Sourcepub fn poll_recv(
&self,
cx: &mut Context<'_>,
recv_buf: &mut ReadBuf<'_>,
) -> Poll<ProxySocketResult<(usize, Address, usize)>>
pub fn poll_recv( &self, cx: &mut Context<'_>, recv_buf: &mut ReadBuf<'_>, ) -> Poll<ProxySocketResult<(usize, Address, usize)>>
poll family functions. the recv_timeout is ignored.
Sourcepub fn poll_recv_with_ctrl(
&self,
cx: &mut Context<'_>,
recv_buf: &mut ReadBuf<'_>,
) -> Poll<ProxySocketResult<(usize, Address, usize, Option<UdpSocketControlData>)>>
pub fn poll_recv_with_ctrl( &self, cx: &mut Context<'_>, recv_buf: &mut ReadBuf<'_>, ) -> Poll<ProxySocketResult<(usize, Address, usize, Option<UdpSocketControlData>)>>
poll family functions
Sourcepub fn poll_recv_from(
&self,
cx: &mut Context<'_>,
recv_buf: &mut ReadBuf<'_>,
) -> Poll<ProxySocketResult<(usize, SocketAddr, Address, usize)>>
pub fn poll_recv_from( &self, cx: &mut Context<'_>, recv_buf: &mut ReadBuf<'_>, ) -> Poll<ProxySocketResult<(usize, SocketAddr, Address, usize)>>
poll family functions
Sourcepub fn poll_recv_from_with_ctrl(
&self,
cx: &mut Context<'_>,
recv_buf: &mut ReadBuf<'_>,
) -> Poll<ProxySocketResult<(usize, SocketAddr, Address, usize, Option<UdpSocketControlData>)>>
pub fn poll_recv_from_with_ctrl( &self, cx: &mut Context<'_>, recv_buf: &mut ReadBuf<'_>, ) -> Poll<ProxySocketResult<(usize, SocketAddr, Address, usize, Option<UdpSocketControlData>)>>
poll family functions
Sourcepub fn poll_recv_ready(
&self,
cx: &mut Context<'_>,
) -> Poll<ProxySocketResult<()>>
pub fn poll_recv_ready( &self, cx: &mut Context<'_>, ) -> Poll<ProxySocketResult<()>>
poll family functions
Source§impl<S> ProxySocket<S>where
S: DatagramSocket,
impl<S> ProxySocket<S>where
S: DatagramSocket,
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get local addr of socket