mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-01 05:32:18 +08:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
920054c844 | ||
![]() |
3c5405dd07 |
@@ -2,8 +2,9 @@
|
||||
|
||||
[](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) [](https://www.spiritlhl.net/)
|
||||
|
||||
融合怪测评脚本 - GO 重构版本
|
||||
由于未正式发版,如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
|
||||
融合怪测评项目 - GO 重构版本
|
||||
|
||||
如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
|
||||
|
||||
Go 版本:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs)
|
||||
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
[](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) [](https://www.spiritlhl.net/)
|
||||
|
||||
Fusion Monster Evaluation Script - GO Refactored Version - Since it has not been officially released, please report any issues via issues.
|
||||
Fusion Monster Evaluation Script - GO Refactored Version
|
||||
|
||||
Please report any issues via issues.
|
||||
|
||||
Go version:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs)
|
||||
|
||||
|
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.22.4
|
||||
require (
|
||||
github.com/imroc/req/v3 v3.49.0
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502
|
||||
github.com/oneclickvirt/UnlockTests v0.0.21-20241220082535
|
||||
github.com/oneclickvirt/UnlockTests v0.0.22-20241221103638
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722
|
||||
github.com/oneclickvirt/basics v0.0.8-20241108124433
|
||||
github.com/oneclickvirt/cputest v0.0.8-20240702070215
|
||||
|
4
go.sum
4
go.sum
@@ -104,8 +104,8 @@ github.com/nxtrace/NTrace-core v1.3.2 h1:8aU/IQFmPnwbaWGVBIJHwwVIWk+roo+9+lG+U0O
|
||||
github.com/nxtrace/NTrace-core v1.3.2/go.mod h1:qCVsgSs982jw02BVjTtN8mjSg5OIXW9TaUdISQrMnTw=
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502 h1:hRIYJ2uEp2N3AH5bP5X6bwfdwWfZQO/2WoqpUJ8+WsY=
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.4-20240704024502/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.21-20241220082535 h1:toXd0wMG2bbEMXzOT1i29JXaWbBrp1gDVi8BT0GtwZc=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.21-20241220082535/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.22-20241221103638 h1:31Ek7CLX94vWzbU4fysqCxn7scC53Zk4OhlaB3OQDYQ=
|
||||
github.com/oneclickvirt/UnlockTests v0.0.22-20241221103638/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722 h1:UJ/VWf+ZbhGarc9HcHMIyenpmX+b2LxkXu0hlLk3Gxs=
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240702140722/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
|
||||
github.com/oneclickvirt/basics v0.0.8-20241108124433 h1:eKZcoNoa9uLWmfisk+qN/QOvSGT4ajCmZdZfIAcHG+o=
|
||||
|
2
goecs.go
2
goecs.go
@@ -39,7 +39,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ecsVersion = "v0.0.88"
|
||||
ecsVersion = "v0.1.01"
|
||||
menuMode bool
|
||||
onlyChinaTest bool
|
||||
input, choice string
|
||||
|
@@ -245,8 +245,8 @@ func PrintAndCapture(f func(), tempOutput, output string) string {
|
||||
|
||||
// UploadText 上传文本内容到指定URL
|
||||
func UploadText(absPath string) (string, string, error) {
|
||||
primaryURL := "http://hpaste.spiritlhl.net/api/upload"
|
||||
backupURL := "https://paste.spiritlhl.net/api/upload"
|
||||
primaryURL := "http://hpaste.spiritlhl.net/api/UL/upload"
|
||||
backupURL := "https://paste.spiritlhl.net/api/UL/upload"
|
||||
token := network.SecurityUploadToken
|
||||
client := req.C().SetTimeout(6 * time.Second)
|
||||
client.R().
|
||||
@@ -259,47 +259,42 @@ func UploadText(absPath string) (string, string, error) {
|
||||
}
|
||||
defer file.Close()
|
||||
upload := func(url string) (string, string, error) {
|
||||
// 重新打开文件,以确保我们总是从文件开头读取
|
||||
file, err := os.Open(absPath)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// 读取文件内容
|
||||
content, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err)
|
||||
}
|
||||
resp, err := client.R().
|
||||
SetHeader("Authorization", token).
|
||||
SetHeader("Format", "RANDOM").
|
||||
SetHeader("Max-Views", "0").
|
||||
SetHeader("UploadText", "true").
|
||||
SetHeader("Content-Type", "multipart/form-data").
|
||||
SetHeader("No-JSON", "true").
|
||||
SetFileBytes("file", "goecs.txt", content).
|
||||
SetFileBytes("file", filepath.Base(absPath), content).
|
||||
Post(url)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to make request to %s: %w", url, err)
|
||||
}
|
||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||
http_url := strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/")
|
||||
https_url := strings.ReplaceAll(resp.String(), "http://hpaste.spiritlhl.net/", "https://paste.spiritlhl.net/")
|
||||
return http_url, https_url, nil
|
||||
} else {
|
||||
return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode)
|
||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 && resp.String() != "" {
|
||||
fileID := strings.TrimSpace(resp.String())
|
||||
if strings.Contains(fileID, "show") {
|
||||
fileID = fileID[strings.LastIndex(fileID, "/")+1:]
|
||||
}
|
||||
httpURL := fmt.Sprintf("http://hpaste.spiritlhl.net/#/show/%s", fileID)
|
||||
httpsURL := fmt.Sprintf("https://paste.spiritlhl.net/#/show/%s", fileID)
|
||||
return httpURL, httpsURL, nil
|
||||
}
|
||||
return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode)
|
||||
}
|
||||
http_url, https_url, err := upload(primaryURL)
|
||||
httpURL, httpsURL, err := upload(primaryURL)
|
||||
if err == nil {
|
||||
return http_url, https_url, nil
|
||||
return httpURL, httpsURL, nil
|
||||
}
|
||||
http_url, https_url, err = upload(backupURL)
|
||||
httpURL, httpsURL, err = upload(backupURL)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err)
|
||||
}
|
||||
return http_url, https_url, nil
|
||||
return httpURL, httpsURL, nil
|
||||
}
|
||||
|
||||
// ProcessAndUpload 创建结果文件并上传文件
|
||||
|
Reference in New Issue
Block a user