mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-05 07:17:01 +08:00
update
This commit is contained in:
20
goecs.go
20
goecs.go
@@ -212,9 +212,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
var (
|
var (
|
||||||
wg1, wg2, wg3 sync.WaitGroup
|
wg1, wg2 sync.WaitGroup
|
||||||
basicInfo, securityInfo, emailInfo, mediaInfo, backtraceInfo string
|
basicInfo, securityInfo, emailInfo, mediaInfo string
|
||||||
output, tempOutput string
|
output, tempOutput string
|
||||||
)
|
)
|
||||||
output = utils.PrintAndCapture(func() {
|
output = utils.PrintAndCapture(func() {
|
||||||
switch language {
|
switch language {
|
||||||
@@ -255,17 +255,6 @@ func main() {
|
|||||||
mediaInfo = unlocktest.MediaTest(language)
|
mediaInfo = unlocktest.MediaTest(language)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
if backtraceStatus {
|
|
||||||
wg3.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg3.Done()
|
|
||||||
backtraceInfo = utils.GetCaptureOutput(func() {
|
|
||||||
backtrace.BackTrace()
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if commTestStatus {
|
if commTestStatus {
|
||||||
utils.PrintCenteredTitle("御三家流媒体解锁", width)
|
utils.PrintCenteredTitle("御三家流媒体解锁", width)
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
@@ -287,8 +276,7 @@ func main() {
|
|||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
if backtraceStatus {
|
if backtraceStatus {
|
||||||
utils.PrintCenteredTitle("三网回程", width)
|
utils.PrintCenteredTitle("三网回程", width)
|
||||||
wg3.Wait()
|
backtrace.BackTrace()
|
||||||
fmt.Printf(backtraceInfo)
|
|
||||||
}
|
}
|
||||||
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
// nexttrace 在win上不支持检测,报错 bind: An invalid argument was supplied.
|
||||||
if nt3Status {
|
if nt3Status {
|
||||||
|
@@ -91,56 +91,6 @@ func SecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (stri
|
|||||||
return basicInfo, securityInfo, nt3CheckType
|
return basicInfo, securityInfo, nt3CheckType
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCaptureOutput 仅捕获输出不实时输出
|
|
||||||
func GetCaptureOutput(f func()) string {
|
|
||||||
// 保存旧的 stdout 和 stderr
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
oldStderr := os.Stderr
|
|
||||||
// 创建管道
|
|
||||||
stdoutPipeR, stdoutPipeW, err := os.Pipe()
|
|
||||||
if err != nil {
|
|
||||||
return "Error creating stdout pipe"
|
|
||||||
}
|
|
||||||
stderrPipeR, stderrPipeW, err := os.Pipe()
|
|
||||||
if err != nil {
|
|
||||||
stdoutPipeW.Close()
|
|
||||||
stdoutPipeR.Close()
|
|
||||||
return "Error creating stderr pipe"
|
|
||||||
}
|
|
||||||
// 替换标准输出和标准错误输出为管道写入端
|
|
||||||
os.Stdout = stdoutPipeW
|
|
||||||
os.Stderr = stderrPipeW
|
|
||||||
// 恢复标准输出和标准错误输出
|
|
||||||
defer func() {
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
os.Stderr = oldStderr
|
|
||||||
stdoutPipeW.Close()
|
|
||||||
stderrPipeW.Close()
|
|
||||||
}()
|
|
||||||
// 缓冲区
|
|
||||||
var stdoutBuf, stderrBuf bytes.Buffer
|
|
||||||
// 并发读取 stdout 和 stderr
|
|
||||||
done := make(chan struct{})
|
|
||||||
go func() {
|
|
||||||
io.Copy(&stdoutBuf, stdoutPipeR)
|
|
||||||
done <- struct{}{}
|
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
io.Copy(&stderrBuf, stderrPipeR)
|
|
||||||
done <- struct{}{}
|
|
||||||
}()
|
|
||||||
// 执行函数
|
|
||||||
f()
|
|
||||||
// 关闭管道写入端,让管道读取端可以读取所有数据
|
|
||||||
stdoutPipeW.Close()
|
|
||||||
stderrPipeW.Close()
|
|
||||||
// 等待两个 goroutine 完成
|
|
||||||
<-done
|
|
||||||
<-done
|
|
||||||
// 返回捕获的输出字符串
|
|
||||||
return stdoutBuf.String() + stderrBuf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// CaptureOutput 捕获函数输出和错误输出,实时输出,并返回字符串
|
// CaptureOutput 捕获函数输出和错误输出,实时输出,并返回字符串
|
||||||
func CaptureOutput(f func()) string {
|
func CaptureOutput(f func()) string {
|
||||||
// 保存旧的 stdout 和 stderr
|
// 保存旧的 stdout 和 stderr
|
||||||
|
Reference in New Issue
Block a user