mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-10-30 17:51:44 +08:00
feat:check win7 core version
This commit is contained in:
@@ -65,7 +65,7 @@ jobs:
|
||||
BUILDTIME: ${{ env.BUILDTIME }}
|
||||
CURRENT_TAG: ${{ env.CURRENT_TAG }}
|
||||
run: |
|
||||
go build -ldflags="-X SamWaf/global.GWAF_RELEASE=true -X SamWaf/global.GWAF_RELEASE_VERSION_NAME=${BUILDTIME} -X SamWaf/global.GWAF_RELEASE_VERSION=${CURRENT_TAG} -s -w -extldflags '-static'" -o ./release/SamWaf64W7.exe main.go
|
||||
go build -ldflags="-X SamWaf/global.GWAF_RUNTIME_WIN7_VERSION=true -X SamWaf/global.GWAF_RELEASE=true -X SamWaf/global.GWAF_RELEASE_VERSION_NAME=${BUILDTIME} -X SamWaf/global.GWAF_RELEASE_VERSION=${CURRENT_TAG} -s -w -extldflags '-static'" -o ./release/SamWaf64W7.exe main.go
|
||||
|
||||
- name: Archive artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
+4
-2
@@ -51,8 +51,6 @@ func (w *WafSysInfoApi) CheckVersionApi(c *gin.Context) {
|
||||
VersionNew: newVer,
|
||||
VersionDesc: desc,
|
||||
}, "有新版本", c)
|
||||
/*wafDelayMsgService.Add("升级结果", "升级结果", "升级成功,当前版本为:"+global.GWAF_RUNTIME_NEW_VERSION+" 版本说明:"+global.GWAF_RUNTIME_NEW_VERSION_DESC)
|
||||
waftask.TaskDelayInfo()*/
|
||||
} else {
|
||||
response.FailWithMessage("没有最新版本", c)
|
||||
return
|
||||
@@ -67,6 +65,10 @@ func (w *WafSysInfoApi) UpdateApi(c *gin.Context) {
|
||||
response.OkWithMessage("正在升级中...请在消息等待结果", c)
|
||||
return
|
||||
}
|
||||
if global.GWAF_RUNTIME_WIN7_VERSION == "true" {
|
||||
response.OkWithMessage("您当前使用的是Win7内核版本,请手工下载版本升级。https://github.com/samwafgo/SamWaf/releases", c)
|
||||
return
|
||||
}
|
||||
global.GWAF_RUNTIME_IS_UPDATETING = true
|
||||
var updater = &wafupdate.Updater{
|
||||
CurrentVersion: global.GWAF_RELEASE_VERSION, // Manually update the const, or set it using `go build -ldflags="-X main.VERSION=<newver>" -o hello-updater src/hello-updater/main.go`
|
||||
|
||||
+5
-5
@@ -24,11 +24,11 @@ var (
|
||||
GWAF_RUNTIME_AREA string = "" //本机当前所在区域
|
||||
GWAF_RUNTIME_SERVER_TYPE bool = false //当前是是否以服务形式启动
|
||||
|
||||
GWAF_RUNTIME_NEW_VERSION string = "" //最新版本号
|
||||
GWAF_RUNTIME_NEW_VERSION_DESC string = "" //最新版本描述
|
||||
|
||||
GWAF_RUNTIME_QPS uint64 = 0 //当前qps
|
||||
GWAF_RUNTIME_LOG_PROCESS uint64 = 0 //log 处理速度
|
||||
GWAF_RUNTIME_NEW_VERSION string = "" //最新版本号
|
||||
GWAF_RUNTIME_NEW_VERSION_DESC string = "" //最新版本描述
|
||||
GWAF_RUNTIME_WIN7_VERSION string = "false" //是否是win7内部版本
|
||||
GWAF_RUNTIME_QPS uint64 = 0 //当前qps
|
||||
GWAF_RUNTIME_LOG_PROCESS uint64 = 0 //log 处理速度
|
||||
|
||||
GWAF_RUNTIME_DNS_SERVER string = "119.29.29.29" //反向查询DNS的IP
|
||||
|
||||
|
||||
@@ -168,7 +168,9 @@ func (m *wafSystenService) run() {
|
||||
} else {
|
||||
rversion = rversion + " " + runtime.GOOS
|
||||
}
|
||||
|
||||
if global.GWAF_RUNTIME_WIN7_VERSION == "true" {
|
||||
rversion = rversion + " Win7内核版本"
|
||||
}
|
||||
zlog.Info(rversion)
|
||||
zlog.Info("OutIp", global.GWAF_RUNTIME_IP)
|
||||
|
||||
@@ -210,7 +212,7 @@ func (m *wafSystenService) run() {
|
||||
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.StartWaf()
|
||||
|
||||
//启动管理界面
|
||||
webmanager = &wafmangeweb.WafWebManager{}
|
||||
webmanager = &wafmangeweb.WafWebManager{LogName: "WebManager"}
|
||||
go func() {
|
||||
webmanager.StartLocalServer()
|
||||
}()
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"SamWaf/global"
|
||||
"SamWaf/middleware"
|
||||
"SamWaf/router"
|
||||
"SamWaf/utils/zlog"
|
||||
"SamWaf/wafmangeweb/static"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
type WafWebManager struct {
|
||||
HttpServer *http.Server
|
||||
R *gin.Engine
|
||||
LogName string
|
||||
}
|
||||
|
||||
func (web *WafWebManager) initRouter(r *gin.Engine) {
|
||||
@@ -60,6 +62,9 @@ func (web *WafWebManager) initRouter(r *gin.Engine) {
|
||||
static.Static(r, func(handlers ...gin.HandlerFunc) {
|
||||
r.NoRoute(handlers...)
|
||||
})
|
||||
zlog.Info(web.LogName, "use static asset")
|
||||
} else {
|
||||
zlog.Info(web.LogName, "no use static asset")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,10 +103,9 @@ func (web *WafWebManager) StartLocalServer() {
|
||||
Handler: r,
|
||||
}
|
||||
if err := web.HttpServer.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
|
||||
log.Printf("listen: %s\n", err)
|
||||
zlog.Error(web.LogName, "use static asset", err.Error())
|
||||
}
|
||||
|
||||
log.Printf("本地 port:%d\n", global.GWAF_LOCAL_SERVER_PORT)
|
||||
zlog.Info(web.LogName, "本地 port:", global.GWAF_LOCAL_SERVER_PORT)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -116,8 +120,7 @@ func (web *WafWebManager) CloseLocalServer() {
|
||||
defer cancel()
|
||||
|
||||
if err := web.HttpServer.Shutdown(ctx); err != nil {
|
||||
log.Fatal("Server forced to shutdown:", err)
|
||||
zlog.Error(web.LogName, "Server forced to shutdown:", err.Error())
|
||||
}
|
||||
|
||||
log.Println("local Server exiting")
|
||||
zlog.Info(web.LogName, "local Server exiting")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user