mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-05 21:07:38 +03:00
refactor: Modular inbound/outbound manager
This commit is contained in:
parent
0f7ffeed5c
commit
3310d0716e
69 changed files with 1186 additions and 754 deletions
33
adapter/lifecycle_legacy.go
Normal file
33
adapter/lifecycle_legacy.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package adapter
|
||||
|
||||
type LegacyPreStarter interface {
|
||||
PreStart() error
|
||||
}
|
||||
|
||||
type LegacyPostStarter interface {
|
||||
PostStart() error
|
||||
}
|
||||
|
||||
func LegacyStart(starter any, stage StartStage) error {
|
||||
switch stage {
|
||||
case StartStateInitialize:
|
||||
if preStarter, isPreStarter := starter.(interface {
|
||||
PreStart() error
|
||||
}); isPreStarter {
|
||||
return preStarter.PreStart()
|
||||
}
|
||||
case StartStateStart:
|
||||
if starter, isStarter := starter.(interface {
|
||||
Start() error
|
||||
}); isStarter {
|
||||
return starter.Start()
|
||||
}
|
||||
case StartStatePostStart:
|
||||
if postStarter, isPostStarter := starter.(interface {
|
||||
PostStart() error
|
||||
}); isPostStarter {
|
||||
return postStarter.PostStart()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue