mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-04 20:37:37 +03:00
Minor fixes
This commit is contained in:
parent
ef8dde2b70
commit
b0ed1dc106
10 changed files with 70 additions and 36 deletions
8
box.go
8
box.go
|
@ -29,6 +29,7 @@ type Box struct {
|
|||
logger log.ContextLogger
|
||||
logFile *os.File
|
||||
clashServer adapter.ClashServer
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
func New(ctx context.Context, options option.Options) (*Box, error) {
|
||||
|
@ -161,6 +162,7 @@ func New(ctx context.Context, options option.Options) (*Box, error) {
|
|||
logger: logFactory.NewLogger(""),
|
||||
logFile: logFile,
|
||||
clashServer: clashServer,
|
||||
done: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -189,6 +191,12 @@ func (s *Box) Start() error {
|
|||
}
|
||||
|
||||
func (s *Box) Close() error {
|
||||
select {
|
||||
case <-s.done:
|
||||
return os.ErrClosed
|
||||
default:
|
||||
close(s.done)
|
||||
}
|
||||
for _, in := range s.inbounds {
|
||||
in.Close()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue