diff --git a/server/app.go b/server/app.go index 5509733..1482139 100644 --- a/server/app.go +++ b/server/app.go @@ -45,9 +45,9 @@ func (app *App) httpSvr() { server := &http.Server{ Addr: app.cfg.ListenAddr(), Handler: mux, - ReadTimeout: 180 * time.Second, - WriteTimeout: 180 * time.Second, - IdleTimeout: 180 * time.Second, + ReadTimeout: 60 * time.Second, + WriteTimeout: 60 * time.Second, + IdleTimeout: 60 * time.Second, } app.svr = server @@ -66,8 +66,9 @@ func NewApp(c *global.Config, sig chan os.Signal) *App { }, }, upGrader: &websocket.Upgrader{ - ReadBufferSize: bufferSize, - WriteBufferSize: bufferSize, + HandshakeTimeout: 2 * time.Second, + ReadBufferSize: bufferSize, + WriteBufferSize: bufferSize, CheckOrigin: func(r *http.Request) bool { // Allow all connections by default return true diff --git a/server/app_ws_vless.go b/server/app_ws_vless.go index d909093..bbae4b0 100644 --- a/server/app_ws_vless.go +++ b/server/app_ws_vless.go @@ -212,6 +212,7 @@ func (app *App) vlessUDP(_ context.Context, sv *schema.ProtoVLESS, ws *websocket buf := app.bufferPool.Get().([]byte) defer app.bufferPool.Put(buf) + conn.SetDeadline(time.Now().Add(2 * time.Second)) n, err := conn.Read(buf) if err != nil { logger.Error("Error reading from UDP connection:", "err", err)