Struct wmproxy::WMCore

source ·
pub struct WMCore {
Show 19 fields pub option: ConfigOption, pub center_client: Option<CenterClient>, pub center_servers: Vec<CenterServer>, pub proxy_accept: Option<TlsAcceptor>, pub proxy_client: Option<Arc<ClientConfig>>, pub client_listener: Option<TcpListener>, pub center_listener: Option<TcpListener>, pub map_http_listener: Option<TcpListener>, pub map_https_listener: Option<TcpListener>, pub map_tcp_listener: Option<TcpListener>, pub map_proxy_listener: Option<TcpListener>, pub map_accept: Option<TlsAcceptor>, pub http_servers: Vec<Arc<ServerConfig>>, pub http_accepts: Vec<Option<WrapTlsAccepter>>, pub http_tlss: Vec<bool>, pub http_listeners: Vec<TcpListener>, pub stream_config: Option<Arc<Mutex<StreamConfig>>>, pub stream_listeners: Vec<TcpListener>, pub stream_udp_listeners: Vec<StreamUdp>, /* private fields */
}
Expand description

核心处理类

Fields§

§option: ConfigOption§center_client: Option<CenterClient>§center_servers: Vec<CenterServer>§proxy_accept: Option<TlsAcceptor>§proxy_client: Option<Arc<ClientConfig>>§client_listener: Option<TcpListener>§center_listener: Option<TcpListener>§map_http_listener: Option<TcpListener>§map_https_listener: Option<TcpListener>§map_tcp_listener: Option<TcpListener>§map_proxy_listener: Option<TcpListener>§map_accept: Option<TlsAcceptor>§http_servers: Vec<Arc<ServerConfig>>§http_accepts: Vec<Option<WrapTlsAccepter>>§http_tlss: Vec<bool>§http_listeners: Vec<TcpListener>§stream_config: Option<Arc<Mutex<StreamConfig>>>§stream_listeners: Vec<TcpListener>§stream_udp_listeners: Vec<StreamUdp>

Implementations§

source§

impl WMCore

source

pub fn new(option: ConfigOption) -> WMCore

Examples found in repository?
examples/proxy.rs (line 31)
26
27
28
29
30
31
32
33
34
35
36
37
38
async fn run_proxy(
    proxy: ProxyConfig,
) -> ProxyResult<(SocketAddr, Sender<()>)> {
    let option = ConfigOption::new_by_proxy(proxy);
    let (sender_close, receiver_close) = channel::<()>(1);
    let mut proxy = WMCore::new(option);
    proxy.ready_serve().await.unwrap();
    let addr = proxy.center_listener.as_ref().unwrap().local_addr()?;
    tokio::spawn(async move {
        let _ = proxy.run_serve(receiver_close, None).await;
    });
    Ok((addr, sender_close))
}
source

pub async fn do_start_health_check(&mut self) -> ProxyResult<()>

source

pub async fn ready_serve(&mut self) -> ProxyResult<()>

Examples found in repository?
examples/proxy.rs (line 32)
26
27
28
29
30
31
32
33
34
35
36
37
38
async fn run_proxy(
    proxy: ProxyConfig,
) -> ProxyResult<(SocketAddr, Sender<()>)> {
    let option = ConfigOption::new_by_proxy(proxy);
    let (sender_close, receiver_close) = channel::<()>(1);
    let mut proxy = WMCore::new(option);
    proxy.ready_serve().await.unwrap();
    let addr = proxy.center_listener.as_ref().unwrap().local_addr()?;
    tokio::spawn(async move {
        let _ = proxy.run_serve(receiver_close, None).await;
    });
    Ok((addr, sender_close))
}
source

pub async fn run_serve( &mut self, receiver_close: Receiver<()>, sender_close: Option<Sender<()>> ) -> ProxyResult<()>

Examples found in repository?
examples/proxy.rs (line 35)
26
27
28
29
30
31
32
33
34
35
36
37
38
async fn run_proxy(
    proxy: ProxyConfig,
) -> ProxyResult<(SocketAddr, Sender<()>)> {
    let option = ConfigOption::new_by_proxy(proxy);
    let (sender_close, receiver_close) = channel::<()>(1);
    let mut proxy = WMCore::new(option);
    proxy.ready_serve().await.unwrap();
    let addr = proxy.center_listener.as_ref().unwrap().local_addr()?;
    tokio::spawn(async move {
        let _ = proxy.run_serve(receiver_close, None).await;
    });
    Ok((addr, sender_close))
}
source

pub async fn start_serve( &mut self, receiver_close: Receiver<()>, sender_close: Option<Sender<()>> ) -> ProxyResult<()>

source

pub fn clear_close_servers(&mut self)

source

pub async fn server_new_http( &mut self, stream: TcpStream, addr: SocketAddr ) -> ProxyResult<()>

source

pub async fn server_new_https( &mut self, stream: TcpStream, addr: SocketAddr, accept: TlsAcceptor ) -> ProxyResult<()>

source

pub async fn server_new_tcp( &mut self, stream: TcpStream, _addr: SocketAddr ) -> ProxyResult<()>

source

pub async fn server_new_proxy( &mut self, stream: TcpStream, _addr: SocketAddr ) -> ProxyResult<()>

Auto Trait Implementations§

§

impl !RefUnwindSafe for WMCore

§

impl Send for WMCore

§

impl Sync for WMCore

§

impl Unpin for WMCore

§

impl !UnwindSafe for WMCore

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> UnsafeAny for T
where T: Any,