GetInterfaces, GetBridgeMTU

This commit is contained in:
yo 2022-06-26 20:02:22 +02:00
parent 0f6b7b8b80
commit 2a8836721c

View File

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