ReverseIt.WebSocketProxy (ReverseIt v0.2.0)

Copy Markdown View Source

WebSocket proxy handler implementing the WebSock behavior. Maintains bidirectional connection between client and backend.

Summary

Functions

Handles control frames from the client.

Handles incoming frames from the client and forwards them to the backend.

Handles messages from the backend connection.

Initializes the WebSocket proxy connection.

Cleanup when connection terminates.

Types

t()

@type t() :: %ReverseIt.WebSocketProxy{
  backend_upgrade_timer: reference() | nil,
  client: map(),
  config: ReverseIt.Config.t(),
  conn: Mint.HTTP.t(),
  pending_bytes: non_neg_integer(),
  pending_frames: [Mint.WebSocket.frame()],
  request_ref: Mint.Types.request_ref(),
  websocket: Mint.WebSocket.t()
}

Functions

handle_control(arg, state)

Handles control frames from the client.

handle_in(arg, state)

Handles incoming frames from the client and forwards them to the backend.

handle_info(message, state)

Handles messages from the backend connection.

init(opts)

Initializes the WebSocket proxy connection.

The state contains:

  • config: Backend configuration
  • client_headers: Original client headers for forwarding

terminate(reason, state)

Cleanup when connection terminates.