From de14337b4bcf91ab4233c8488f8c7295f4dc8ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 18 Nov 2024 14:06:25 +0800 Subject: [PATCH] Fix deprecated check --- experimental/deprecated/constants.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/experimental/deprecated/constants.go b/experimental/deprecated/constants.go index 44918857..fd785dbc 100644 --- a/experimental/deprecated/constants.go +++ b/experimental/deprecated/constants.go @@ -1,6 +1,7 @@ package deprecated import ( + "github.com/sagernet/sing-box/common/badversion" C "github.com/sagernet/sing-box/constant" F "github.com/sagernet/sing/common/format" @@ -23,11 +24,12 @@ func (n Note) Impending() bool { if !semver.IsValid("v" + C.Version) { return false } - versionMinor := semver.Compare(semver.MajorMinor("v"+C.Version), "v"+n.ScheduledVersion) - if semver.Prerelease("v"+C.Version) == "" && versionMinor > 0 { + versionCurrent := badversion.Parse(C.Version) + versionMinor := badversion.Parse(n.ScheduledVersion).Minor - versionCurrent.Minor + if versionCurrent.PreReleaseIdentifier == "" && versionMinor < 0 { panic("invalid deprecated note: " + n.Name) } - return versionMinor >= -1 + return versionMinor <= 1 } func (n Note) Message() string { @@ -49,6 +51,7 @@ var OptionBadMatchSource = Note{ Description: "legacy match source rule item", DeprecatedVersion: "1.10.0", ScheduledVersion: "1.11.0", + EnvName: "BAD_MATCH_SOURCE", MigrationLink: "https://sing-box.sagernet.org/deprecated/#match-source-rule-items-are-renamed", } @@ -75,6 +78,7 @@ var OptionTUNAddressX = Note{ Description: "legacy tun address fields", DeprecatedVersion: "1.10.0", ScheduledVersion: "1.12.0", + EnvName: "TUN_ADDRESS_X", MigrationLink: "https://sing-box.sagernet.org/migration/#tun-address-fields-are-merged", }