Skip to content

Commit

Permalink
fix: close when createWsConn failed
Browse files Browse the repository at this point in the history
  • Loading branch information
dyxushuai committed Sep 11, 2024
1 parent 6a3ea6a commit a0a9aba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/fatih/color"
"log"
"net"
"os"
Expand All @@ -12,6 +11,8 @@ import (
"strings"
"time"

"github.com/fatih/color"

"github.com/akamensky/argparse"
"github.com/nxtrace/NTrace-core/config"
fastTrace "github.com/nxtrace/NTrace-core/fast_trace"
Expand Down Expand Up @@ -114,7 +115,7 @@ func Excute() {
Timeout: time.Duration(*timeout) * time.Millisecond,
File: *file,
DontFragment: *dontFragment,
Dot: *dot,
Dot: *dot,
}

fastTrace.FastTest(*tcp, *output, paramsFastTrace)
Expand Down Expand Up @@ -186,7 +187,9 @@ func Excute() {
w.Interrupt = make(chan os.Signal, 1)
signal.Notify(w.Interrupt, os.Interrupt)
defer func() {
w.Conn.Close()
if w.Conn != nil {
w.Conn.Close()
}
}()
}
}
Expand Down

0 comments on commit a0a9aba

Please sign in to comment.