1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

instance manager: create instance with API(fix)

This commit is contained in:
Shelikhoo 2021-06-28 21:16:48 +01:00
parent 3940b6f156
commit c7c4effbd2
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
2 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package instman
import ( import (
"context" "context"
core "github.com/v2fly/v2ray-core/v4" core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/features/extension" "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) delete(i.instances, name)
return nil 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
}))
}

View File

@ -15,6 +15,7 @@ import (
_ "github.com/v2fly/v2ray-core/v4/app/stats/command" _ "github.com/v2fly/v2ray-core/v4/app/stats/command"
// Developer preview services // Developer preview services
_ "github.com/v2fly/v2ray-core/v4/app/instman/command"
_ "github.com/v2fly/v2ray-core/v4/app/observatory/command" _ "github.com/v2fly/v2ray-core/v4/app/observatory/command"
// Other optional features. // Other optional features.
@ -30,6 +31,7 @@ import (
_ "github.com/v2fly/v2ray-core/v4/transport/internet/tagged/taggedimpl" _ "github.com/v2fly/v2ray-core/v4/transport/internet/tagged/taggedimpl"
// Developer preview features // Developer preview features
_ "github.com/v2fly/v2ray-core/v4/app/instman"
_ "github.com/v2fly/v2ray-core/v4/app/observatory" _ "github.com/v2fly/v2ray-core/v4/app/observatory"
// Inbound and outbound proxies. // Inbound and outbound proxies.