# antoniomika/sish architecture

> Architecture diagram of the GitHub repository antoniomika/sish, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/antoniomika/sish
- Repository: https://github.com/antoniomika/sish

## Overview

##### Main Components Identification

a. SSH Multiplexer (sshmuxer/)
- Core SSH server functionality
- Channel handling
- Request processing
- TCP forwarding
- HTTP(S) handling
- Alias management

b. HTTP Multiplexer (httpmuxer/)
- HTTP proxy functionality
- HTTPS handling
- General HTTP multiplexing

c. Utils Layer (utils/)
- Authentication handling
- Connection management
- Console operations
- State management

**┌─────────────────────────────────────────────┐**
- Client Layer                 │
- (SSH Clients, HTTP Clients, Local Services) │
- ┬─────────────────────────────┘

**┌───────────────▼─────────────────────────────┐**
- sish Service                     │
- ┬───────────────────────┤
- SSH Multiplexer  │   HTTP Multiplexer    │
- (Port 2222)      │   (Port 80/443)       │
- ┴───────────────────────┤
- Authentication Layer               │
- (Public Key Authentication)          │
- ┤
- Utils Layer                    │
- (State Management, Console, Connections)   │
- ┘

##### Important Details to Highlight

a. Configuration Elements:
- Domain handling (--domain flag)
- HTTP address binding (--http-address flag)
- SSL/TLS termination

b. Security Boundaries:
- Public internet facing components
- Internal routing mechanisms
- Authentication checkpoints

##### Implementation Notes

- The separation between SSH and HTTP handling
- How local services are exposed through the tunnel
- The role of the multiplexer in managing multiple connections
- Configuration options and their impact on the architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        SSH["SSH Clients"]
        HTTP["HTTP Clients"]
        Local["Local Services"]
    end

    subgraph Core["sish Service"]
        subgraph Multiplexers["Multiplexing Layer"]
            SSHMux["SSH Multiplexer<br/>(Port 2222)"]:::ssh
            HTTPMux["HTTP Multiplexer<br/>(Port 80/443)"]:::http
        end

        subgraph Auth["Authentication Layer"]
            PubKey["Public Key<br/>Authentication"]:::auth
            KeyStore["Key Storage"]:::auth
        end

        subgraph Utils["Utils Layer"]
            ConnMgr["Connection<br/>Manager"]:::util
            StateMgr["State<br/>Manager"]:::util
            Console["Console<br/>Operations"]:::util
        end

        subgraph Config["Configuration"]
            SSL["SSL/TLS<br/>Certificates"]:::config
            Templates["Web Interface<br/>Templates"]:::config
            ConfigFile["Configuration<br/>File"]:::config
        end
    end

    %% Connections
    SSH --> SSHMux
    HTTP --> HTTPMux
    Local --> SSHMux

    SSHMux <--> HTTPMux
    SSHMux --> PubKey
    HTTPMux --> PubKey

    PubKey --> KeyStore
    PubKey --> ConnMgr

    SSHMux --> ConnMgr
    HTTPMux --> ConnMgr
    ConnMgr --> StateMgr
    StateMgr --> Console

    HTTPMux --> SSL
    Console --> Templates
    Core --> ConfigFile

    %% Click Events
    click SSHMux "https://github.com/antoniomika/sish/blob/main/sshmuxer/sshmuxer.go"
    click HTTPMux "https://github.com/antoniomika/sish/blob/main/httpmuxer/httpmuxer.go"
    click PubKey "https://github.com/antoniomika/sish/blob/main/utils/authentication_key_request_test.go"
    click KeyStore "https://github.com/antoniomika/sish/tree/main/deploy/pubkeys"
    click ConnMgr "https://github.com/antoniomika/sish/blob/main/utils/conn.go"
    click StateMgr "https://github.com/antoniomika/sish/blob/main/utils/state.go"
    click Console "https://github.com/antoniomika/sish/blob/main/utils/console.go"
    click SSL "https://github.com/antoniomika/sish/tree/main/deploy/ssl"
    click Templates "https://github.com/antoniomika/sish/tree/main/templates"
    click ConfigFile "https://github.com/antoniomika/sish/blob/main/config.example.yml"

    %% Styles
    classDef ssh fill:#2374ab
    classDef http fill:#48a9a6
    classDef auth fill:#e4cc37
    classDef util fill:#d3d3d3
    classDef config fill:#e57a44

    %% Legend
    subgraph Legend
        SSH_L["SSH Components"]:::ssh
        HTTP_L["HTTP Components"]:::http
        Auth_L["Authentication"]:::auth
        Util_L["Utilities"]:::util
        Config_L["Configuration"]:::config
    end
```
