From 04bbde74ad96644ad5cfff22c8c10a5f01b5c8eb Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 17 Apr 2021 19:56:27 +0200 Subject: [PATCH] added mtu --- ipconfig.go | 6 ------ network.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ipconfig.go b/ipconfig.go index 6e77195..19d4be4 100644 --- a/ipconfig.go +++ b/ipconfig.go @@ -36,7 +36,6 @@ type IPConfig struct { IPv4Gateway string IPv6CIDR string IPv6Gateway string - MTU string } func (c *IPConfig) String() string { @@ -53,9 +52,6 @@ func (c *IPConfig) String() string { str = append(str, "gw6="+c.IPv6Gateway) } } - if c.MTU != "" { - str = append(str, "mtu="+c.MTU) - } return strings.Join(str, ",") } @@ -79,8 +75,6 @@ func parseIPConfig(s string) (c *IPConfig) { c.IPv6CIDR = v[1] case "gw6": c.IPv6Gateway = v[1] - case "mtu": - c.MTU = v[1] } } return diff --git a/network.go b/network.go index 0828578..7c550cf 100644 --- a/network.go +++ b/network.go @@ -36,10 +36,15 @@ type NetworkDevice struct { Type string MACAddress string Bridge string + MTU string } func (n *NetworkDevice) String() string { - return fmt.Sprintf("%s=%s,bridge=%s", n.Type, n.MACAddress, n.Bridge) + var mtu string + if n.MTU != "" { + mtu = "," + n.MTU + } + return fmt.Sprintf("%s=%s,bridge=%s%s", n.Type, n.MACAddress, n.Bridge, mtu) } func parseNetworkDevice(s string) (n *NetworkDevice) { cfg := strings.Split(s, ",") @@ -57,7 +62,8 @@ func parseNetworkDevice(s string) (n *NetworkDevice) { for _, o := range cfg { if strings.HasPrefix(o, "bridge=") { n.Bridge = o[7:] - break + } else if strings.HasPrefix(o, "mtu=") { + n.MTU = o[4:] } } return