2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 01:57:19 +08:00

feat: 添加系统支持及EOL检测

This commit is contained in:
2026-01-10 05:46:53 +08:00
parent 01a228f3ad
commit 9aa951e247
3 changed files with 108 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import (
"github.com/acepanel/panel/pkg/api"
"github.com/acepanel/panel/pkg/config"
"github.com/acepanel/panel/pkg/db"
"github.com/acepanel/panel/pkg/os"
"github.com/acepanel/panel/pkg/shell"
"github.com/acepanel/panel/pkg/tools"
"github.com/acepanel/panel/pkg/types"
@@ -115,6 +116,33 @@ func (s *HomeService) SystemInfo(w http.ResponseWriter, r *http.Request) {
})
}
// 系统是否支持
osSupported := true
if os.IsRHEL() {
minVer := version.Must(version.NewVersion("9.0"))
currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0]
currentVer, err := version.NewVersion(currentVerStr)
if err != nil || currentVer.LessThan(minVer) {
osSupported = false
}
}
if os.IsDebian() {
minVer := version.Must(version.NewVersion("12.0"))
currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0]
currentVer, err := version.NewVersion(currentVerStr)
if err != nil || currentVer.LessThan(minVer) {
osSupported = false
}
}
if os.IsUbuntu() {
minVer := version.Must(version.NewVersion("22.04"))
currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0]
currentVer, err := version.NewVersion(currentVerStr)
if err != nil || currentVer.LessThan(minVer) {
osSupported = false
}
}
Success(w, chix.M{
"procs": hostInfo.Procs,
"hostname": hostInfo.Hostname,
@@ -128,6 +156,8 @@ func (s *HomeService) SystemInfo(w http.ResponseWriter, r *http.Request) {
"kernel_arch": hostInfo.KernelArch,
"kernel_version": hostInfo.KernelVersion,
"os_name": hostInfo.Platform + " " + hostInfo.PlatformVersion,
"os_supported": osSupported,
"os_eol": os.IsEOL(),
"boot_time": hostInfo.BootTime,
"uptime": hostInfo.Uptime,
"nets": nets,

View File

@@ -6,6 +6,7 @@ import (
"net"
"os"
"strings"
"time"
)
func readOSRelease() map[string]string {
@@ -62,6 +63,59 @@ func IsUbuntu() bool {
return id == "ubuntu" || strings.Contains(idLike, "ubuntu")
}
// IsEOL 判断系统是否已到达生命周期终点
func IsEOL() bool {
eolTimeTable := map[string]map[string]time.Time{
"rhel": {
"9": time.Date(2032, 5, 31, 0, 0, 0, 0, time.UTC),
"10": time.Date(2035, 5, 31, 0, 0, 0, 0, time.UTC),
},
"debian": {
"12": time.Date(2028, 6, 30, 0, 0, 0, 0, time.UTC),
"13": time.Date(2030, 6, 30, 0, 0, 0, 0, time.UTC),
},
"ubuntu": {
"22.04": time.Date(2027, 4, 1, 0, 0, 0, 0, time.UTC),
"24.04": time.Date(2029, 5, 31, 0, 0, 0, 0, time.UTC),
},
}
osRelease := readOSRelease()
if IsRHEL() {
version, ok := osRelease["VERSION_ID"]
if !ok {
return false
}
majorVersion := strings.Split(version, ".")[0]
if eol, ok := eolTimeTable["rhel"][majorVersion]; ok {
return time.Now().After(eol)
}
}
if IsUbuntu() {
version, ok := osRelease["VERSION_ID"]
if !ok {
return false
}
majorVersion := strings.Join(strings.Split(version, ".")[:2], ".")
if eol, ok := eolTimeTable["ubuntu"][majorVersion]; ok {
return time.Now().After(eol)
}
}
if IsDebian() {
version, ok := osRelease["VERSION_ID"]
if !ok {
return false
}
majorVersion := strings.Split(version, ".")[0]
if eol, ok := eolTimeTable["debian"][majorVersion]; ok {
return time.Now().After(eol)
}
}
return false
}
func TCPPortInUse(port uint) bool {
addr := fmt.Sprintf(":%d", port)
conn, err := net.Listen("tcp", addr)

View File

@@ -54,7 +54,9 @@ const { data: systemInfo } = useRequest(home.systemInfo, {
go_version: '',
kernel_arch: '',
kernel_version: '',
os_eol: false,
os_name: '',
os_supported: true,
boot_time: 0,
uptime: 0,
nets: [],
@@ -417,6 +419,28 @@ if (import.meta.hot) {
<app-page :show-footer="true" min-w-375>
<div flex-1>
<n-space vertical>
<!-- 系统是否 EOL -->
<n-alert type="info" v-if="systemInfo.os_eol">
{{
$gettext(
'Your operating system %{ os_name } has reached its end-of-life. Please consider upgrading to a supported version to ensure optimal performance and security.',
{
os_name: systemInfo?.os_name
}
)
}}
</n-alert>
<!-- 系统是否不受支持 -->
<n-alert type="warning" v-if="!systemInfo.os_supported">
{{
$gettext(
'Your operating system %{ os_name } is not officially supported. Some features may not work as expected. Please consider using a supported operating system for the best experience.',
{
os_name: systemInfo?.os_name
}
)
}}
</n-alert>
<n-card :segmented="true" size="small">
<n-page-header :subtitle="systemInfo?.panel_version">
<n-grid :cols="4" pb-10>