From 65629c0dfbe4f7a585d58956f87e64e8a38be053 Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Fri, 30 Jun 2023 11:07:27 +0800 Subject: [PATCH 1/4] change log to logrus --- cmd/cmd.go | 4 +-- cmd/server.go | 30 +++++++++++++------- core/xray/user.go | 2 -- core/xray/xray.go | 31 ++++++++++---------- limiter/clear.go | 8 ++++-- limiter/limiter.go | 5 ++-- node/controller.go | 4 +-- node/task.go | 71 ++++++++++++++++++++++++++++++++++------------ node/user.go | 9 ++++-- 9 files changed, 105 insertions(+), 59 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 8bf7d47..26f9130 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,7 +1,7 @@ package cmd import ( - "log" + log "github.com/sirupsen/logrus" _ "github.com/Yuzuki616/V2bX/core/imports" "github.com/spf13/cobra" @@ -14,6 +14,6 @@ var command = &cobra.Command{ func Run() { err := command.Execute() if err != nil { - log.Println("execute failed, error:", err) + log.WithField("err", err).Error("Execute command failed") } } diff --git a/cmd/server.go b/cmd/server.go index 1542389..34ceeae 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -1,7 +1,7 @@ package cmd import ( - "log" + log "github.com/sirupsen/logrus" "os" "os/signal" "runtime" @@ -42,23 +42,26 @@ func serverHandle(_ *cobra.Command, _ []string) { c := conf.New() err := c.LoadFromPath(config) if err != nil { - log.Fatalf("can't unmarshal config file: %s \n", err) + log.WithField("err", err).Error("Load config file failed") + return } limiter.Init() - log.Println("Start V2bX...") + log.Info("Start V2bX...") vc, err := vCore.NewCore(&c.CoreConfig) if err != nil { - log.Fatalf("New core error: %s", err) + log.WithField("err", err).Error("new core failed") + return } err = vc.Start() if err != nil { - log.Fatalf("Start core error: %s", err) + log.WithField("err", err).Error("Start core failed") + return } defer vc.Close() nodes := node.New() err = nodes.Start(c.NodesConfig, vc) if err != nil { - log.Fatalf("Run nodes error: %s", err) + log.WithField("err", err).Error("Run nodes failed") return } if watch { @@ -66,24 +69,29 @@ func serverHandle(_ *cobra.Command, _ []string) { nodes.Close() err = vc.Close() if err != nil { - log.Fatalf("Failed to restart xray-core: %s", err) + log.WithField("err", err).Error("Restart node failed") + return } vc, err = vCore.NewCore(&c.CoreConfig) if err != nil { - log.Fatalf("New core error: %s", err) + log.WithField("err", err).Error("New core failed") + return } err = vc.Start() if err != nil { - log.Fatalf("Start core error: %s", err) + log.WithField("err", err).Error("Start core failed") + return } err = nodes.Start(c.NodesConfig, vc) if err != nil { - log.Fatalf("Run nodes error: %s", err) + log.WithField("err", err).Error("Run nodes failed") + return } runtime.GC() }) if err != nil { - log.Fatalf("Watch config file error: %s", err) + log.WithField("err", err).Error("start watch failed") + return } } // clear memory diff --git a/core/xray/user.go b/core/xray/user.go index b5cc330..b2a51e4 100644 --- a/core/xray/user.go +++ b/core/xray/user.go @@ -73,10 +73,8 @@ func (c *Core) AddUsers(p *vCore.AddUsersParams) (added int, err error) { users := make([]*protocol.User, 0, len(p.UserInfo)) switch p.NodeInfo.Type { case "v2ray": - if p.Config.XrayOptions.EnableVless || p.NodeInfo.ExtraConfig.EnableVless { - if p.Config.XrayOptions.VlessFlow != "" { if p.Config.XrayOptions.VlessFlow == p.NodeInfo.ExtraConfig.VlessFlow { users = builder.BuildVlessUsers(p.Tag, p.UserInfo, p.Config.XrayOptions.VlessFlow) diff --git a/core/xray/xray.go b/core/xray/xray.go index 280eb10..2520e46 100644 --- a/core/xray/xray.go +++ b/core/xray/xray.go @@ -1,7 +1,6 @@ package xray import ( - "log" "os" "sync" @@ -10,6 +9,7 @@ import ( "github.com/Yuzuki616/V2bX/core/xray/app/dispatcher" _ "github.com/Yuzuki616/V2bX/core/xray/distro/all" "github.com/goccy/go-json" + log "github.com/sirupsen/logrus" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" "github.com/xtls/xray-core/common/serial" @@ -63,40 +63,40 @@ func getCore(c *conf.XrayConfig) *core.Instance { coreDnsConfig := &coreConf.DNSConfig{} if c.DnsConfigPath != "" { if f, err := os.Open(c.DnsConfigPath); err != nil { - log.Panicf("Failed to read DNS config file at: %s", c.DnsConfigPath) + log.WithField("err", err).Panic("Failed to read DNS config file") } else { if err = json.NewDecoder(f).Decode(coreDnsConfig); err != nil { - log.Panicf("Failed to unmarshal DNS config: %s", c.DnsConfigPath) + log.WithField("err", err).Panic("Failed to unmarshal DNS config") } } } dnsConfig, err := coreDnsConfig.Build() if err != nil { - log.Panicf("Failed to understand DNS config, Please check: https://xtls.github.io/config/dns.html for help: %s", err) + log.WithField("err", err).Panic("Failed to understand DNS config, Please check: https://xtls.github.io/config/dns.html for help") } // Routing config coreRouterConfig := &coreConf.RouterConfig{} if c.RouteConfigPath != "" { if f, err := os.Open(c.RouteConfigPath); err != nil { - log.Panicf("Failed to read Routing config file at: %s", c.RouteConfigPath) + log.WithField("err", err).Panic("Failed to read Routing config file") } else { if err = json.NewDecoder(f).Decode(coreRouterConfig); err != nil { - log.Panicf("Failed to unmarshal Routing config: %s", c.RouteConfigPath) + log.WithField("err", err).Panic("Failed to unmarshal Routing config") } } } routeConfig, err := coreRouterConfig.Build() if err != nil { - log.Panicf("Failed to understand Routing config Please check: https://xtls.github.io/config/routing.html for help: %s", err) + log.WithField("err", err).Panic("Failed to understand Routing config Please check: https://xtls.github.io/config/routing.html") } // Custom Inbound config var coreCustomInboundConfig []coreConf.InboundDetourConfig if c.InboundConfigPath != "" { if f, err := os.Open(c.InboundConfigPath); err != nil { - log.Panicf("Failed to read Custom Inbound config file at: %s", c.OutboundConfigPath) + log.WithField("err", err).Panic("Failed to read Custom Inbound config file") } else { if err = json.NewDecoder(f).Decode(&coreCustomInboundConfig); err != nil { - log.Panicf("Failed to unmarshal Custom Inbound config: %s", c.OutboundConfigPath) + log.WithField("err", err).Panic("Failed to unmarshal Custom Inbound config") } } } @@ -104,7 +104,7 @@ func getCore(c *conf.XrayConfig) *core.Instance { for _, config := range coreCustomInboundConfig { oc, err := config.Build() if err != nil { - log.Panicf("Failed to understand Inbound config, Please check: https://xtls.github.io/config/inbound.html for help: %s", err) + log.WithField("err", err).Panic("Failed to understand Inbound config, Please check: https://xtls.github.io/config/inbound.html for help") } inBoundConfig = append(inBoundConfig, oc) } @@ -112,10 +112,10 @@ func getCore(c *conf.XrayConfig) *core.Instance { var coreCustomOutboundConfig []coreConf.OutboundDetourConfig if c.OutboundConfigPath != "" { if f, err := os.Open(c.OutboundConfigPath); err != nil { - log.Panicf("Failed to read Custom Outbound config file at: %s", c.OutboundConfigPath) + log.WithField("err", err).Panic("Failed to read Custom Outbound config file") } else { if err = json.NewDecoder(f).Decode(&coreCustomOutboundConfig); err != nil { - log.Panicf("Failed to unmarshal Custom Outbound config: %s", c.OutboundConfigPath) + log.WithField("err", err).Panic("Failed to unmarshal Custom Outbound config") } } } @@ -123,7 +123,7 @@ func getCore(c *conf.XrayConfig) *core.Instance { for _, config := range coreCustomOutboundConfig { oc, err := config.Build() if err != nil { - log.Panicf("Failed to understand Outbound config, Please check: https://xtls.github.io/config/outbound.html for help: %s", err) + log.WithField("err", err).Panic("Failed to understand Outbound config, Please check: https://xtls.github.io/config/outbound.html for help") } outBoundConfig = append(outBoundConfig, oc) } @@ -149,10 +149,9 @@ func getCore(c *conf.XrayConfig) *core.Instance { } server, err := core.New(config) if err != nil { - log.Panicf("failed to create instance: %s", err) + log.WithField("err", err).Panic("failed to create instance") } - log.Printf("Core Version: %s", core.Version()) - + log.Info("Xray Core Version: ", core.Version()) return server } diff --git a/limiter/clear.go b/limiter/clear.go index 47db76f..a926854 100644 --- a/limiter/clear.go +++ b/limiter/clear.go @@ -1,14 +1,16 @@ package limiter -import "log" +import log "github.com/sirupsen/logrus" func ClearOnlineIP() error { - log.Println("Limiter: Clear online ip...") + log.WithField("Type", "Limiter"). + Debug("Clear online ip...") limitLock.RLock() for _, l := range limiter { l.ConnLimiter.ClearOnlineIP() } limitLock.RUnlock() - log.Println("Limiter: Clear online ip done") + log.WithField("Type", "Limiter"). + Debug("Clear online ip done") return nil } diff --git a/limiter/limiter.go b/limiter/limiter.go index f8faf07..45c4583 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -7,8 +7,8 @@ import ( "github.com/Yuzuki616/V2bX/common/builder" "github.com/Yuzuki616/V2bX/conf" "github.com/juju/ratelimit" + log "github.com/sirupsen/logrus" "github.com/xtls/xray-core/common/task" - "log" "regexp" "sync" "time" @@ -24,7 +24,8 @@ func Init() { Execute: ClearOnlineIP, } go func() { - log.Println("Limiter: ClearOnlineIP started") + log.WithField("Type", "Limiter"). + Debug("ClearOnlineIP started") time.Sleep(time.Minute * 2) _ = c.Start() }() diff --git a/node/controller.go b/node/controller.go index 85b0b4a..725b2ad 100644 --- a/node/controller.go +++ b/node/controller.go @@ -9,7 +9,7 @@ import ( "github.com/Yuzuki616/V2bX/conf" vCore "github.com/Yuzuki616/V2bX/core" "github.com/Yuzuki616/V2bX/limiter" - "log" + log "github.com/sirupsen/logrus" ) type Controller struct { @@ -81,7 +81,7 @@ func (c *Controller) Start() error { if err != nil { return fmt.Errorf("add users error: %s", err) } - log.Printf("[%s] Added %d new users", c.Tag, added) + log.WithField("tag", c.Tag).Infof("Added %d new users", added) c.initTask() return nil } diff --git a/node/task.go b/node/task.go index 0cc05de..d87b380 100644 --- a/node/task.go +++ b/node/task.go @@ -4,7 +4,7 @@ import ( "github.com/Yuzuki616/V2bX/common/task" vCore "github.com/Yuzuki616/V2bX/core" "github.com/Yuzuki616/V2bX/limiter" - "log" + log "github.com/sirupsen/logrus" "time" ) @@ -19,10 +19,10 @@ func (c *Controller) initTask() { Interval: c.nodeInfo.PushInterval, Execute: c.reportUserTrafficTask, } - log.Printf("[%s] Start monitor node status", c.Tag) + log.WithField("tag", c.Tag).Info("Start monitor node status") // delay to start nodeInfoMonitor _ = c.nodeInfoMonitorPeriodic.Start(false) - log.Printf("[%s] Start report node status", c.Tag) + log.WithField("tag", c.Tag).Info("Start report node status") _ = c.userReportPeriodic.Start(false) if c.nodeInfo.Tls { switch c.CertConfig.CertMode { @@ -32,7 +32,7 @@ func (c *Controller) initTask() { Interval: time.Hour * 24, Execute: c.reportUserTrafficTask, } - log.Printf("[%s] Start renew cert", c.Tag) + log.WithField("tag", c.Tag).Info("Start renew cert") // delay to start renewCert _ = c.renewCertPeriodic.Start(true) } @@ -43,22 +43,31 @@ func (c *Controller) nodeInfoMonitor() (err error) { // get node info newNodeInfo, err := c.apiClient.GetNodeInfo() if err != nil { - log.Printf("[%s] Get node info error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Get node info failed") return nil } // get user info newUserInfo, err := c.apiClient.GetUserList() if err != nil { - log.Printf("[%s] Get user list error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Get user list failed") return nil } if newNodeInfo != nil { // nodeInfo changed // Remove old tag - log.Printf("[%s] Node changed, reload...", c.Tag) + log.WithField("tag", c.Tag).Info("Node changed, reload") err = c.server.DelNode(c.Tag) if err != nil { - log.Printf("[%s] Del node error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Delete node failed") return nil } // Remove Old limiter @@ -70,13 +79,20 @@ func (c *Controller) nodeInfoMonitor() (err error) { if newNodeInfo.Tls || newNodeInfo.Type == "hysteria" { err = c.requestCert() if err != nil { - log.Printf("[%s] Request cert error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Request cert failed") + return nil } } // add new node err = c.server.AddNode(c.Tag, newNodeInfo, c.ControllerConfig) if err != nil { - log.Printf("[%s] Add node error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Add node failed") return nil } _, err = c.server.AddUsers(&vCore.AddUsersParams{ @@ -86,12 +102,19 @@ func (c *Controller) nodeInfoMonitor() (err error) { NodeInfo: newNodeInfo, }) if err != nil { - log.Printf("[%s] Add users error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Add users failed") return nil } err = l.UpdateRule(newNodeInfo.Rules) if err != nil { - log.Printf("[%s] Update Rule error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Update Rule failed") + return nil } // Check interval if c.nodeInfoMonitorPeriodic.Interval != newNodeInfo.PullInterval && @@ -108,7 +131,7 @@ func (c *Controller) nodeInfoMonitor() (err error) { } c.nodeInfo = newNodeInfo c.userList = newUserInfo - log.Printf("[%s] Added %d new users", c.Tag, len(newUserInfo)) + log.WithField("tag", c.Tag).Infof("Added %d new users", len(newUserInfo)) // exit return nil } @@ -119,7 +142,11 @@ func (c *Controller) nodeInfoMonitor() (err error) { // have deleted users err = c.server.DelUsers(deleted, c.Tag) if err != nil { - log.Printf("[%s] Del users error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Delete users failed") + return nil } } if len(added) > 0 { @@ -131,18 +158,26 @@ func (c *Controller) nodeInfoMonitor() (err error) { NodeInfo: c.nodeInfo, }) if err != nil { - log.Printf("[%s] Add users error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Add users failed") + return nil } } if len(added) > 0 || len(deleted) > 0 { // update Limiter err = limiter.UpdateLimiter(c.Tag, added, deleted) if err != nil { - log.Printf("[%s] Update limiter error: %s", c.Tag, err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("limiter users failed") + return nil } } c.userList = newUserInfo - log.Printf("[%s] %d user deleted, %d user added", c.Tag, - len(deleted), len(added)) + log.WithField("tag", c.Tag). + Errorf("%d user deleted, %d user added", len(deleted), len(added)) return nil } diff --git a/node/user.go b/node/user.go index d832b09..b8e95cc 100644 --- a/node/user.go +++ b/node/user.go @@ -2,7 +2,7 @@ package node import ( "github.com/Yuzuki616/V2bX/api/panel" - "log" + log "github.com/sirupsen/logrus" "runtime" "strconv" ) @@ -25,9 +25,12 @@ func (c *Controller) reportUserTrafficTask() (err error) { if len(userTraffic) > 0 { err = c.apiClient.ReportUserTraffic(userTraffic) if err != nil { - log.Printf("Report user traffic faild: %s", err) + log.WithFields(log.Fields{ + "tag": c.Tag, + "err": err, + }).Error("Report user traffic faild") } else { - log.Printf("[%s] Report %d online users", c.Tag, len(userTraffic)) + log.WithField("tag", err).Errorf("Report %d online users", len(userTraffic)) } } userTraffic = nil From c3242f35bd0ab7369aed98f0de7a91afffbfe928 Mon Sep 17 00:00:00 2001 From: Yuzuki616 Date: Sat, 8 Jul 2023 22:44:49 +0800 Subject: [PATCH 2/4] fix ProxyProtocol --- common/builder/inbound.go | 11 ++++++----- conf/node.go | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common/builder/inbound.go b/common/builder/inbound.go index dc576f9..18e62ee 100644 --- a/common/builder/inbound.go +++ b/common/builder/inbound.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/Yuzuki616/V2bX/api/panel" "github.com/Yuzuki616/V2bX/conf" "github.com/goccy/go-json" @@ -52,16 +53,16 @@ func BuildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s in.SniffingConfig = sniffingConfig if *in.StreamSetting.Network == "tcp" { if in.StreamSetting.TCPSettings != nil { - in.StreamSetting.TCPSettings.AcceptProxyProtocol = config.EnableProxyProtocol + in.StreamSetting.TCPSettings.AcceptProxyProtocol = config.XrayOptions.EnableProxyProtocol } else { tcpSetting := &coreConf.TCPConfig{ - AcceptProxyProtocol: config.EnableProxyProtocol, + AcceptProxyProtocol: config.XrayOptions.EnableProxyProtocol, } //Enable proxy protocol in.StreamSetting.TCPSettings = tcpSetting } } else if *in.StreamSetting.Network == "ws" { in.StreamSetting.WSSettings = &coreConf.WebSocketConfig{ - AcceptProxyProtocol: config.EnableProxyProtocol} //Enable proxy protocol + AcceptProxyProtocol: config.XrayOptions.EnableProxyProtocol} //Enable proxy protocol } // Set TLS or Reality settings if nodeInfo.Tls { @@ -104,9 +105,9 @@ func BuildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s // Support ProxyProtocol for any transport protocol if *in.StreamSetting.Network != "tcp" && *in.StreamSetting.Network != "ws" && - config.EnableProxyProtocol { + config.XrayOptions.EnableProxyProtocol { socketConfig := &coreConf.SocketConfig{ - AcceptProxyProtocol: config.EnableProxyProtocol, + AcceptProxyProtocol: config.XrayOptions.EnableProxyProtocol, TFO: config.XrayOptions.EnableTFO, } //Enable proxy protocol in.StreamSetting.SocketSettings = socketConfig diff --git a/conf/node.go b/conf/node.go index ac1b134..9304ef1 100644 --- a/conf/node.go +++ b/conf/node.go @@ -19,7 +19,6 @@ type ControllerConfig struct { DisableGetRule bool `yaml:"DisableGetRule"` ListenIP string `yaml:"ListenIP"` SendIP string `yaml:"SendIP"` - EnableProxyProtocol bool `yaml:"EnableProxyProtocol"` XrayOptions XrayOptions `yaml:"XrayOptions"` HyOptions HyOptions `yaml:"HyOptions"` LimitConfig LimitConfig `yaml:"LimitConfig"` @@ -27,16 +26,17 @@ type ControllerConfig struct { } type XrayOptions struct { - EnableDNS bool `yaml:"EnableDNS"` - DNSType string `yaml:"DNSType"` - EnableVless bool `yaml:"EnableVless"` - EnableXtls bool `yaml:"EnableXtls"` - EnableUot bool `yaml:"EnableUot"` - EnableTFO bool `yaml:"EnableTFO"` - DisableIVCheck bool `yaml:"DisableIVCheck"` - DisableSniffing bool `yaml:"DisableSniffing"` - EnableFallback bool `yaml:"EnableFallback"` - FallBackConfigs []FallBackConfig `yaml:"FallBackConfigs"` + EnableProxyProtocol bool `yaml:"EnableProxyProtocol"` + EnableDNS bool `yaml:"EnableDNS"` + DNSType string `yaml:"DNSType"` + EnableVless bool `yaml:"EnableVless"` + EnableXtls bool `yaml:"EnableXtls"` + EnableUot bool `yaml:"EnableUot"` + EnableTFO bool `yaml:"EnableTFO"` + DisableIVCheck bool `yaml:"DisableIVCheck"` + DisableSniffing bool `yaml:"DisableSniffing"` + EnableFallback bool `yaml:"EnableFallback"` + FallBackConfigs []FallBackConfig `yaml:"FallBackConfigs"` } type HyOptions struct { From 536a93dfc11d2e9c845ef1ac67b17f9534d362e6 Mon Sep 17 00:00:00 2001 From: Yuzuki616 Date: Sun, 9 Jul 2023 12:57:30 +0800 Subject: [PATCH 3/4] fix ProxyProtocol --- conf/node.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/conf/node.go b/conf/node.go index f8b38c9..b843a78 100644 --- a/conf/node.go +++ b/conf/node.go @@ -15,26 +15,26 @@ type ApiConfig struct { } type ControllerConfig struct { - ListenIP string `yaml:"ListenIP"` - SendIP string `yaml:"SendIP"` - EnableProxyProtocol bool `yaml:"EnableProxyProtocol"` - XrayOptions XrayOptions `yaml:"XrayOptions"` - HyOptions HyOptions `yaml:"HyOptions"` - LimitConfig LimitConfig `yaml:"LimitConfig"` - CertConfig *CertConfig `yaml:"CertConfig"` + ListenIP string `yaml:"ListenIP"` + SendIP string `yaml:"SendIP"` + XrayOptions XrayOptions `yaml:"XrayOptions"` + HyOptions HyOptions `yaml:"HyOptions"` + LimitConfig LimitConfig `yaml:"LimitConfig"` + CertConfig *CertConfig `yaml:"CertConfig"` } type XrayOptions struct { - EnableDNS bool `yaml:"EnableDNS"` - DNSType string `yaml:"DNSType"` - EnableVless bool `yaml:"EnableVless"` - VlessFlow string `json:"VlessFlow"` - EnableUot bool `yaml:"EnableUot"` - EnableTFO bool `yaml:"EnableTFO"` - DisableIVCheck bool `yaml:"DisableIVCheck"` - DisableSniffing bool `yaml:"DisableSniffing"` - EnableFallback bool `yaml:"EnableFallback"` - FallBackConfigs []FallBackConfig `yaml:"FallBackConfigs"` + EnableProxyProtocol bool `yaml:"EnableProxyProtocol"` + EnableDNS bool `yaml:"EnableDNS"` + DNSType string `yaml:"DNSType"` + EnableVless bool `yaml:"EnableVless"` + VlessFlow string `json:"VlessFlow"` + EnableUot bool `yaml:"EnableUot"` + EnableTFO bool `yaml:"EnableTFO"` + DisableIVCheck bool `yaml:"DisableIVCheck"` + DisableSniffing bool `yaml:"DisableSniffing"` + EnableFallback bool `yaml:"EnableFallback"` + FallBackConfigs []FallBackConfig `yaml:"FallBackConfigs"` } type HyOptions struct { From 848c7b014a3c3055534e4884a551c26e87412144 Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Thu, 13 Jul 2023 01:19:13 +0800 Subject: [PATCH 4/4] fix bugs --- common/builder/user.go | 2 +- conf/core.go | 2 +- conf/log.go | 2 +- node/task.go | 6 ++++-- node/user.go | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/common/builder/user.go b/common/builder/user.go index bde1c86..91a5399 100644 --- a/common/builder/user.go +++ b/common/builder/user.go @@ -105,7 +105,7 @@ func BuildSSUser(tag string, userInfo *panel.UserInfo, cypher string, serverKey } return &protocol.User{ Level: 0, - Email: tag, + Email: BuildUserTag(tag, userInfo.Uuid), Account: serial.ToTypedMessage(ssAccount), } } diff --git a/conf/core.go b/conf/core.go index ce4fc08..45b8ce2 100644 --- a/conf/core.go +++ b/conf/core.go @@ -2,7 +2,7 @@ package conf type CoreConfig struct { Type string `yaml:"Type"` - XrayConfig *XrayConfig `yaml:"Xray"` + XrayConfig *XrayConfig `yaml:"XrayConfig"` } type XrayConfig struct { diff --git a/conf/log.go b/conf/log.go index 4380c21..86bb6d1 100644 --- a/conf/log.go +++ b/conf/log.go @@ -8,7 +8,7 @@ type LogConfig struct { func NewLogConfig() *LogConfig { return &LogConfig{ - Level: "none", + Level: "warning", AccessPath: "", ErrorPath: "", } diff --git a/node/task.go b/node/task.go index d87b380..550f11d 100644 --- a/node/task.go +++ b/node/task.go @@ -177,7 +177,9 @@ func (c *Controller) nodeInfoMonitor() (err error) { } } c.userList = newUserInfo - log.WithField("tag", c.Tag). - Errorf("%d user deleted, %d user added", len(deleted), len(added)) + if len(added)+len(deleted) != 0 { + log.WithField("tag", c.Tag). + Infof("%d user deleted, %d user added", len(deleted), len(added)) + } return nil } diff --git a/node/user.go b/node/user.go index b8e95cc..91aa5df 100644 --- a/node/user.go +++ b/node/user.go @@ -28,9 +28,9 @@ func (c *Controller) reportUserTrafficTask() (err error) { log.WithFields(log.Fields{ "tag": c.Tag, "err": err, - }).Error("Report user traffic faild") + }).Info("Report user traffic failed") } else { - log.WithField("tag", err).Errorf("Report %d online users", len(userTraffic)) + log.WithField("tag", c.Tag).Infof("Report %d online users", len(userTraffic)) } } userTraffic = nil