Update documentation

This commit is contained in:
世界 2022-08-22 12:43:21 +08:00
parent c4f4fd97d6
commit 3a442347a5
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 109 additions and 33 deletions

17
box.go
View file

@ -168,16 +168,18 @@ func New(ctx context.Context, options option.Options) (*Box, error) {
}
func (s *Box) Start() error {
err := s.start()
if err != nil {
s.Close()
}
return err
}
func (s *Box) start() error {
for i, out := range s.outbounds {
if starter, isStarter := out.(common.Starter); isStarter {
err := starter.Start()
if err != nil {
for _, in := range s.inbounds {
common.Close(in)
}
for g := 0; g < i; g++ {
common.Close(s.outbounds[g])
}
var tag string
if out.Tag() == "" {
tag = F.ToString(i)
@ -195,9 +197,6 @@ func (s *Box) Start() error {
for i, in := range s.inbounds {
err = in.Start()
if err != nil {
for g := 0; g < i; g++ {
s.inbounds[g].Close()
}
var tag string
if in.Tag() == "" {
tag = F.ToString(i)