This commit is contained in:
Adam Ierymenko 2019-10-02 12:19:37 -07:00
parent c3e0f262d1
commit 57ade250af
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
10 changed files with 25 additions and 23 deletions

View file

@ -14,6 +14,7 @@
package cli
import (
"encoding/base64"
"fmt"
"io/ioutil"
"net/url"
@ -32,12 +33,15 @@ func AddRoot(basePath, authToken string, args []string) {
locData, err := ioutil.ReadFile(args[0])
if err != nil {
fmt.Printf("ERROR: unable to read locator: %s\n", err.Error())
os.Exit(1)
locData, err2 := base64.StdEncoding.DecodeString(strings.TrimSpace(args[0]))
if err2 != nil || len(locData) == 0 {
fmt.Printf("ERROR: unable to read locator: %s\n", err.Error())
os.Exit(1)
}
}
loc, err := zerotier.NewLocatorFromBytes(locData)
if err != nil {
fmt.Printf("ERROR: invalid locator in file '%s': %s\n", args[0], err.Error())
fmt.Printf("ERROR: invalid locator '%s' (tried as file and base64 literal): %s\n", args[0], err.Error())
os.Exit(1)
}