mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
fix: cannot start tun
This commit is contained in:
parent
c6c1cdbb4f
commit
2617a4c332
@ -57,22 +57,21 @@ func (t *TUN) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewTUN(ctx context.Context, config *Config, dispatcher routing.Dispatcher) *TUN {
|
||||
v := core.MustFromContext(ctx)
|
||||
return &TUN{
|
||||
ctx: ctx,
|
||||
dispatcher: dispatcher,
|
||||
config: config,
|
||||
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
|
||||
}
|
||||
func (t *TUN) Init(ctx context.Context, config *Config, dispatcher routing.Dispatcher, policyManager policy.Manager) error {
|
||||
t.ctx = ctx
|
||||
t.config = config
|
||||
t.dispatcher = dispatcher
|
||||
t.policyManager = policyManager
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
||||
tun := core.RequireFeatures(ctx, func(d routing.Dispatcher) *TUN {
|
||||
return NewTUN(ctx, config.(*Config), d)
|
||||
tun := new(TUN)
|
||||
err := core.RequireFeatures(ctx, func(d routing.Dispatcher, p policy.Manager) error {
|
||||
return tun.Init(ctx, config.(*Config), d, p)
|
||||
})
|
||||
|
||||
return tun, nil
|
||||
return tun, err
|
||||
}))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user