Browse Source

trim extra spaces from iface name mac

Abhishek Kondur 2 years ago
parent
commit
aabb573a19
1 changed files with 4 additions and 1 deletions
  1. 4 1
      netclient/wireguard/mac.go

+ 4 - 1
netclient/wireguard/mac.go

@@ -2,6 +2,8 @@ package wireguard
 
 
 import (
 import (
 	"errors"
 	"errors"
+	"fmt"
+	"strings"
 
 
 	"github.com/gravitl/netmaker/netclient/ncutils"
 	"github.com/gravitl/netmaker/netclient/ncutils"
 )
 )
@@ -17,7 +19,8 @@ func GetRealIface(iface string) (string, error) {
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}
-	if !(ncutils.FileExists("/var/run/wireguard/" + realIfaceName + ".sock")) {
+	realIfaceName = strings.TrimSpace(realIfaceName)
+	if !(ncutils.FileExists(fmt.Sprintf("/var/run/wireguard/%s.sock", realIfaceName))) {
 		return "", errors.New("interface file does not exist")
 		return "", errors.New("interface file does not exist")
 	}
 	}
 	return realIfaceName, nil
 	return realIfaceName, nil