mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
7c1ab06206
* remove v2ctl, wv2ray * remove v2ctl, wv2ray build scripts * remove infra/control/main * remove !confonly flag * remove ctlcmd package * remove Confgi.Override func * move commands package into main
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package all
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/v2fly/VSign/signerVerify"
|
|
"v2ray.com/core/main/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)
|
|
}
|
|
}
|