deprecated.go 573 B

1234567891011121314151617181920212223242526272829
  1. package daemon
  2. import (
  3. "sync"
  4. "github.com/sagernet/sing-box/experimental/deprecated"
  5. "github.com/sagernet/sing/common"
  6. )
  7. var _ deprecated.Manager = (*deprecatedManager)(nil)
  8. type deprecatedManager struct {
  9. access sync.Mutex
  10. notes []deprecated.Note
  11. }
  12. func (m *deprecatedManager) ReportDeprecated(feature deprecated.Note) {
  13. m.access.Lock()
  14. defer m.access.Unlock()
  15. m.notes = common.Uniq(append(m.notes, feature))
  16. }
  17. func (m *deprecatedManager) Get() []deprecated.Note {
  18. m.access.Lock()
  19. defer m.access.Unlock()
  20. notes := m.notes
  21. m.notes = nil
  22. return notes
  23. }