mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-26 13:06:56 +00:00
Refactor lifecycle to scoped cleanup
This commit is contained in:
@@ -73,7 +73,10 @@ func (s *Selector) Network() []string {
|
||||
return selected.Network()
|
||||
}
|
||||
|
||||
func (s *Selector) Start() error {
|
||||
func (s *Selector) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
if stage != adapter.StartStateStart {
|
||||
return nil
|
||||
}
|
||||
for i, tag := range s.tags {
|
||||
detour, loaded := s.outbound.Outbound(tag)
|
||||
if !loaded {
|
||||
|
||||
@@ -71,7 +71,7 @@ func NewURLTest(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
return outbound, nil
|
||||
}
|
||||
|
||||
func (s *URLTest) Start(stage adapter.StartStage) error {
|
||||
func (s *URLTest) Start(stage adapter.StartStage, scope *adapter.Scope) error {
|
||||
switch stage {
|
||||
case adapter.StartStateStart:
|
||||
outbounds := make([]adapter.Outbound, 0, len(s.tags))
|
||||
@@ -89,16 +89,11 @@ func (s *URLTest) Start(stage adapter.StartStage) error {
|
||||
s.group = group
|
||||
case adapter.StartStateStarted:
|
||||
s.group.PostStart()
|
||||
scope.Add(s.group.Close)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *URLTest) Close() error {
|
||||
return common.Close(
|
||||
common.PtrOrNil(s.group),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *URLTest) Now() string {
|
||||
if s.group.selectedOutboundTCP != nil {
|
||||
return s.group.selectedOutboundTCP.Tag()
|
||||
|
||||
Reference in New Issue
Block a user