mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-03 07:45:29 -05:00
remove unused code
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
package scenarios
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"v2ray.com/core"
|
||||
"v2ray.com/core/app/log"
|
||||
"v2ray.com/core/common"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/retry"
|
||||
)
|
||||
|
||||
func pickPort() v2net.Port {
|
||||
@@ -59,3 +68,46 @@ func InitializeServerConfig(config *core.Config) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
runningServers = make([]*exec.Cmd, 0, 10)
|
||||
testBinaryPath string
|
||||
testBinaryPathGen sync.Once
|
||||
)
|
||||
|
||||
func genTestBinaryPath() {
|
||||
testBinaryPathGen.Do(func() {
|
||||
var tempDir string
|
||||
err := retry.Timed(5, 100).On(func() error {
|
||||
dir, err := ioutil.TempDir("", "v2ray")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tempDir = dir
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
file := filepath.Join(tempDir, "v2ray.test")
|
||||
if runtime.GOOS == "windows" {
|
||||
file += ".exe"
|
||||
}
|
||||
testBinaryPath = file
|
||||
fmt.Printf("Generated binary path: %s\n", file)
|
||||
})
|
||||
}
|
||||
|
||||
func GetSourcePath() string {
|
||||
return filepath.Join("v2ray.com", "core", "main")
|
||||
}
|
||||
|
||||
func CloseAllServers() {
|
||||
log.Info("Closing all servers.")
|
||||
for _, server := range runningServers {
|
||||
server.Process.Signal(os.Interrupt)
|
||||
server.Process.Wait()
|
||||
}
|
||||
runningServers = make([]*exec.Cmd, 0, 10)
|
||||
log.Info("All server closed.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user