sing-box/experimental/deprecated/env.go
2024-10-30 14:01:28 +08:00

31 lines
696 B
Go

package deprecated
import (
"os"
"strconv"
"github.com/sagernet/sing/common/logger"
)
type envManager struct {
logger logger.Logger
}
func NewEnvManager(logger logger.Logger) Manager {
return &envManager{logger: logger}
}
func (f *envManager) ReportDeprecated(feature Note) {
if !feature.Impending() {
f.logger.Warn(feature.MessageWithLink())
return
}
enable, enableErr := strconv.ParseBool(os.Getenv("ENABLE_DEPRECATED_" + feature.EnvName))
if enableErr == nil && enable {
f.logger.Warn(feature.MessageWithLink())
return
}
f.logger.Error(feature.MessageWithLink())
f.logger.Fatal("to continuing using this feature, set ENABLE_DEPRECATED_" + feature.EnvName + "=true")
}