diff --git a/cmd/cmd.go b/cmd/cmd.go index aba47fc..8bf7d47 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,8 +1,10 @@ package cmd import ( - "github.com/spf13/cobra" "log" + + _ "github.com/Yuzuki616/V2bX/core/imports" + "github.com/spf13/cobra" ) var command = &cobra.Command{ diff --git a/cmd/version.go b/cmd/version.go index 0f2b0ce..4b5332a 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -2,7 +2,9 @@ package cmd import ( "fmt" + "strings" + vCore "github.com/Yuzuki616/V2bX/core" "github.com/spf13/cobra" ) @@ -26,6 +28,7 @@ func init() { func showVersion() { fmt.Printf("%s %s (%s) \n", codename, version, intro) + fmt.Printf("Supported cores: %s\n", strings.Join(vCore.RegisteredCore(), ", ")) // Warning fmt.Println(Warn("This version need V2board version >= 1.7.0.")) } diff --git a/cmd/x25519.go b/cmd/x25519.go index 2e3b9a3..791a4b0 100644 --- a/cmd/x25519.go +++ b/cmd/x25519.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/base64" "fmt" + "github.com/spf13/cobra" "golang.org/x/crypto/curve25519" ) @@ -45,7 +46,7 @@ func executeX25519() { return } - output = Err("Private key: ", + output = fmt.Sprint("Private key: ", base64.RawURLEncoding.EncodeToString(privateKey), "\nPublic key: ", base64.RawURLEncoding.EncodeToString(publicKey)) diff --git a/core/core.go b/core/core.go index 946e7da..6f02499 100644 --- a/core/core.go +++ b/core/core.go @@ -2,6 +2,8 @@ package core import ( "errors" + "strings" + "github.com/Yuzuki616/V2bX/conf" ) @@ -10,7 +12,7 @@ var ( ) func NewCore(c *conf.CoreConfig) (Core, error) { - if f, ok := cores[c.Type]; ok { + if f, ok := cores[strings.ToLower(c.Type)]; ok { return f(c) } else { return nil, errors.New("unknown core type") @@ -20,3 +22,11 @@ func NewCore(c *conf.CoreConfig) (Core, error) { 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 +} diff --git a/core/hy.go b/core/imports/hy.go similarity index 84% rename from core/hy.go rename to core/imports/hy.go index f3834c7..b59cbc3 100644 --- a/core/hy.go +++ b/core/imports/hy.go @@ -1,6 +1,6 @@ //go:build hy -package core +package imports // not works for now //import _ "github.com/Yuzuki616/V2bX/core/hy" diff --git a/core/xray.go b/core/imports/xray.go similarity index 80% rename from core/xray.go rename to core/imports/xray.go index 47afd9a..24c806d 100644 --- a/core/xray.go +++ b/core/imports/xray.go @@ -1,5 +1,5 @@ //go:build xray -package core +package imports import _ "github.com/Yuzuki616/V2bX/core/xray" diff --git a/core/xray/distro/all/all.go b/core/xray/distro/all/all.go index 8f2186c..1a5f307 100644 --- a/core/xray/distro/all/all.go +++ b/core/xray/distro/all/all.go @@ -4,7 +4,7 @@ import ( // The following are necessary as they register handlers in their init functions. // Mandatory features. Can't remove unless there are replacements. - _ "github.com/xtls/xray-core/app/dispatcher" + _ "github.com/Yuzuki616/V2bX/core/xray/app/dispatcher" _ "github.com/xtls/xray-core/app/proxyman/inbound" _ "github.com/xtls/xray-core/app/proxyman/outbound" diff --git a/example/config.yml.example b/example/config.yml.example index 3ab664b..4588845 100644 --- a/example/config.yml.example +++ b/example/config.yml.example @@ -1,17 +1,20 @@ -Log: - Level: warning # Log level: none, error, warning, info, debug - AccessPath: # /etc/XrayR/access.Log - ErrorPath: # /etc/XrayR/error.log -DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help -RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help -InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help -OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help -ConnetionConfig: - Handshake: 4 # Handshake time limit, Second - ConnIdle: 30 # Connection idle time limit, Second - UplinkOnly: 2 # Time limit when the connection downstream is closed, Second - DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second - BufferSize: 64 # The internal cache size of each connection, kB +CoreConfig: + Type: "xray" # Core type + XrayConfig: + Log: + Level: warning # Log level: none, error, warning, info, debug + AccessPath: # /etc/XrayR/access.Log + ErrorPath: # /etc/XrayR/error.log + DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help + RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help + InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help + OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help + ConnectionConfig: + Handshake: 4 # Handshake time limit, Second + ConnIdle: 30 # Connection idle time limit, Second + UplinkOnly: 2 # Time limit when the connection downstream is closed, Second + DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second + BufferSize: 64 # The internal cache size of each connection, kB Nodes: - ApiConfig: ApiHost: "http://127.0.0.1:667"