|
|
@@ -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
|
|
|
+ }))
|
|
|
+}
|