mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-04 01:17:15 +00:00
fix dead code, typo, and minor bugs in main.go, process.go and index.go (#6167)
Fixes several small issues found during code review: - fix(xray): return explicit nil instead of stale err in getLogPath - fix(xray): remove duplicate doc comment on GetErrorLogPath - refactor: remove unreachable return after log.Fatalf (×4) - fix(cli): add missing newline to listen IP success message - fix(cli): typo "form" → "from" in migrate help text - refactor: simplify var+assign to short declaration for server/subServer - fix(controller): return error from getTwoFactorEnable instead of swallowing it
This commit is contained in:
@@ -163,7 +163,5 @@ func (a *IndexController) csrfToken(c *gin.Context) {
|
|||||||
// getTwoFactorEnable retrieves the current status of two-factor authentication.
|
// getTwoFactorEnable retrieves the current status of two-factor authentication.
|
||||||
func (a *IndexController) getTwoFactorEnable(c *gin.Context) {
|
func (a *IndexController) getTwoFactorEnable(c *gin.Context) {
|
||||||
status, err := a.settingService.GetTwoFactorEnable()
|
status, err := a.settingService.GetTwoFactorEnable()
|
||||||
if err == nil {
|
jsonObj(c, status, err)
|
||||||
jsonObj(c, status, nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func getLogPath(key string) (string, error) {
|
|||||||
return logPath, nil
|
return logPath, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", err
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccessLogPath reads the Xray config and returns the access log file path.
|
// GetAccessLogPath reads the Xray config and returns the access log file path.
|
||||||
@@ -93,7 +93,6 @@ func GetAccessLogPath() (string, error) {
|
|||||||
return getLogPath("access")
|
return getLogPath("access")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetErrorLogPath reads the Xray config and returns the error log file path.
|
|
||||||
// GetErrorLogPath reads the Xray config and returns the error log file path.
|
// GetErrorLogPath reads the Xray config and returns the error log file path.
|
||||||
func GetErrorLogPath() (string, error) {
|
func GetErrorLogPath() (string, error) {
|
||||||
return getLogPath("error")
|
return getLogPath("error")
|
||||||
|
|||||||
@@ -71,24 +71,20 @@ func runWebServer() {
|
|||||||
log.Fatalf("Error initializing database: %v", err)
|
log.Fatalf("Error initializing database: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var server *web.Server
|
server := web.NewServer()
|
||||||
server = web.NewServer()
|
|
||||||
global.SetWebServer(server)
|
global.SetWebServer(server)
|
||||||
err = server.Start()
|
err = server.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error starting web server: %v", err)
|
log.Fatalf("Error starting web server: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var subServer *sub.Server
|
|
||||||
sub.SetDistFS(web.EmbeddedDist())
|
sub.SetDistFS(web.EmbeddedDist())
|
||||||
service.RegisterSubLinkProvider(sub.NewLinkProvider())
|
service.RegisterSubLinkProvider(sub.NewLinkProvider())
|
||||||
subServer = sub.NewServer()
|
subServer := sub.NewServer()
|
||||||
global.SetSubServer(subServer)
|
global.SetSubServer(subServer)
|
||||||
err = subServer.Start()
|
err = subServer.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error starting sub server: %v", err)
|
log.Fatalf("Error starting sub server: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sigCh := make(chan os.Signal, 8)
|
sigCh := make(chan os.Signal, 8)
|
||||||
@@ -142,7 +138,6 @@ func runWebServer() {
|
|||||||
err = server.StartPanelOnly()
|
err = server.StartPanelOnly()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error restarting web server: %v", err)
|
log.Fatalf("Error restarting web server: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
log.Println("Web server restarted successfully.")
|
log.Println("Web server restarted successfully.")
|
||||||
|
|
||||||
@@ -152,7 +147,6 @@ func runWebServer() {
|
|||||||
err = subServer.Start()
|
err = subServer.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error restarting sub server: %v", err)
|
log.Fatalf("Error restarting sub server: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
log.Println("Sub server restarted successfully.")
|
log.Println("Sub server restarted successfully.")
|
||||||
case sys.SIGUSR1:
|
case sys.SIGUSR1:
|
||||||
@@ -360,7 +354,7 @@ func updateSetting(port int, username string, password string, webBasePath strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to set listen IP:", err)
|
fmt.Println("Failed to set listen IP:", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("listen %v set successfully", listenIP)
|
fmt.Printf("listen %v set successfully\n", listenIP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +573,7 @@ func main() {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Commands:")
|
fmt.Println("Commands:")
|
||||||
fmt.Println(" run run web panel")
|
fmt.Println(" run run web panel")
|
||||||
fmt.Println(" migrate migrate form other/old x-ui")
|
fmt.Println(" migrate migrate from other/old x-ui")
|
||||||
fmt.Println(" migrate-db SQLite <-> .dump (--dump/--restore) or copy into PostgreSQL (--dsn)")
|
fmt.Println(" migrate-db SQLite <-> .dump (--dump/--restore) or copy into PostgreSQL (--dsn)")
|
||||||
fmt.Println(" setting set settings")
|
fmt.Println(" setting set settings")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user