| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package control
- import (
- "flag"
- "os"
- "github.com/v2fly/VSign/signerVerify"
- "github.com/v2fly/v2ray-core/v4/common"
- )
- type VerifyCommand struct{}
- func (c *VerifyCommand) Name() string {
- return "verify"
- }
- func (c *VerifyCommand) Description() Description {
- return Description{
- Short: "Verify if a binary is officially signed.",
- Usage: []string{
- "v2ctl verify --sig=<sig-file> file...",
- "Verify the file officially signed by V2Ray.",
- },
- }
- }
- func (c *VerifyCommand) Execute(args []string) error {
- fs := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- sigFile := fs.String("sig", "", "Path to the signature file")
- if err := fs.Parse(args); err != nil {
- return err
- }
- target := fs.Arg(0)
- if target == "" {
- return newError("empty file path.")
- }
- if *sigFile == "" {
- return newError("empty signature path.")
- }
- sigReader, err := os.Open(os.ExpandEnv(*sigFile))
- if err != nil {
- return newError("failed to open file ", *sigFile).Base(err)
- }
- files := fs.Args()
- err = signerVerify.OutputAndJudge(signerVerify.CheckSignaturesV2Fly(sigReader, files))
- if err == nil {
- return nil
- }
- return newError("file is not officially signed by V2Ray").Base(err)
- }
- func init() {
- common.Must(RegisterCommand(&VerifyCommand{}))
- }
|