# boronine/h2tunnel architecture

> Architecture diagram of the GitHub repository boronine/h2tunnel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boronine/h2tunnel
- Repository: https://github.com/boronine/h2tunnel

## Overview

##### Main Components

a) Client-side Components:
- Local TCP Server (Origin Server)
- H2Tunnel Client
- TLS Client Connection Handler

b) Server-side Components:
- H2Tunnel Server
- TLS Server Connection Handler
- TCP Proxy Server

##### Data Flow Through HTTP/2 Streams

**Left Side (Client)                    Right Side (Server)**

- Local Server │                      │ TCP Proxy    │

- ↕                                     ↕

- H2T Client   │ ←──── HTTP/2 ─────→ │ H2T Server  │
- Tunnel        ────────────────
- ↕                                     ↕

- TLS Client   │ ←──── TLS ─────────→│ TLS Server  │

D. Important Details to Include:
- Port numbers (tunnel port and proxy port)
- TLS certificate/key authentication
- HTTP/2 stream multiplexing indication
- TCP connection conversion points

##### Technical Specifications to Note

Annotations for:
- Node.js v18+ requirement
- TLS with self-signed certificates
- HTTP/2 multiplexing capability
- TCP protocol conversion points

##### Implementation Notes

Notes about:
- No dependencies requirement
- Less than 500 LOC implementation
- Support for both CLI and library usage
- Authentication mechanism using shared TLS certificates

Remember to include version information and any relevant environment-specific configurations in supplementary documentation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        direction TB
        LocalServer["Local TCP Server"]
        H2TClient["H2Tunnel Client"]:::client
        TLSClient["TLS Client"]
    end

    subgraph Server
        direction TB
        TCPProxy["TCP Proxy Server"]
        H2TServer["H2Tunnel Server"]:::server
        TLSServer["TLS Server"]
    end

    %% Connections
    LocalServer <--> |TCP Connection| H2TClient
    H2TClient <--> |HTTP/2 Tunnel| H2TServer
    TLSClient <--> |TLS Connection| TLSServer
    H2TServer <--> |TCP Connection| TCPProxy

    %% Component Styling
    classDef client fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef connection fill:#FFB366,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[Server Components]:::server
        L3[Connection Types]:::connection
    end

    %% Click Events
    click H2TClient "https://github.com/boronine/h2tunnel/blob/main/src/h2tunnel.ts"
    click H2TServer "https://github.com/boronine/h2tunnel/blob/main/src/h2tunnel.ts"
    click TCPProxy "https://github.com/boronine/h2tunnel/blob/main/src/h2tunnel.ts"

    %% Notes
    note1[Node.js v18+ Required]
    note2[TLS Authentication]
    note3[HTTP/2 Multiplexing]

    %% Styling for notes
    style note1 fill:#f9f,stroke:#333,stroke-width:2px
    style note2 fill:#f9f,stroke:#333,stroke-width:2px
    style note3 fill:#f9f,stroke:#333,stroke-width:2px
```
