diff --git a/app.go b/app.go index b2ffc2e..d5a9901 100644 --- a/app.go +++ b/app.go @@ -11,9 +11,6 @@ import ( "strings" "time" ) //导入 -func handler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "正在扫描环境") -} // 测试是否为简幻欢服务器 // 重置已有日志 func renameFileToDateTime(oldFilePath string) (newFilePath string, err error) { @@ -48,58 +45,11 @@ func renameFileToDateTime(oldFilePath string) (newFilePath string, err error) { func main() { logFilePath := "./.autoinst/logs/laster.txt" - //整活下载器 - now := time.Now() - currentDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) - targetDate := time.Date(currentDate.Year(), time.April, 1, 0, 0, 0, 0, now.Location()) - if currentDate == targetDate { - log.Println("正在初始化瑞典原神下崽器") - } else { - log.Println("AutoInstall初始化") - } + fmt.Println("AutoInstall初始化") if _, err := os.Stat("./.autoinst"); err == nil { fmt.Println("OK") } else { os.MkdirAll(".autoinst", os.ModePerm) - //检测是否为simpfun - _, err := os.Stat("./.autoinst/simpfun") - if err == nil { - log.Printf("OK") - } else { - port := os.Getenv("SERVER_PORT") - if port == "" { - // 设置HTTP服务器 - http.HandleFunc("/", handler) - server := &http.Server{Addr: ":" + port} - // 启动服务器 - go func() { - log.Println("服务器启动测试") - if err := server.ListenAndServe(); err != http.ErrServerClosed { - log.Fatalf("监听出现一些错误: %v", err) - } - }() - // 给服务器一点时间来启动 - time.Sleep(1 * time.Second) - // 构建请求 - url := "http://play.simpfun.cn:" + port - _, err = http.Get(url) - if err != nil { - log.Printf("验证失败: %v", err) - } else { - log.Println("你正在简幻欢的服务器上使用AutoInstall,将使用预设") - //记录 - file, err := os.Create("./.autoinst/simpfun") - if err != nil { - log.Fatalf("无法创建文件: %v", err) - } - defer file.Close() - } - if err := server.Shutdown(nil); err != nil { - log.Fatalf("强制关闭测试服务器: %v", err) - } - log.Println("测试服务器已关闭") - } - } } if _, err := os.Stat("./.autoinst/logs"); err == nil {