Struct shadowsocks::relay::udprelay::proxy_socket::ProxySocket
source · [−]pub struct ProxySocket { /* private fields */ }
Expand description
UDP client for communicating with ShadowSocks’ server
Implementations
sourceimpl ProxySocket
impl ProxySocket
sourcepub async fn connect(
context: SharedContext,
svr_cfg: &ServerConfig
) -> Result<ProxySocket>
pub async fn connect(
context: SharedContext,
svr_cfg: &ServerConfig
) -> Result<ProxySocket>
Create a client to communicate with Shadowsocks’ UDP server (outbound)
sourcepub async fn connect_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: &ConnectOpts
) -> Result<ProxySocket>
pub async fn connect_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: &ConnectOpts
) -> Result<ProxySocket>
Create a client to communicate with Shadowsocks’ UDP server (outbound)
sourcepub fn from_socket(
context: SharedContext,
svr_cfg: &ServerConfig,
socket: UdpSocket
) -> ProxySocket
pub fn from_socket(
context: SharedContext,
svr_cfg: &ServerConfig,
socket: UdpSocket
) -> ProxySocket
Create a ProxySocket
from a UdpSocket
sourcepub async fn bind(
context: SharedContext,
svr_cfg: &ServerConfig
) -> Result<ProxySocket>
pub async fn bind(
context: SharedContext,
svr_cfg: &ServerConfig
) -> Result<ProxySocket>
Create a ProxySocket
binding to a specific address (inbound)
sourcepub async fn bind_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: AcceptOpts
) -> Result<ProxySocket>
pub async fn bind_with_opts(
context: SharedContext,
svr_cfg: &ServerConfig,
opts: AcceptOpts
) -> Result<ProxySocket>
Create a ProxySocket
binding to a specific address (inbound)
sourcepub async fn send(&self, addr: &Address, payload: &[u8]) -> Result<usize>
pub async fn send(&self, addr: &Address, payload: &[u8]) -> Result<usize>
Send a UDP packet to addr through proxy
sourcepub async fn send_to<A: ToSocketAddrs>(
&self,
target: A,
addr: &Address,
payload: &[u8]
) -> Result<usize>
pub async fn send_to<A: ToSocketAddrs>(
&self,
target: A,
addr: &Address,
payload: &[u8]
) -> Result<usize>
Send a UDP packet to target from proxy
sourcepub async fn recv(&self, recv_buf: &mut [u8]) -> Result<(usize, Address, usize)>
pub async fn recv(&self, recv_buf: &mut [u8]) -> Result<(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_from(
&self,
recv_buf: &mut [u8]
) -> Result<(usize, SocketAddr, Address, usize)>
pub async fn recv_from(
&self,
recv_buf: &mut [u8]
) -> Result<(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 fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get local addr of socket
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
Auto Trait Implementations
impl !RefUnwindSafe for ProxySocket
impl Send for ProxySocket
impl Sync for ProxySocket
impl Unpin for ProxySocket
impl !UnwindSafe for ProxySocket
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more