Skip to main content

GoutClient

Struct GoutClient 

Source
pub struct GoutClient { /* private fields */ }
Expand description

隧道操作客户端。

使用服务端分配的普通 api-key(非 admin key)进行认证。 客户端实例持有 HTTP 连接池,建议复用。

§示例

use gout_api::client::GoutClient;
use gout_api::TunnelType;

let gout = GoutClient::new("server.example.com:8080", "sk-your-key");
let tunnel = gout.create_tunnel(TunnelType::Tcp, 4000).await.unwrap();
gout.delete_tunnel(tunnel.token).await.unwrap();

Implementations§

Source§

impl GoutClient

Source

pub fn new(server_addr: &str, api_key: &str) -> Self

创建一个新的 GoutClient

§参数
  • server_addr — 服务端地址,host:port 格式,如 "example.com:8080"
  • api_key — 普通隧道 API key
Source

pub async fn create_tunnel( &self, tunnel_type: TunnelType, local_port: u16, ) -> Result<TunnelResponse>

创建一个新隧道。

返回 TunnelResponse,调用方据此建立数据通道连接。 数据通道的握手和 pipe 由 data_channel 模块提供。

§参数
  • tunnel_type — 隧道协议类型(TCP / UDP / HTTP)
  • local_port — 本地服务端口号
Source

pub async fn list_tunnels(&self) -> Result<Vec<TunnelListEntry>>

列出所有活跃隧道。

返回当前服务端上状态为 “waiting” 或 “active” 的隧道列表。 已关闭或已过期的隧道不会出现在列表中。

Source

pub async fn delete_tunnel(&self, token: u64) -> Result<()>

删除指定 token 的隧道。

服务端会关闭对应的公网端口监听并清理所有相关资源。

Source

pub fn server_addr(&self) -> &str

获取服务端地址(不含 http:// 前缀)。

Source

pub fn api_key(&self) -> &str

获取当前客户端使用的 API key。

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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