light: cross-check the very first header (#5429)

Closes #5428
This commit is contained in:
Anton Kaliaev
2020-10-09 14:29:22 +04:00
committed by GitHub
parent 93b9bab932
commit 12ebd7735a
4 changed files with 135 additions and 29 deletions
+20 -1
View File
@@ -1,6 +1,7 @@
package commands
import (
"bufio"
"context"
"errors"
"fmt"
@@ -140,7 +141,25 @@ func runProxy(cmd *cobra.Command, args []string) error {
return fmt.Errorf("can't parse trust level: %w", err)
}
options := []light.Option{light.Logger(logger)}
options := []light.Option{
light.Logger(logger),
light.ConfirmationFunction(func(action string) bool {
fmt.Println(action)
scanner := bufio.NewScanner(os.Stdin)
for {
scanner.Scan()
response := scanner.Text()
switch response {
case "y", "Y":
return true
case "n", "N":
return false
default:
fmt.Println("please input 'Y' or 'n' and press ENTER")
}
}
}),
}
if sequential {
options = append(options, light.SequentialVerification())