2016-08-08 22:55:36 +00:00
|
|
|
// +build !coverage
|
|
|
|
|
|
|
|
package scenarios
|
|
|
|
|
|
|
|
import (
|
2016-12-16 20:39:00 +00:00
|
|
|
"bytes"
|
2016-11-17 23:01:37 +00:00
|
|
|
"fmt"
|
2016-08-08 22:55:36 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BuildV2Ray() error {
|
2017-03-31 15:12:33 +00:00
|
|
|
genTestBinaryPath()
|
2016-11-17 23:01:37 +00:00
|
|
|
if _, err := os.Stat(testBinaryPath); err == nil {
|
2016-08-08 22:55:36 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-21 23:19:51 +00:00
|
|
|
fmt.Printf("Building V2Ray into path (%s)\n", testBinaryPath)
|
2018-07-28 23:53:20 +00:00
|
|
|
cmd := exec.Command("go", "build", "-o="+testBinaryPath, GetSourcePath())
|
2016-08-08 22:55:36 +00:00
|
|
|
return cmd.Run()
|
|
|
|
}
|
|
|
|
|
2016-12-16 20:39:00 +00:00
|
|
|
func RunV2RayProtobuf(config []byte) *exec.Cmd {
|
2017-03-31 15:12:33 +00:00
|
|
|
genTestBinaryPath()
|
2016-12-16 20:39:00 +00:00
|
|
|
proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb")
|
|
|
|
proc.Stdin = bytes.NewBuffer(config)
|
|
|
|
proc.Stderr = os.Stderr
|
|
|
|
proc.Stdout = os.Stdout
|
|
|
|
|
|
|
|
return proc
|
|
|
|
}
|