common_regular.go 632 B

1234567891011121314151617181920212223242526272829303132
  1. //go:build !coverage
  2. // +build !coverage
  3. package scenarios
  4. import (
  5. "bytes"
  6. "fmt"
  7. "os"
  8. "os/exec"
  9. )
  10. func BuildV2Ray() error {
  11. genTestBinaryPath()
  12. if _, err := os.Stat(testBinaryPath); err == nil {
  13. return nil
  14. }
  15. fmt.Printf("Building V2Ray into path (%s)\n", testBinaryPath)
  16. cmd := exec.Command("go", "build", "-o="+testBinaryPath, GetSourcePath())
  17. return cmd.Run()
  18. }
  19. func RunV2RayProtobuf(config []byte) *exec.Cmd {
  20. genTestBinaryPath()
  21. proc := exec.Command(testBinaryPath, "run", "-config=stdin:", "-format=pb")
  22. proc.Stdin = bytes.NewBuffer(config)
  23. proc.Stderr = os.Stderr
  24. proc.Stdout = os.Stdout
  25. return proc
  26. }