banger/internal/api/types.go
Thales Maciel c298ed2fc1
Add vsock-backed VM port inspection
Let the host ask the guest vsock agent to run ss so open ports can be surfaced without SSHing in manually.

Add a narrow /ports agent endpoint, a daemon vm.ports RPC that enriches listeners with <hostname>.vm endpoints and best-effort HTTP links, and a concurrent 'banger vm ports' CLI table for one or more VMs.

Update the guest package contract to include ss for rebuilt Debian images, allow the guest agent package in the shell-out policy, and cover the new parsing/RPC/CLI flow in tests.

Verified with GOCACHE=/tmp/banger-gocache go test ./... outside the sandbox, make build, bash -n customize.sh make-rootfs-void.sh verify.sh, and ./banger vm ports --help.
2026-03-19 15:52:11 -03:00

124 lines
3.2 KiB
Go

package api
import "banger/internal/model"
type Empty struct{}
type PingResult struct {
Status string `json:"status"`
PID int `json:"pid"`
}
type ShutdownResult struct {
Status string `json:"status"`
}
type VMCreateParams struct {
Name string `json:"name,omitempty"`
ImageName string `json:"image_name,omitempty"`
VCPUCount *int `json:"vcpu_count,omitempty"`
MemoryMiB *int `json:"memory_mib,omitempty"`
SystemOverlaySize string `json:"system_overlay_size,omitempty"`
WorkDiskSize string `json:"work_disk_size,omitempty"`
NATEnabled bool `json:"nat_enabled,omitempty"`
NoStart bool `json:"no_start,omitempty"`
}
type VMRefParams struct {
IDOrName string `json:"id_or_name"`
}
type VMKillParams struct {
IDOrName string `json:"id_or_name"`
Signal string `json:"signal,omitempty"`
}
type VMSetParams struct {
IDOrName string `json:"id_or_name"`
VCPUCount *int `json:"vcpu_count,omitempty"`
MemoryMiB *int `json:"memory_mib,omitempty"`
WorkDiskSize string `json:"work_disk_size,omitempty"`
NATEnabled *bool `json:"nat_enabled,omitempty"`
}
type VMListResult struct {
VMs []model.VMRecord `json:"vms"`
}
type VMShowResult struct {
VM model.VMRecord `json:"vm"`
}
type VMStatsResult struct {
VM model.VMRecord `json:"vm"`
Stats model.VMStats `json:"stats"`
}
type VMLogsResult struct {
LogPath string `json:"log_path"`
}
type VMSSHResult struct {
Name string `json:"name"`
GuestIP string `json:"guest_ip"`
}
type VMHealthResult struct {
Name string `json:"name"`
Healthy bool `json:"healthy"`
}
type VMPingResult struct {
Name string `json:"name"`
Alive bool `json:"alive"`
}
type VMPort struct {
Proto string `json:"proto"`
BindAddress string `json:"bind_address,omitempty"`
Port int `json:"port"`
PID int `json:"pid,omitempty"`
Process string `json:"process,omitempty"`
Command string `json:"command,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
WebURL string `json:"web_url,omitempty"`
}
type VMPortsResult struct {
Name string `json:"name"`
DNSName string `json:"dns_name,omitempty"`
Ports []VMPort `json:"ports"`
}
type ImageBuildParams struct {
Name string `json:"name,omitempty"`
BaseRootfs string `json:"base_rootfs,omitempty"`
Size string `json:"size,omitempty"`
KernelPath string `json:"kernel_path,omitempty"`
InitrdPath string `json:"initrd_path,omitempty"`
ModulesDir string `json:"modules_dir,omitempty"`
Docker bool `json:"docker,omitempty"`
}
type ImageRegisterParams struct {
Name string `json:"name,omitempty"`
RootfsPath string `json:"rootfs_path,omitempty"`
WorkSeedPath string `json:"work_seed_path,omitempty"`
KernelPath string `json:"kernel_path,omitempty"`
InitrdPath string `json:"initrd_path,omitempty"`
ModulesDir string `json:"modules_dir,omitempty"`
PackagesPath string `json:"packages_path,omitempty"`
Docker bool `json:"docker,omitempty"`
}
type ImageRefParams struct {
IDOrName string `json:"id_or_name"`
}
type ImageListResult struct {
Images []model.Image `json:"images"`
}
type ImageShowResult struct {
Image model.Image `json:"image"`
}