Class: QuietQUIC::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/quietquic/client.rb

Overview

Dial a cloaked QUIC server.

Build a connection with Client.connect (from a client id + PSK + server address) or Client.connect_toml (from a client config file). Both parse and validate the config synchronously (raising ConfigError on a bad address or PSK), then await the native connect on the shared runtime.

The underlying crate connect has its own internal handshake timeout (about 10 seconds); a server that never responds surfaces as ConnectError, same as any other failed dial.

Class Method Summary collapse

Class Method Details

.connect(client_id:, psk:, server:) ⇒ Connection

Dial a server from this client's identity, PSK, and the server address.

Parameters:

  • client_id (String)

    this client's id (must be authorized by the server).

  • psk (String)

    the shared PSK, 64 hex chars (32 bytes).

  • server (String)

    the server's "ip:port" to dial.

Returns:

Raises:

  • (QuietQUIC::ConfigError)

    on a bad address or PSK.

  • (QuietQUIC::ConnectError)

    if the connect fails or times out.



24
25
26
27
# File 'lib/quietquic/client.rb', line 24

def self.connect(client_id:, psk:, server:)
  handle = Native.client_config_from_parts(client_id, psk, server)
  Connection.new(QuietQUIC.await(Native::Client.connect(handle)))
end

.connect_toml(path) ⇒ Connection

Dial a server using a client config TOML file.

Parameters:

  • path (String)

    path to the client config TOML.

Returns:

Raises:

  • (QuietQUIC::ConfigError)

    if the file is missing or invalid.

  • (QuietQUIC::ConnectError)

    if the connect fails or times out.



35
36
37
38
# File 'lib/quietquic/client.rb', line 35

def self.connect_toml(path)
  handle = Native.client_config_from_toml(path)
  Connection.new(QuietQUIC.await(Native::Client.connect(handle)))
end