mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-23 10:28:13 -05:00
ca67855ec9
fix deps cycle update example fix color for X25519 output supported cores message
33 lines
547 B
Go
33 lines
547 B
Go
package core
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
|
|
"github.com/Yuzuki616/V2bX/conf"
|
|
)
|
|
|
|
var (
|
|
cores = map[string]func(c *conf.CoreConfig) (Core, error){}
|
|
)
|
|
|
|
func NewCore(c *conf.CoreConfig) (Core, error) {
|
|
if f, ok := cores[strings.ToLower(c.Type)]; ok {
|
|
return f(c)
|
|
} else {
|
|
return nil, errors.New("unknown core type")
|
|
}
|
|
}
|
|
|
|
func RegisterCore(t string, f func(c *conf.CoreConfig) (Core, error)) {
|
|
cores[t] = f
|
|
}
|
|
|
|
func RegisteredCore() []string {
|
|
cs := make([]string, 0, len(cores))
|
|
for k := range cores {
|
|
cs = append(cs, k)
|
|
}
|
|
return cs
|
|
}
|