1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-05 00:47:51 -05:00
v2fly/commands/all/verify.go
Jebbs 521120d196
go style commands, merge v2ctl commands, v5 oriented (#369)
* go style commands
merge v2ctl commandsw

* migrate go style commands to v2ctl

* fixes & code optimize

* sort the commands

* update commands description

* restore old proto
golang.org proto has removed UnmarshalText, without alternative

* add test command

* remove unused code

* code optimize and fix
* The commit simplifies the run and test commands code,
* Fixes a hidden issue that the format flag not applied in command "v2ray test -format=pb ..."

* fix default loader logic
2020-11-23 23:38:43 +08:00

54 lines
1.1 KiB
Go

package all
import (
"os"
"github.com/v2fly/VSign/signerVerify"
"v2ray.com/core/commands/base"
)
var cmdVerify = &base.Command{
UsageLine: "{{.Exec}} verify [--sig=sig-file] file",
Short: "Verify if a binary is officially signed",
Long: `
Verify if a binary is officially signed.
Arguments:
-sig
The path to the signature file
`,
}
func init() {
cmdVerify.Run = executeVerify // break init loop
}
var (
verifySigFile = cmdVerify.Flag.String("sig", "", "Path to the signature file")
)
func executeVerify(cmd *base.Command, args []string) {
target := cmdVerify.Flag.Arg(0)
if target == "" {
base.Fatalf("empty file path.")
}
if *verifySigFile == "" {
base.Fatalf("empty signature path.")
}
sigReader, err := os.Open(os.ExpandEnv(*verifySigFile))
if err != nil {
base.Fatalf("failed to open file %s: %s ", *verifySigFile, err)
}
files := cmdVerify.Flag.Args()
err = signerVerify.OutputAndJudge(signerVerify.CheckSignaturesV2Fly(sigReader, files))
if err != nil {
base.Fatalf("file is not officially signed by V2Ray: %s", err)
}
}