seedling: Webui enhancements (#620)

* 🌱 Make sure webui starts on alpine

Also drop to shell when there are no providers

Signed-off-by: mudler <mudler@c3os.io>

* 🌱 Suppress verbose logging on tty

Signed-off-by: mudler <mudler@c3os.io>

* 🌱 Print WebUI address

Signed-off-by: mudler <mudler@c3os.io>

* 🎨 Update banner

Signed-off-by: mudler <mudler@c3os.io>

* 🌱 Refactor, display also interfaces

Signed-off-by: mudler <mudler@c3os.io>

* 🌱 Address feedback from review

Signed-off-by: mudler <mudler@c3os.io>

Signed-off-by: mudler <mudler@c3os.io>
This commit is contained in:
Ettore Di Giacinto
2023-01-08 21:49:23 +01:00
committed by Itxaka
parent e15014addc
commit cffbc3f35f
2 changed files with 46 additions and 0 deletions

View File

@@ -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"`

44
pkg/machine/network.go Normal file
View File

@@ -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
}