From f02bddd1fe43b34bb159b2c925c64f7a08c23a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A1=D0=B0?= =?UTF-8?q?=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sat, 25 Oct 2025 14:55:26 +0300 Subject: [PATCH] add debug recover --- web/controller/inbound.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/controller/inbound.go b/web/controller/inbound.go index e0ef4433..200dd43e 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "runtime/debug" "strconv" "github.com/mhsanaei/3x-ui/v2/database/model" @@ -30,6 +31,15 @@ func NewInboundController(g *gin.RouterGroup) *InboundController { // initRouter initializes the routes for inbound-related operations. func (a *InboundController) initRouter(g *gin.RouterGroup) { + g.Use(func(c *gin.Context) { + defer func() { + if rec := recover(); rec != nil { + logger.Errorf("PANIC: %v\nStack: %s", rec, debug.Stack()) + c.AbortWithStatusJSON(500, gin.H{"msg": fmt.Sprintf("panic: %v", rec)}) + } + }() + c.Next() + }) g.GET("/list", a.getInbounds) g.GET("/get/:id", a.getInbound)