client

package
v0.0.0-...-18e49d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package client implements the Hush protocol client. Supports both QUIC (hush://) and TCP (tcps://) transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Hush protocol client.

func Dial

func Dial(ctx context.Context, addr string, key *session.APIKey, opts ...Option) (*Client, error)

Dial creates a new Hush client and establishes a session. addr may be "host:port" or "hush://host:port" (QUIC) or "tcps://host:port" (TCP).

By default uses QUIC transport. Use DialTCP or WithTransport(TransportTCP) for TCP.

func DialTCP

func DialTCP(ctx context.Context, addr string, key *session.APIKey, opts ...Option) (*Client, error)

DialTCP creates a client over TLS-over-TCP (useful behind Cloudflare).

client, err := client.DialTCP(ctx, "api.myserver.com:8443", key)

func (*Client) Close

func (c *Client) Close() error

Close closes the client connection.

func (*Client) Do

func (c *Client) Do(ctx context.Context, opcode uint16, payload *tlv.Map) (*frame.Response, error)

Do sends a request and returns the response.

func (*Client) SessionID

func (c *Client) SessionID() uint64

SessionID returns the current session ID.

type Option

type Option func(*Client)

Option configures the client.

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) Option

WithTLSConfig sets a custom TLS config.

func WithTransport

func WithTransport(mode TransportMode) Option

WithTransport sets the transport mode (QUIC or TCP).

type TransportMode

type TransportMode int

TransportMode selects the underlying transport.

const (
	// TransportQUIC uses QUIC over UDP (default). Fast, multiplexed.
	TransportQUIC TransportMode = iota
	// TransportTCP uses TLS over TCP. Compatible with Cloudflare.
	TransportTCP
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL