update singbox

This commit is contained in:
Yuzuki616
2023-10-26 14:06:43 +09:00
parent 7f5b0893f9
commit f928b4f8f3
17 changed files with 186 additions and 608 deletions

View File

@@ -22,12 +22,14 @@ import (
coreConf "github.com/xtls/xray-core/infra/conf"
)
var _ vCore.Core = (*Xray)(nil)
func init() {
vCore.RegisterCore("xray", New)
}
// Core Structure
type Core struct {
// Xray Structure
type Xray struct {
access sync.Mutex
Server *core.Instance
ihm inbound.Manager
@@ -37,7 +39,7 @@ type Core struct {
}
func New(c *conf.CoreConfig) (vCore.Core, error) {
return &Core{Server: getCore(c.XrayConfig)}, nil
return &Xray{Server: getCore(c.XrayConfig)}, nil
}
func parseConnectionConfig(c *conf.XrayConnectionConfig) (policy *coreConf.Policy) {
@@ -137,7 +139,7 @@ func getCore(c *conf.XrayConfig) *core.Instance {
corePolicyConfig := &coreConf.PolicyConfig{}
corePolicyConfig.Levels = map[uint32]*coreConf.Policy{0: levelPolicyConfig}
policyConfig, _ := corePolicyConfig.Build()
// Build Core conf
// Build Xray conf
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(coreLogConfig.Build()),
@@ -160,8 +162,8 @@ func getCore(c *conf.XrayConfig) *core.Instance {
return server
}
// Start the Core
func (c *Core) Start() error {
// Start the Xray
func (c *Xray) Start() error {
c.access.Lock()
defer c.access.Unlock()
if err := c.Server.Start(); err != nil {
@@ -175,7 +177,7 @@ func (c *Core) Start() error {
}
// Close the core
func (c *Core) Close() error {
func (c *Xray) Close() error {
c.access.Lock()
defer c.access.Unlock()
c.ihm = nil
@@ -189,7 +191,7 @@ func (c *Core) Close() error {
return nil
}
func (c *Core) Protocols() []string {
func (c *Xray) Protocols() []string {
return []string{
"vmess",
"vless",
@@ -198,6 +200,6 @@ func (c *Core) Protocols() []string {
}
}
func (c *Core) Type() string {
func (c *Xray) Type() string {
return "xray"
}