From a6baab92f39f82d44341f1284155cba5610780b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 24 Aug 2022 19:03:00 +0800 Subject: [PATCH] Fix early close on windows and catch any --- box.go | 11 +++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/box.go b/box.go index 34f753c0..d8b711de 100644 --- a/box.go +++ b/box.go @@ -2,8 +2,10 @@ package box import ( "context" + "fmt" "io" "os" + "runtime/debug" "time" "github.com/sagernet/sing-box/adapter" @@ -170,6 +172,15 @@ func New(ctx context.Context, options option.Options) (*Box, error) { func (s *Box) Start() error { err := s.start() if err != nil { + // TODO: remove catch error + defer func() { + v := recover() + if v != nil { + log.Error(E.Cause(err, "origin error")) + debug.PrintStack() + panic("panic on early close: " + fmt.Sprint(v)) + } + }() s.Close() } return err diff --git a/go.mod b/go.mod index 06aa240e..68320359 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/sagernet/sing v0.0.0-20220824062950-7bfd820739a8 github.com/sagernet/sing-dns v0.0.0-20220822023312-3e086b06d666 github.com/sagernet/sing-shadowsocks v0.0.0-20220819002358-7461bb09a8f6 - github.com/sagernet/sing-tun v0.0.0-20220822073626-d5efb431220d + github.com/sagernet/sing-tun v0.0.0-20220824105617-e5c59fc756a6 github.com/sagernet/sing-vmess v0.0.0-20220811135656-4f3f07acf9c4 github.com/sagernet/smux v0.0.0-20220812084127-e2d085ee3939 github.com/spf13/cobra v1.5.0 diff --git a/go.sum b/go.sum index 4cbf8ad1..76d90c63 100644 --- a/go.sum +++ b/go.sum @@ -148,8 +148,8 @@ github.com/sagernet/sing-dns v0.0.0-20220822023312-3e086b06d666 h1:XUTocA/Ek0dFx github.com/sagernet/sing-dns v0.0.0-20220822023312-3e086b06d666/go.mod h1:eDyH7AJmqBGjZQdQmpZIzlbTREudZuWDExMuGKgjRVM= github.com/sagernet/sing-shadowsocks v0.0.0-20220819002358-7461bb09a8f6 h1:JJfDeYYhWunvtxsU/mOVNTmFQmnzGx9dY034qG6G3g4= github.com/sagernet/sing-shadowsocks v0.0.0-20220819002358-7461bb09a8f6/go.mod h1:EX3RbZvrwAkPI2nuGa78T2iQXmrkT+/VQtskjou42xM= -github.com/sagernet/sing-tun v0.0.0-20220822073626-d5efb431220d h1:KzJty4GU98567kCAZdZT9wmt1vdRjX1GBCTTdgT3oZA= -github.com/sagernet/sing-tun v0.0.0-20220822073626-d5efb431220d/go.mod h1:zMKRFCEoO6Jp5Yxb2NUTqc+SvAtNVAmzfwArAheJy5g= +github.com/sagernet/sing-tun v0.0.0-20220824105617-e5c59fc756a6 h1:C0uNMDrjYribl4Pu41Au9UeQROIOeMWaDd7eSUIQ9gQ= +github.com/sagernet/sing-tun v0.0.0-20220824105617-e5c59fc756a6/go.mod h1:zMKRFCEoO6Jp5Yxb2NUTqc+SvAtNVAmzfwArAheJy5g= github.com/sagernet/sing-vmess v0.0.0-20220811135656-4f3f07acf9c4 h1:2hLETh97+S4WnfMR27XyC7QVU1SH7FTNoCznP229YJU= github.com/sagernet/sing-vmess v0.0.0-20220811135656-4f3f07acf9c4/go.mod h1:82O6gzbxLha/W/jxSVQbsqf2lVdRTjMIgyLug0lpJps= github.com/sagernet/smux v0.0.0-20220812084127-e2d085ee3939 h1:pB1Dh1NbwVrLhQhotr4O4Hs3yhiBzmg3AvnUyYjL4x4=