common_regular.go 604 B

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