diff --git a/pkg/config/config.go b/pkg/config/config.go index 9374074..eef6d4a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -19,6 +19,8 @@ import ( "gopkg.in/yaml.v3" ) +const DefaultWebUIListenAddress = ":8080" + type Install struct { Auto bool `yaml:"auto,omitempty"` Reboot bool `yaml:"reboot,omitempty"` diff --git a/pkg/machine/network.go b/pkg/machine/network.go new file mode 100644 index 0000000..377a674 --- /dev/null +++ b/pkg/machine/network.go @@ -0,0 +1,44 @@ +package machine + +import ( + "net" +) + +func Interfaces() (in []string) { + ifaces, err := net.Interfaces() + if err != nil { + return + } + for _, i := range ifaces { + if i.Flags == net.FlagLoopback { + continue + } + in = append(in, i.Name) + } + return +} + +func LocalIPs() (ips []string) { + ifaces, err := net.Interfaces() + if err != nil { + return + } + for _, i := range ifaces { + if i.Flags == net.FlagLoopback { + continue + } + addrs, err := i.Addrs() + if err != nil { + continue + } + for _, a := range addrs { + ip, _, err := net.ParseCIDR(a.String()) + if err != nil { + continue + } + + ips = append(ips, ip.String()) + } + } + return +}