mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
common/errors/feature_errors.go: Add PrintNonRemovalDeprecatedFeatureWarning() (#5567)
And https://github.com/XTLS/Xray-core/pull/5567#issuecomment-3765466219 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
59dc2cee2e
commit
cd8aab9544
@@ -4,22 +4,19 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PrintMigrateFeatureInfo prints a notice of the upcoming feature migration.
|
// PrintNonRemovalDeprecatedFeatureWarning prints a warning of the deprecated feature that won't be removed in the near future.
|
||||||
// Place it after the source feature related config file pharser code.
|
|
||||||
// Important note: Only use this when the target migrating feature is under construction.
|
|
||||||
// Important note: Even when the target migrating feature has finished its construction, this notice can still be used yet before announcing deprecation of the old feature.
|
|
||||||
// Do not remove this function even there is no reference to it.
|
// Do not remove this function even there is no reference to it.
|
||||||
func PrintMigrateFeatureInfo(sourceFeature string, targetFeature string) {
|
func PrintNonRemovalDeprecatedFeatureWarning(sourceFeature string, targetFeature string) {
|
||||||
LogInfo(context.Background(), "The feature "+sourceFeature+" will be migrated to "+targetFeature+" in the future.")
|
LogWarning(context.Background(), "The feature "+sourceFeature+" is deprecated, not recommended for using and might be removed. Please migrate to "+targetFeature+" as soon as possible.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature.
|
// PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature.
|
||||||
// Do not remove this function even there is no reference to it.
|
// Do not remove this function even there is no reference to it.
|
||||||
func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) {
|
func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) {
|
||||||
if len(migrateFeature) > 0 {
|
if len(migrateFeature) > 0 {
|
||||||
LogWarning(context.Background(), "This feature "+feature+" is deprecated and being migrated to "+migrateFeature+". Please update your config(s) according to release note and documentation before removal.")
|
LogWarning(context.Background(), "This feature "+feature+" is deprecated, will be removed soon and being migrated to "+migrateFeature+". Please update your config(s) according to release note and documentation before removal.")
|
||||||
} else {
|
} else {
|
||||||
LogWarning(context.Background(), "This feature "+feature+" is deprecated. Please update your config(s) according to release note and documentation before removal.")
|
LogWarning(context.Background(), "This feature "+feature+" is deprecated and will be removed soon. Please update your config(s) according to release note and documentation before removal.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ type ShadowsocksServerConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
|
func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("Shadowsocks", "VLESS Encryption")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("Shadowsocks (with no Forward Secrecy, etc.)", "VLESS Encryption")
|
||||||
|
|
||||||
if C.Contains(shadowaead_2022.List, v.Cipher) {
|
if C.Contains(shadowaead_2022.List, v.Cipher) {
|
||||||
return buildShadowsocks2022(v)
|
return buildShadowsocks2022(v)
|
||||||
@@ -187,7 +187,7 @@ type ShadowsocksClientConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *ShadowsocksClientConfig) Build() (proto.Message, error) {
|
func (v *ShadowsocksClientConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("Shadowsocks", "VLESS Encryption")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("Shadowsocks (with no Forward Secrecy, etc.)", "VLESS Encryption")
|
||||||
|
|
||||||
if v.Address != nil {
|
if v.Address != nil {
|
||||||
v.Servers = []*ShadowsocksServerTarget{
|
v.Servers = []*ShadowsocksServerTarget{
|
||||||
|
|||||||
@@ -903,13 +903,13 @@ func (p TransportProtocol) Build() (string, error) {
|
|||||||
case "kcp", "mkcp":
|
case "kcp", "mkcp":
|
||||||
return "mkcp", nil
|
return "mkcp", nil
|
||||||
case "grpc":
|
case "grpc":
|
||||||
errors.PrintDeprecatedFeatureWarning("gRPC transport (with unnecessary costs, etc.)", "XHTTP stream-up H2")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("gRPC transport (with unnecessary costs, etc.)", "XHTTP stream-up H2")
|
||||||
return "grpc", nil
|
return "grpc", nil
|
||||||
case "ws", "websocket":
|
case "ws", "websocket":
|
||||||
errors.PrintDeprecatedFeatureWarning("WebSocket transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("WebSocket transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3")
|
||||||
return "websocket", nil
|
return "websocket", nil
|
||||||
case "httpupgrade":
|
case "httpupgrade":
|
||||||
errors.PrintDeprecatedFeatureWarning("HTTPUpgrade transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("HTTPUpgrade transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3")
|
||||||
return "httpupgrade", nil
|
return "httpupgrade", nil
|
||||||
case "h2", "h3", "http":
|
case "h2", "h3", "http":
|
||||||
return "", errors.PrintRemovedFeatureError("HTTP transport (without header padding, etc.)", "XHTTP stream-one H2 & H3")
|
return "", errors.PrintRemovedFeatureError("HTTP transport (without header padding, etc.)", "XHTTP stream-one H2 & H3")
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type TrojanClientConfig struct {
|
|||||||
|
|
||||||
// Build implements Buildable
|
// Build implements Buildable
|
||||||
func (c *TrojanClientConfig) Build() (proto.Message, error) {
|
func (c *TrojanClientConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("Trojan", "VLESS with flow")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("Trojan (with no Flow, etc.)", "VLESS with Flow & Seed")
|
||||||
|
|
||||||
if c.Address != nil {
|
if c.Address != nil {
|
||||||
c.Servers = []*TrojanServerTarget{
|
c.Servers = []*TrojanServerTarget{
|
||||||
@@ -117,7 +117,7 @@ type TrojanServerConfig struct {
|
|||||||
|
|
||||||
// Build implements Buildable
|
// Build implements Buildable
|
||||||
func (c *TrojanServerConfig) Build() (proto.Message, error) {
|
func (c *TrojanServerConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("Trojan", "VLESS with flow")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("Trojan (with no Flow, etc.)", "VLESS with Flow & Seed")
|
||||||
|
|
||||||
config := &trojan.ServerConfig{
|
config := &trojan.ServerConfig{
|
||||||
Users: make([]*protocol.User, len(c.Clients)),
|
Users: make([]*protocol.User, len(c.Clients)),
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) {
|
|||||||
return nil, errors.New(`VLESS clients: "flow" doesn't support "` + account.Flow + `" in this version`)
|
return nil, errors.New(`VLESS clients: "flow" doesn't support "` + account.Flow + `" in this version`)
|
||||||
}
|
}
|
||||||
if account.Flow == "" {
|
if account.Flow == "" {
|
||||||
errors.PrintDeprecatedFeatureWarning("VLESS without flow", "VLESS with flow")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("VLESS (with no Flow, etc.)", "VLESS with Flow & Seed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(account.Testseed) < 4 {
|
if len(account.Testseed) < 4 {
|
||||||
@@ -280,7 +280,7 @@ func (c *VLessOutboundConfig) Build() (proto.Message, error) {
|
|||||||
|
|
||||||
switch account.Flow {
|
switch account.Flow {
|
||||||
case "":
|
case "":
|
||||||
errors.PrintDeprecatedFeatureWarning("VLESS without flow", "VLESS with flow")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("VLESS (with no Flow, etc.)", "VLESS with Flow & Seed")
|
||||||
case vless.XRV, vless.XRV + "-udp443":
|
case vless.XRV, vless.XRV + "-udp443":
|
||||||
default:
|
default:
|
||||||
return nil, errors.New(`VLESS users: "flow" doesn't support "` + account.Flow + `" in this version`)
|
return nil, errors.New(`VLESS users: "flow" doesn't support "` + account.Flow + `" in this version`)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ type VMessInboundConfig struct {
|
|||||||
|
|
||||||
// Build implements Buildable
|
// Build implements Buildable
|
||||||
func (c *VMessInboundConfig) Build() (proto.Message, error) {
|
func (c *VMessInboundConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("VMess", "VLESS Encryption")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("VMess (with no Forward Secrecy, etc.)", "VLESS Encryption")
|
||||||
|
|
||||||
config := &inbound.Config{}
|
config := &inbound.Config{}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ type VMessOutboundConfig struct {
|
|||||||
|
|
||||||
// Build implements Buildable
|
// Build implements Buildable
|
||||||
func (c *VMessOutboundConfig) Build() (proto.Message, error) {
|
func (c *VMessOutboundConfig) Build() (proto.Message, error) {
|
||||||
errors.PrintDeprecatedFeatureWarning("VMess", "VLESS Encryption")
|
errors.PrintNonRemovalDeprecatedFeatureWarning("VMess (with no Forward Secrecy, etc.)", "VLESS Encryption")
|
||||||
|
|
||||||
config := new(outbound.Config)
|
config := new(outbound.Config)
|
||||||
if c.Address != nil {
|
if c.Address != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user