diff --git a/common/urltest/urltest.go b/common/urltest/urltest.go index bfeb13ba3d..7b5378dbc5 100644 --- a/common/urltest/urltest.go +++ b/common/urltest/urltest.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/imkira/go-observer" + "github.com/imkira/go-observer/v2" "github.com/sagernet/sing/common" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -22,7 +22,7 @@ type History struct { type HistoryStorage struct { access sync.RWMutex delayHistory map[string]*History - updateHook observer.Property + updateHook observer.Property[int] } func NewHistoryStorage() *HistoryStorage { @@ -31,7 +31,7 @@ func NewHistoryStorage() *HistoryStorage { } } -func (s *HistoryStorage) SetHook(hook observer.Property) { +func (s *HistoryStorage) SetHook(hook observer.Property[int]) { s.updateHook = hook } diff --git a/experimental/libbox/command_group.go b/experimental/libbox/command_group.go index 191fb8dc99..35aebe9fe4 100644 --- a/experimental/libbox/command_group.go +++ b/experimental/libbox/command_group.go @@ -91,6 +91,7 @@ func (s *CommandServer) handleGroupConn(conn net.Conn, onlyGroupItems bool) erro case <-ctx.Done(): return ctx.Err() case <-urlTestUpdateStream.Changes(): + urlTestUpdateStream.Next() } } } diff --git a/experimental/libbox/command_server.go b/experimental/libbox/command_server.go index 430613ddb3..cab1da5b5a 100644 --- a/experimental/libbox/command_server.go +++ b/experimental/libbox/command_server.go @@ -7,7 +7,7 @@ import ( "path/filepath" "sync" - "github.com/imkira/go-observer" + "github.com/imkira/go-observer/v2" "github.com/sagernet/sing-box/common/urltest" "github.com/sagernet/sing-box/experimental/clashapi" "github.com/sagernet/sing-box/log" @@ -31,7 +31,7 @@ type CommandServer struct { service *BoxService // These channels only work with a single client. if multi-client support is needed, replace with Subscriber/Observer - urlTestUpdate observer.Property + urlTestUpdate observer.Property[int] modeUpdate chan struct{} logReset chan struct{} }