From 2a8836721c264b086f6de8177b4e44edf3069f6b Mon Sep 17 00:00:00 2001 From: yo Date: Sun, 26 Jun 2022 20:02:22 +0200 Subject: [PATCH] GetInterfaces, GetBridgeMTU --- cmd/jailhost.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/cmd/jailhost.go b/cmd/jailhost.go index 273168a..c7ed273 100644 --- a/cmd/jailhost.go +++ b/cmd/jailhost.go @@ -108,6 +108,35 @@ func (jh *JailHost) GetDefaultGateway6() string { return jh.default_gateway6 } +/***************************************************************************** + * Get all network interfaces + ****************************************************************************/ +func (jh *JailHost) GetInterfaces() ([]string, error) { + var names []string + + interfaces, err := net.Interfaces() + if err != nil { + return names, fmt.Errorf("Error listing network interfaces: %v", err) + } + for _, n := range interfaces { + names = append(names, n.Name) + } + + return names, nil +} + +func (jh *JailHost) GetBridgeMTU(bridgeName string) (int, error) { + bridge, err := net.InterfaceByName(bridgeName) + if err != nil { + return 0, err + } + + return bridge.MTU, nil +} + +/***************************************************************************** + * Get all IPv4 currently in use on host + ****************************************************************************/ func getHostInUseIPv4() ([]string, error) { var ips []string