Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func main() {
&cli.BoolFlag{
Name: "debug",
},
&cli.BoolFlag{
Name: "public-key",
},
},
Action: func(c *cli.Context) error {
args := c.Args().Slice()
Expand Down Expand Up @@ -58,27 +61,33 @@ func main() {

file := args[0]

var privateKey []byte
var inKey []byte
var err error
if file == "-" {
buff := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
buff.WriteString(scanner.Text() + "\n")
}
privateKey = buff.Bytes()
inKey = buff.Bytes()
} else {
privateKey, err = ioutil.ReadFile(args[0])
inKey, err = ioutil.ReadFile(args[0])
if err != nil {
logger.Fatalf("File cannot be read: %s", err)
return nil
}
}

publicKey, err := parser.PublicKey(privateKey)
if err != nil {
logger.Fatalf("Error computing public key: %s", err)
var publicKey []byte
if ! c.Bool("public-key") {
publicKey, err = parser.PublicKey(inKey)
if err != nil {
logger.Fatalf("Error computing public key: %s", err)
}
} else {
publicKey = inKey
}

result, err := client.Lookup(version, publicKey)
if err != nil {
logger.Fatalf("Error looking up public key: %s", err)
Expand Down