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:
parent
67d0e0612a
commit
0d60592b9f
16 changed files with 266 additions and 289 deletions
40
CLAUDE.md
40
CLAUDE.md
|
|
@ -1 +1,39 @@
|
||||||
- This project uses forgejo for source control and the fj client is available.
|
# SkyView Project Guidelines
|
||||||
|
|
||||||
|
## Documentation Requirements
|
||||||
|
- We should always have an up to date document describing our architecture and features
|
||||||
|
- Include links to any external resources we've used
|
||||||
|
- We should also always have an up to date README describing the project
|
||||||
|
- Shell scripts should be validated with shellcheck
|
||||||
|
- Always make sure the code is well documented with explanations for why and how a particular solution is selected
|
||||||
|
|
||||||
|
## Development Principles
|
||||||
|
- An overarching principle with all code is KISS, Keep It Simple Stupid
|
||||||
|
- We do not want to create code that is more complicated than necessary
|
||||||
|
- When changing code, always make sure to update any relevant tests
|
||||||
|
- Use proper error handling - aviation applications need reliability
|
||||||
|
|
||||||
|
## SkyView-Specific Guidelines
|
||||||
|
|
||||||
|
### Architecture & Design
|
||||||
|
- Multi-source ADS-B data fusion is the core feature - prioritize signal strength-based conflict resolution
|
||||||
|
- Embedded resources (SQLite ICAO database, static assets) over external dependencies
|
||||||
|
- Low-latency performance is critical - optimize for fast WebSocket updates
|
||||||
|
- Support concurrent aircraft tracking (100+ aircraft should work smoothly)
|
||||||
|
|
||||||
|
### Code Organization
|
||||||
|
- Keep Go packages focused: beast parsing, modes decoding, merger, server, clients
|
||||||
|
- Frontend should be modular: separate managers for aircraft, map, UI, websockets
|
||||||
|
- Database operations should be fast (use indexes, avoid N+1 queries)
|
||||||
|
|
||||||
|
### Performance Considerations
|
||||||
|
- Beast binary parsing must handle high message rates (1000+ msg/sec per source)
|
||||||
|
- WebSocket broadcasting should not block on slow clients
|
||||||
|
- Memory usage should be bounded (configurable history limits)
|
||||||
|
- CPU usage should remain low during normal operation
|
||||||
|
|
||||||
|
### Documentation Maintenance
|
||||||
|
- Always update docs/ARCHITECTURE.md when changing system design
|
||||||
|
- README.md should stay current with features and usage
|
||||||
|
- External resources (ICAO docs, ADS-B standards) should be linked in documentation
|
||||||
|
- Country database updates should be straightforward (replace SQLite file)
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
// - index.html: Main web interface with aircraft tracking map
|
// - index.html: Main web interface with aircraft tracking map
|
||||||
// - css/style.css: Styling for the web interface
|
// - css/style.css: Styling for the web interface
|
||||||
// - js/app.js: JavaScript client for WebSocket communication and map rendering
|
// - js/app.js: JavaScript client for WebSocket communication and map rendering
|
||||||
// - aircraft-icon.svg: SVG icon for aircraft markers
|
// - icons/*.svg: Type-specific SVG icons for aircraft markers
|
||||||
// - favicon.ico: Browser icon
|
// - favicon.ico: Browser icon
|
||||||
//
|
//
|
||||||
// The embedded filesystem is used by the HTTP server to serve static content
|
// The embedded filesystem is used by the HTTP server to serve static content
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#00a8ff" stroke="#ffffff" stroke-width="1">
|
|
||||||
<path d="M12 2l-2 16 2-2 2 2-2-16z"/>
|
|
||||||
<path d="M4 10l8-2-1 2-7 0z"/>
|
|
||||||
<path d="M20 10l-8-2 1 2 7 0z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 224 B |
Binary file not shown.
|
|
@ -5,11 +5,13 @@
|
||||||
// in human-readable format on the console.
|
// in human-readable format on the console.
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
|
//
|
||||||
// beast-dump -tcp host:port # Read from TCP socket
|
// beast-dump -tcp host:port # Read from TCP socket
|
||||||
// beast-dump -file path/to/file # Read from file
|
// beast-dump -file path/to/file # Read from file
|
||||||
// beast-dump -verbose # Show detailed message parsing
|
// beast-dump -verbose # Show detailed message parsing
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// beast-dump -tcp svovel:30005 # Connect to dump1090 Beast stream
|
// beast-dump -tcp svovel:30005 # Connect to dump1090 Beast stream
|
||||||
// beast-dump -file beast.test # Parse Beast data from file
|
// beast-dump -file beast.test # Parse Beast data from file
|
||||||
// beast-dump -tcp localhost:30005 -verbose # Verbose TCP parsing
|
// beast-dump -tcp localhost:30005 -verbose # Verbose TCP parsing
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"server": {
|
|
||||||
"address": ":8080",
|
|
||||||
"port": 8080
|
|
||||||
},
|
|
||||||
"dump1090": {
|
|
||||||
"host": "192.168.1.100",
|
|
||||||
"data_port": 30003
|
|
||||||
},
|
|
||||||
"origin": {
|
|
||||||
"latitude": 37.7749,
|
|
||||||
"longitude": -122.4194,
|
|
||||||
"name": "San Francisco"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
# SkyView Project Guidelines
|
|
||||||
|
|
||||||
## Documentation Requirements
|
|
||||||
- We should always have an up to date document describing our architecture and features
|
|
||||||
- Include links to any external resources we've used
|
|
||||||
- We should also always have an up to date README describing the project
|
|
||||||
- Shell scripts should be validated with shellcheck
|
|
||||||
- Always make sure the code is well documented with explanations for why and how a particular solution is selected
|
|
||||||
|
|
||||||
## Development Principles
|
|
||||||
- An overarching principle with all code is KISS, Keep It Simple Stupid
|
|
||||||
- We do not want to create code that is more complicated than necessary
|
|
||||||
- When changing code, always make sure to update any relevant tests
|
|
||||||
- Use proper error handling - aviation applications need reliability
|
|
||||||
|
|
||||||
## SkyView-Specific Guidelines
|
|
||||||
|
|
||||||
### Architecture & Design
|
|
||||||
- Multi-source ADS-B data fusion is the core feature - prioritize signal strength-based conflict resolution
|
|
||||||
- Embedded resources (SQLite ICAO database, static assets) over external dependencies
|
|
||||||
- Low-latency performance is critical - optimize for fast WebSocket updates
|
|
||||||
- Support concurrent aircraft tracking (100+ aircraft should work smoothly)
|
|
||||||
|
|
||||||
### Code Organization
|
|
||||||
- Keep Go packages focused: beast parsing, modes decoding, merger, server, clients
|
|
||||||
- Frontend should be modular: separate managers for aircraft, map, UI, websockets
|
|
||||||
- Database operations should be fast (use indexes, avoid N+1 queries)
|
|
||||||
|
|
||||||
### Performance Considerations
|
|
||||||
- Beast binary parsing must handle high message rates (1000+ msg/sec per source)
|
|
||||||
- WebSocket broadcasting should not block on slow clients
|
|
||||||
- Memory usage should be bounded (configurable history limits)
|
|
||||||
- CPU usage should remain low during normal operation
|
|
||||||
|
|
||||||
### Documentation Maintenance
|
|
||||||
- Always update docs/ARCHITECTURE.md when changing system design
|
|
||||||
- README.md should stay current with features and usage
|
|
||||||
- External resources (ICAO docs, ADS-B standards) should be linked in documentation
|
|
||||||
- Country database updates should be straightforward (replace SQLite file)
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -51,6 +52,7 @@ type OriginConfig struct {
|
||||||
// - Concurrent broadcast system for WebSocket clients
|
// - Concurrent broadcast system for WebSocket clients
|
||||||
// - CORS support for cross-origin web applications
|
// - CORS support for cross-origin web applications
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
host string // Bind address for HTTP server
|
||||||
port int // TCP port for HTTP server
|
port int // TCP port for HTTP server
|
||||||
merger *merger.Merger // Data source for aircraft information
|
merger *merger.Merger // Data source for aircraft information
|
||||||
staticFiles embed.FS // Embedded static web assets
|
staticFiles embed.FS // Embedded static web assets
|
||||||
|
|
@ -85,7 +87,7 @@ type AircraftUpdate struct {
|
||||||
Stats map[string]interface{} `json:"stats"` // System statistics and metrics
|
Stats map[string]interface{} `json:"stats"` // System statistics and metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a new HTTP server instance for serving the SkyView web interface.
|
// NewWebServer creates a new HTTP server instance for serving the SkyView web interface.
|
||||||
//
|
//
|
||||||
// The server is configured with:
|
// The server is configured with:
|
||||||
// - WebSocket upgrader allowing all origins (suitable for development)
|
// - WebSocket upgrader allowing all origins (suitable for development)
|
||||||
|
|
@ -93,14 +95,16 @@ type AircraftUpdate struct {
|
||||||
// - Read/Write buffers optimized for aircraft data messages
|
// - Read/Write buffers optimized for aircraft data messages
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
|
// - host: Bind address (empty for all interfaces, "localhost" for local only)
|
||||||
// - port: TCP port number for the HTTP server
|
// - port: TCP port number for the HTTP server
|
||||||
// - merger: Data merger instance providing aircraft information
|
// - merger: Data merger instance providing aircraft information
|
||||||
// - staticFiles: Embedded filesystem containing web assets
|
// - staticFiles: Embedded filesystem containing web assets
|
||||||
// - origin: Geographic reference point for the map interface
|
// - origin: Geographic reference point for the map interface
|
||||||
//
|
//
|
||||||
// Returns a configured but not yet started server instance.
|
// Returns a configured but not yet started server instance.
|
||||||
func NewServer(port int, merger *merger.Merger, staticFiles embed.FS, origin OriginConfig) *Server {
|
func NewWebServer(host string, port int, merger *merger.Merger, staticFiles embed.FS, origin OriginConfig) *Server {
|
||||||
return &Server{
|
return &Server{
|
||||||
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
merger: merger,
|
merger: merger,
|
||||||
staticFiles: staticFiles,
|
staticFiles: staticFiles,
|
||||||
|
|
@ -139,8 +143,15 @@ func (s *Server) Start() error {
|
||||||
// Setup routes
|
// Setup routes
|
||||||
router := s.setupRoutes()
|
router := s.setupRoutes()
|
||||||
|
|
||||||
|
// Format address correctly for IPv6
|
||||||
|
addr := fmt.Sprintf("%s:%d", s.host, s.port)
|
||||||
|
if strings.Contains(s.host, ":") {
|
||||||
|
// IPv6 address needs brackets
|
||||||
|
addr = fmt.Sprintf("[%s]:%d", s.host, s.port)
|
||||||
|
}
|
||||||
|
|
||||||
s.server = &http.Server{
|
s.server = &http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", s.port),
|
Addr: addr,
|
||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
main
BIN
main
Binary file not shown.
15
old.json
15
old.json
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"server": {
|
|
||||||
"address": ":8080",
|
|
||||||
"port": 8080
|
|
||||||
},
|
|
||||||
"dump1090": {
|
|
||||||
"host": "svovel",
|
|
||||||
"data_port": 30003
|
|
||||||
},
|
|
||||||
"origin": {
|
|
||||||
"latitude": 59.908127,
|
|
||||||
"longitude": 10.801460,
|
|
||||||
"name": "Etterstadsletta flyplass"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BIN
ux.png
BIN
ux.png
Binary file not shown.
|
Before Width: | Height: | Size: 102 KiB |
Loading…
Add table
Add a link
Reference in a new issue