diff --git a/ipfs.go b/ipfs.go index d6ee97b..cb99217 100644 --- a/ipfs.go +++ b/ipfs.go @@ -43,10 +43,10 @@ func (i *IPFS) Get(ref IPFSRef) ([]byte, error) { return nil, err } - fmt.Printf("Fetching %q from primary location (%q)...", ref, i.GatewayAddressURL.String()) + fmt.Printf("Fetching %q from %q...", ref, i.GatewayAddressURL.String()) resp, err := i.Client.Do(req1) if err != nil { - fmt.Printf(" failed (%s), trying fallback (%q)...", err, i.FallbackGatewayAddressURL) + fmt.Printf(" failed (%s), trying %q...", err, i.FallbackGatewayAddressURL) resp, err = i.Client.Do(req2) if err != nil { diff --git a/yaml.go b/yaml.go index 74b7617..ba90829 100644 --- a/yaml.go +++ b/yaml.go @@ -2,7 +2,9 @@ package bios import ( "encoding/json" + "fmt" "io/ioutil" + "strings" yaml2json "github.com/bronze1man/go-yaml2json" ) @@ -28,5 +30,14 @@ func ValidateDiscoveryFile(filename string) error { return err } + for _, peer := range disco.LaunchData.Peers { + if !strings.HasPrefix(string(peer.DiscoveryLink), "/ipns/") { + return fmt.Errorf("peer link %q invalid, should start with '/ipns/'", peer.DiscoveryLink) + } + if peer.Weight > 1.0 { + return fmt.Errorf("peer %q weight must be between 0.0 and 1.0", peer.DiscoveryLink) + } + } + return nil }