mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
instance manager: create instance with API(fix)
This commit is contained in:
parent
3940b6f156
commit
c7c4effbd2
@ -3,6 +3,7 @@ package instman
|
||||
import (
|
||||
"context"
|
||||
core "github.com/v2fly/v2ray-core/v4"
|
||||
"github.com/v2fly/v2ray-core/v4/common"
|
||||
"github.com/v2fly/v2ray-core/v4/features/extension"
|
||||
)
|
||||
|
||||
@ -66,3 +67,18 @@ func (i InstanceMgr) UntrackInstance(ctx context.Context, name string) error {
|
||||
delete(i.instances, name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewInstanceMgr(ctx context.Context, config *Config) (extension.InstanceManagement, error) {
|
||||
return InstanceMgr{instances: map[string]*core.Instance{}}, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
||||
var f extension.InstanceManagement
|
||||
var err error
|
||||
if f, err = NewInstanceMgr(ctx, config.(*Config)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return f, nil
|
||||
}))
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
_ "github.com/v2fly/v2ray-core/v4/app/stats/command"
|
||||
|
||||
// Developer preview services
|
||||
_ "github.com/v2fly/v2ray-core/v4/app/instman/command"
|
||||
_ "github.com/v2fly/v2ray-core/v4/app/observatory/command"
|
||||
|
||||
// Other optional features.
|
||||
@ -30,6 +31,7 @@ import (
|
||||
_ "github.com/v2fly/v2ray-core/v4/transport/internet/tagged/taggedimpl"
|
||||
|
||||
// Developer preview features
|
||||
_ "github.com/v2fly/v2ray-core/v4/app/instman"
|
||||
_ "github.com/v2fly/v2ray-core/v4/app/observatory"
|
||||
|
||||
// Inbound and outbound proxies.
|
||||
|
Loading…
Reference in New Issue
Block a user