sing-box/experimental/libbox/deprecated.go

58 lines
1.1 KiB
Go
Raw Normal View History

2024-10-18 09:58:03 +08:00
package libbox
import (
"sync"
"github.com/sagernet/sing-box/experimental/deprecated"
2024-11-07 19:58:46 +08:00
"github.com/sagernet/sing/common"
2024-10-18 09:58:03 +08:00
)
var _ deprecated.Manager = (*deprecatedManager)(nil)
type deprecatedManager struct {
2024-11-07 19:58:46 +08:00
access sync.Mutex
notes []deprecated.Note
2024-10-18 09:58:03 +08:00
}
func (m *deprecatedManager) ReportDeprecated(feature deprecated.Note) {
m.access.Lock()
defer m.access.Unlock()
2024-11-07 19:58:46 +08:00
m.notes = common.Uniq(append(m.notes, feature))
2024-10-18 09:58:03 +08:00
}
func (m *deprecatedManager) Get() []deprecated.Note {
m.access.Lock()
defer m.access.Unlock()
2024-11-07 19:58:46 +08:00
notes := m.notes
m.notes = nil
return notes
2024-10-18 09:58:03 +08:00
}
var _ = deprecated.Note(DeprecatedNote{})
type DeprecatedNote struct {
Name string
Description string
DeprecatedVersion string
ScheduledVersion string
EnvName string
MigrationLink string
}
func (n DeprecatedNote) Impending() bool {
return deprecated.Note(n).Impending()
}
func (n DeprecatedNote) Message() string {
return deprecated.Note(n).Message()
}
func (n DeprecatedNote) MessageWithLink() string {
return deprecated.Note(n).MessageWithLink()
}
type DeprecatedNoteIterator interface {
HasNext() bool
Next() *DeprecatedNote
}