whosthere

repository·main·Indexed 23 days ago

https://github.com/ramonvermeulen/whosthere

A Local Area Network (LAN) discovery tool featuring an interactive Terminal User Interface (TUI). It identifies devices using mDNS, SSDP, and ARP cache sweeps without requiring elevated privileges. The tool supports a CLI for single scans, a daemon mode with an HTTP API for centralized device data, and a configurable TUI with regex search and port scanning capabilities.

Tokens
2.4K
Snippets
7
Records
22
Agent score
81%

What's inside whosthere

  1. Configure TUI Themes

    main

    Themes can be set via the configuration file or at runtime using CTRL+t.

    • Set theme.name to a built-in theme name.
    • Set theme.name to custom to use manual color overrides (e.g., primitive_background_color, border_color, etc.).
    • If theme.enabled is false, the TUI uses the terminal's default ANSI colors.
    • The NO_COLOR environment variable will disable all ANSI colors.
    theme:
      enabled: true
      name: cyberpunk
  2. Install Whosthere

    main

    You can install Whosthere using various package managers depending on your operating system or build it from source using Go.

    # Homebrew
    brew install whosthere
    
    # NixOS
    nix profile install nixpkgs#whosthere
    
    # Arch Linux
    yay -S whosthere-bin
    
    # Go
    go install github.com/ramonvermeulen/whosthere@latest
    
    # Build from source
    git clone https://github.com/ramonvermeulen/whosthere.git
    cd whosthere
    make build
  3. Use the whosthere CLI

    main

    Whosthere is a Local Area Network (LAN) discovery tool that provides an interactive Terminal User Interface (TUI) to discover, explore, and understand devices on your network. The CLI follows a standard command structure: whosthere [global flags] <subcommand> [args].

    Available subcommands include:

    • version: Displays the current version of whosthere.
    • daemon: Runs whosthere in daemon mode.
    • scan: Performs a network scan.
  4. Configure Whosthere via YAML file

    main

    Whosthere uses a YAML configuration file for persistent settings. The file is searched in this order:

    1. Path specified via --config flag or WHOSTHERE_CONFIG environment variable.
    2. $XDG_CONFIG_HOME/whosthere/config.yaml.
    3. ~/.config/whosthere/config.yaml (default).

    Example Configuration

    # network_interface: eth0
    
    all_interfaces: false
    
    scan_interval: 20s
    
    scan_timeout: 10s
    
    scanners:
      mdns:
        enabled: true
      ssdp:
        enabled: true
      arp:
        enabled: true
    
    sweeper:
      enabled: true
      interval: 5m
      timeout: 20s
    
    port_scanner:
      timeout: 5s
      tcp: [21, 22, 23, 25, 80, 110, 135, 139, 143, 389, 443, 445, 993, 995, 1433, 1521, 3306, 3389, 5432, 5900, 8080, 8443, 9000, 9090, 9200, 9300, 10000, 27017]
    
    splash:
      enabled: true
      delay: 1s
    
    theme:
      enabled: true
      name: default
  5. Configure Whosthere via Environment Variables

    main

    You can override any YAML configuration option using environment variables with the WHOSTHERE__ prefix. Nested keys are separated by double underscores (__) and are case-insensitive.

    General Environment Variables

    VariableDescription
    WHOSTHERE_CONFIGPath to the configuration file
    WHOSTHERE_LOGSet the log level (debug, info, warn, error). Defaults to info
    NO_COLORDisable ANSI colors in the TUI

    Examples

    • WHOSTHERE__SPLASH__ENABLED=false (equivalent to splash.enabled: false)
    • WHOSTHERE__SCAN_INTERVAL=30s (equivalent to scan_interval: 30s)
    • WHOSTHERE__SCANNERS__MDNS__ENABLED=false (equivalent to scanners.mdns.enabled: false)
    • WHOSTHERE__PORT_SCANNER__TCP=80,443,8080 (equivalent to port_scanner.tcp: [80, 443, 8080])
    • WHOSTHERE__THEME__NAME=cyberpunk (equivalent to theme.name: cyberpunk)
  6. How the App lifecycle and engine management works

    main

    The App manages a discovery.Engine which is responsible for scanning the network.

    Interface Switching

    When a user switches network interfaces, the application performs a coordinated swap:

    1. It acquires a write lock (engineMu) to prevent concurrent device updates.
    2. It cancels the existing engine's context (engineCancel).
    3. It stops the old engine.
    4. It increments an engineGen (generation counter) to invalidate any pending events from the old engine.
    5. It builds and starts a new engine for the selected interface.

    Event Processing

    The handleEngineEvents goroutine listens to the engine's event channel. It uses the generation counter to ensure that if an interface switch occurs, events from the 'old' engine are discarded and do not pollute the state with stale device data.

  7. Troubleshoot Clipboard functionality

    main

    Whosthere requires an external copy tool to support clipboard actions (y and Y in TUI). Ensure the following tools are installed for your OS:

    • Darwin (macOS): pbcopy
    • Windows: clip.exe
    • Linux/FreeBSD/NetBSD/OpenBSD/Dragonfly:
      • X11: xsel or xclip
      • Wayland: wl-copy
  8. Daemon mode HTTP API endpoints

    main

    When running in daemon mode, Whosthere exposes a simple HTTP API for accessing discovered device data.

    | Method | Endpoint | Description |
    | ------ | -------- | ----------- |
    | GET | `/devices` | Get list of all discovered devices |
    | GET | `/device/{ip}` | Get details of a specific device |
    | GET | `/health` | Health check |
  9. Key bindings for the Whosthere TUI

    main

    Use the following keyboard shortcuts to navigate and interact with the TUI:

    KeyAction
    /Start regex search
    kUp
    jDown
    gGo to top
    GGo to bottom
    yCopy IP of selected device
    YCopy MAC of selected device
    enterShow device details
    CTRL+tToggle theme selector
    CTRL+iToggle interface selector
    CTRL+c/qStop application
    ESCClear search / Go back
    p (details view)Start port scan on device
    tab (modal view)Switch button selection