fix deps cycle
update example
fix color for X25519
output supported cores message
This commit is contained in:
Yuzuki616 2023-06-08 03:11:42 +08:00
parent 0958e351f0
commit ca67855ec9
8 changed files with 39 additions and 20 deletions

View File

@ -1,8 +1,10 @@
package cmd package cmd
import ( import (
"github.com/spf13/cobra"
"log" "log"
_ "github.com/Yuzuki616/V2bX/core/imports"
"github.com/spf13/cobra"
) )
var command = &cobra.Command{ var command = &cobra.Command{

View File

@ -2,7 +2,9 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
vCore "github.com/Yuzuki616/V2bX/core"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -26,6 +28,7 @@ func init() {
func showVersion() { func showVersion() {
fmt.Printf("%s %s (%s) \n", codename, version, intro) fmt.Printf("%s %s (%s) \n", codename, version, intro)
fmt.Printf("Supported cores: %s\n", strings.Join(vCore.RegisteredCore(), ", "))
// Warning // Warning
fmt.Println(Warn("This version need V2board version >= 1.7.0.")) fmt.Println(Warn("This version need V2board version >= 1.7.0."))
} }

View File

@ -4,6 +4,7 @@ import (
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/crypto/curve25519" "golang.org/x/crypto/curve25519"
) )
@ -45,7 +46,7 @@ func executeX25519() {
return return
} }
output = Err("Private key: ", output = fmt.Sprint("Private key: ",
base64.RawURLEncoding.EncodeToString(privateKey), base64.RawURLEncoding.EncodeToString(privateKey),
"\nPublic key: ", "\nPublic key: ",
base64.RawURLEncoding.EncodeToString(publicKey)) base64.RawURLEncoding.EncodeToString(publicKey))

View File

@ -2,6 +2,8 @@ package core
import ( import (
"errors" "errors"
"strings"
"github.com/Yuzuki616/V2bX/conf" "github.com/Yuzuki616/V2bX/conf"
) )
@ -10,7 +12,7 @@ var (
) )
func NewCore(c *conf.CoreConfig) (Core, error) { 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) return f(c)
} else { } else {
return nil, errors.New("unknown core type") 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)) { func RegisterCore(t string, f func(c *conf.CoreConfig) (Core, error)) {
cores[t] = f cores[t] = f
} }
func RegisteredCore() []string {
cs := make([]string, 0, len(cores))
for k := range cores {
cs = append(cs, k)
}
return cs
}

View File

@ -1,6 +1,6 @@
//go:build hy //go:build hy
package core package imports
// not works for now // not works for now
//import _ "github.com/Yuzuki616/V2bX/core/hy" //import _ "github.com/Yuzuki616/V2bX/core/hy"

View File

@ -1,5 +1,5 @@
//go:build xray //go:build xray
package core package imports
import _ "github.com/Yuzuki616/V2bX/core/xray" import _ "github.com/Yuzuki616/V2bX/core/xray"

View File

@ -4,7 +4,7 @@ import (
// The following are necessary as they register handlers in their init functions. // The following are necessary as they register handlers in their init functions.
// Mandatory features. Can't remove unless there are replacements. // 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/inbound"
_ "github.com/xtls/xray-core/app/proxyman/outbound" _ "github.com/xtls/xray-core/app/proxyman/outbound"

View File

@ -1,3 +1,6 @@
CoreConfig:
Type: "xray" # Core type
XrayConfig:
Log: Log:
Level: warning # Log level: none, error, warning, info, debug Level: warning # Log level: none, error, warning, info, debug
AccessPath: # /etc/XrayR/access.Log AccessPath: # /etc/XrayR/access.Log
@ -6,7 +9,7 @@ DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.gi
RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.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 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 OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help
ConnetionConfig: ConnectionConfig:
Handshake: 4 # Handshake time limit, Second Handshake: 4 # Handshake time limit, Second
ConnIdle: 30 # Connection idle time limit, Second ConnIdle: 30 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second UplinkOnly: 2 # Time limit when the connection downstream is closed, Second