mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-15 10:33:59 +00:00
protocol: Forward lifecycle Start stage to nested outbounds in vpn, failover and limiters
This commit is contained in:
@@ -24,6 +24,8 @@ func RegisterOutbound(registry *outbound.Registry) {
|
||||
outbound.Register[option.BandwidthLimiterOutboundOptions](registry, C.TypeBandwidthLimiter, NewOutbound)
|
||||
}
|
||||
|
||||
var _ adapter.Lifecycle = (*Outbound)(nil)
|
||||
|
||||
type Outbound struct {
|
||||
outbound.Adapter
|
||||
ctx context.Context
|
||||
@@ -87,19 +89,19 @@ func (h *Outbound) Network() []string {
|
||||
return []string{N.NetworkTCP, N.NetworkUDP}
|
||||
}
|
||||
|
||||
func (h *Outbound) Start() error {
|
||||
detour, loaded := h.outbound.Outbound(h.outboundTag)
|
||||
if !loaded {
|
||||
return E.New("outbound not found: ", h.outboundTag)
|
||||
}
|
||||
h.detour = detour
|
||||
for _, stage := range []adapter.StartStage{adapter.StartStateStart, adapter.StartStatePostStart, adapter.StartStateStarted} {
|
||||
err := h.router.Start(stage)
|
||||
if err != nil {
|
||||
return err
|
||||
func (h *Outbound) Start(stage adapter.StartStage) error {
|
||||
if stage == adapter.StartStateStart {
|
||||
detour, loaded := h.outbound.Outbound(h.outboundTag)
|
||||
if !loaded {
|
||||
return E.New("outbound not found: ", h.outboundTag)
|
||||
}
|
||||
h.detour = detour
|
||||
}
|
||||
return nil
|
||||
return h.router.Start(stage)
|
||||
}
|
||||
|
||||
func (h *Outbound) Close() error {
|
||||
return h.router.Close()
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
|
||||
Reference in New Issue
Block a user