Clean up codebase and fix server host binding for IPv6 support

Cleanup:
- Remove unused aircraft-icon.svg (replaced by type-specific icons)
- Remove test files: beast-dump-with-heli.bin, beast.test, main, old.json, ux.png
- Remove duplicate config.json.example (kept config.example.json)
- Remove empty internal/coverage/ directory
- Move CLAUDE.md to project root
- Update assets.go documentation to reflect current icon structure
- Format all Go code with gofmt

Server Host Binding Fix:
- Fix critical bug where server host configuration was ignored
- Add host parameter to Server struct and NewWebServer constructor
- Rename NewServer to NewWebServer for better clarity
- Fix IPv6 address formatting in server binding (wrap in brackets)
- Update startup message to show correct bind address format
- Support localhost-only, IPv4, IPv6, and interface-specific binding

This resolves the "too many colons in address" error for IPv6 hosts like ::1
and enables proper localhost-only deployment as configured.

Closes #15

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-24 18:36:14 +02:00
commit 0d60592b9f
16 changed files with 266 additions and 289 deletions

View file

@ -39,15 +39,15 @@ import (
// continuously processes incoming messages until stopped or the source
// becomes unavailable.
type BeastClient struct {
source *merger.Source // Source configuration and status
merger *merger.Merger // Data merger for multi-source fusion
decoder *modes.Decoder // Mode S/ADS-B message decoder
conn net.Conn // TCP connection to Beast source
parser *beast.Parser // Beast format message parser
source *merger.Source // Source configuration and status
merger *merger.Merger // Data merger for multi-source fusion
decoder *modes.Decoder // Mode S/ADS-B message decoder
conn net.Conn // TCP connection to Beast source
parser *beast.Parser // Beast format message parser
msgChan chan *beast.Message // Buffered channel for parsed messages
errChan chan error // Error reporting channel
stopChan chan struct{} // Shutdown signal channel
wg sync.WaitGroup // Wait group for goroutine coordination
errChan chan error // Error reporting channel
stopChan chan struct{} // Shutdown signal channel
wg sync.WaitGroup // Wait group for goroutine coordination
// Reconnection parameters
reconnectDelay time.Duration // Initial reconnect delay
@ -102,9 +102,9 @@ func (c *BeastClient) Start(ctx context.Context) {
// Stop gracefully shuts down the client and all associated goroutines.
//
// The shutdown process:
// 1. Signals all goroutines to stop via stopChan
// 2. Closes the TCP connection if active
// 3. Waits for all goroutines to complete
// 1. Signals all goroutines to stop via stopChan
// 2. Closes the TCP connection if active
// 3. Waits for all goroutines to complete
//
// This method blocks until the shutdown is complete.
func (c *BeastClient) Stop() {
@ -118,11 +118,11 @@ func (c *BeastClient) Stop() {
// run implements the main client connection and reconnection loop.
//
// This method handles the complete client lifecycle:
// 1. Connection establishment with timeout
// 2. Exponential backoff on connection failures
// 3. Message parsing and processing goroutine management
// 4. Connection monitoring and failure detection
// 5. Automatic reconnection on disconnection
// 1. Connection establishment with timeout
// 2. Exponential backoff on connection failures
// 3. Message parsing and processing goroutine management
// 4. Connection monitoring and failure detection
// 5. Automatic reconnection on disconnection
//
// The exponential backoff starts at reconnectDelay (5s) and doubles on each
// failure up to maxReconnect (60s), then resets on successful connection.
@ -210,10 +210,10 @@ func (c *BeastClient) readMessages() {
// processMessages runs in a dedicated goroutine to decode and merge aircraft data.
//
// For each received Beast message, this method:
// 1. Decodes the Mode S/ADS-B message payload
// 2. Extracts aircraft information (position, altitude, speed, etc.)
// 3. Updates the data merger with new aircraft state
// 4. Updates source statistics (message count)
// 1. Decodes the Mode S/ADS-B message payload
// 2. Extracts aircraft information (position, altitude, speed, etc.)
// 3. Updates the data merger with new aircraft state
// 4. Updates source statistics (message count)
//
// Invalid or unparseable messages are silently discarded to maintain
// system stability. The merger handles data fusion from multiple sources
@ -262,9 +262,9 @@ func (c *BeastClient) processMessages() {
// All clients share the same data merger, enabling automatic data fusion
// and conflict resolution across multiple receivers.
type MultiSourceClient struct {
clients []*BeastClient // Managed Beast clients
merger *merger.Merger // Shared data merger for all sources
mu sync.RWMutex // Protects clients slice
clients []*BeastClient // Managed Beast clients
merger *merger.Merger // Shared data merger for all sources
mu sync.RWMutex // Protects clients slice
}
// NewMultiSourceClient creates a client manager for multiple Beast format sources.
@ -292,9 +292,9 @@ func NewMultiSourceClient(merger *merger.Merger) *MultiSourceClient {
// AddSource registers and configures a new Beast format data source.
//
// This method:
// 1. Registers the source with the data merger
// 2. Creates a new BeastClient for the source
// 3. Adds the client to the managed clients list
// 1. Registers the source with the data merger
// 2. Creates a new BeastClient for the source
// 3. Adds the client to the managed clients list
//
// The source is not automatically started; call Start() to begin connections.
// Sources can be added before or after starting the multi-source client.