tui

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cidr string, initialSplit int) error

Run starts the TUI. Optional initialSplit parameter specifies initial split depth (0 means no initial split).

Types

type ExportNode

type ExportNode struct {
	CIDR          string        `json:"cidr"`
	FirstIP       string        `json:"firstIP"`
	LastIP        string        `json:"lastIP"`
	BroadcastAddr string        `json:"broadcastAddr"`
	SubnetMask    string        `json:"subnetMask"`
	Hosts         uint          `json:"hosts"`
	Children      []*ExportNode `json:"children,omitempty"`
}

ExportNode is a JSON-serializable representation of a subnet.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the Bubble Tea model for the TUI.

func NewModel

func NewModel(cidr string, targetBits int) (Model, error)

NewModel creates a new TUI model from a CIDR string. Optional targetBits parameter specifies initial split depth (0 means no initial split).

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

type SubnetNode

type SubnetNode struct {
	CIDR          netip.Prefix
	FirstIP       netip.Addr
	LastIP        netip.Addr
	BroadcastAddr netip.Addr
	SubnetMask    netip.Addr
	Hosts         uint
	Parent        *SubnetNode
	Children      []*SubnetNode
	IsSplit       bool
}

SubnetNode represents a node in the subnet tree.

func (*SubnetNode) ExportJSON

func (n *SubnetNode) ExportJSON() (string, error)

ExportJSON returns the tree as a JSON string.

func (*SubnetNode) Join

func (n *SubnetNode) Join() bool

Join merges the children back into the parent.

func (*SubnetNode) Split

func (n *SubnetNode) Split() bool

Split splits a subnet node into two children.

func (*SubnetNode) SplitToDepth

func (n *SubnetNode) SplitToDepth(targetBits int)

SplitToDepth recursively splits the subnet until reaching the target bit depth.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL