From 863e4cacbe846404c45b08535e90dac7a3ec2c73 Mon Sep 17 00:00:00 2001 From: JT Olio Date: Wed, 16 Oct 2019 22:40:41 -0600 Subject: [PATCH] examples/scope: small scope exploder command line tool (#3266) this provides a small tool that breaks a scope into its constituent parts Change-Id: If011dd457a175eeb6e013a17d1aee4f3edfb8b0c --- examples/scope/main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/scope/main.go diff --git a/examples/scope/main.go b/examples/scope/main.go new file mode 100644 index 000000000..109721a5d --- /dev/null +++ b/examples/scope/main.go @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Storj Labs, Inc. +// See LICENSE for copying information. + +package main + +import ( + "fmt" + "os" + + "storj.io/storj/lib/uplink" +) + +func main() { + if len(os.Args) < 2 { + fmt.Println("usage:", os.Args[0], "") + os.Exit(1) + } + scope, err := uplink.ParseScope(os.Args[1]) + if err != nil { + fmt.Println("invalid scope:", err.Error()) + os.Exit(1) + } + encaccess, err := scope.EncryptionAccess.Serialize() + if err != nil { + panic(err) + } + fmt.Printf("satellite: %s\napi key: %s\nenc access: %s\n", + scope.SatelliteAddr, + scope.APIKey.Serialize(), + encaccess) +}