mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-10 06:52:00 +00:00
style: Extract UI constants and refactor main view rendering (#30)
- [x] Add golangci-lint configuration with gocritic ifElseChain disabled
- [x] Rename error variables to avoid shadowing (createErr, watcherErr, watchErr, etc.)
- [x] Replace `interface{}` with `any` type alias throughout codebase
- [x] Add package-level documentation comments to all internal packages
- [x] Reorder struct fields alphabetically for consistency
- [x] Extract UI constants (terminal dimensions, column widths, colors) to constants.go
- [x] Refactor BubbleTeaUI main view rendering into smaller helper functions
- [x] Simplify nested conditionals and improve code clarity
- [x] Add `isForwardDisabled()` helper method to BubbleTeaUI
- [x] Update file permissions from 0644 to 0600 in config tests
- [x] Add `#nosec` comments and error suppression where appropriate
- [x] Improve test table struct field ordering for readability
- [x] Fix resource parsing in AddForward using strings.SplitN
- [x] Add comprehensive tests for new UI helper functions and constants
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
// Package mdns provides multicast DNS (mDNS/Bonjour) hostname publishing
|
||||
// for port forwards. When enabled, forwards with aliases can be accessed
|
||||
// via <alias>.local hostnames on the local network.
|
||||
//
|
||||
// The Publisher manages mDNS service registrations using zeroconf:
|
||||
// - Registers hostnames when forwards become active
|
||||
// - Unregisters hostnames when forwards are stopped
|
||||
// - Provides service discovery via the _kportal._tcp service type
|
||||
//
|
||||
// mDNS discovery commands:
|
||||
//
|
||||
// dns-sd -B _kportal._tcp local # macOS
|
||||
// avahi-browse -t _kportal._tcp # Linux
|
||||
package mdns
|
||||
|
||||
import (
|
||||
@@ -23,11 +36,11 @@ const (
|
||||
// Publisher manages mDNS hostname registrations for port forwards.
|
||||
// It allows forwards with aliases to be accessible via <alias>.local hostnames.
|
||||
type Publisher struct {
|
||||
mu sync.RWMutex
|
||||
servers map[string]*zeroconf.Server // forwardID -> server
|
||||
aliases map[string]string // forwardID -> alias (for logging)
|
||||
enabled bool
|
||||
servers map[string]*zeroconf.Server
|
||||
aliases map[string]string
|
||||
localIPs []string
|
||||
mu sync.RWMutex
|
||||
enabled bool
|
||||
}
|
||||
|
||||
// NewPublisher creates a new mDNS Publisher.
|
||||
|
||||
Reference in New Issue
Block a user