fix: close when createWsConn failed

This commit is contained in:
john xu
2024-09-11 10:47:48 +08:00
committed by tsosunchia
parent 6a3ea6acb3
commit 8774e8cd67

View File

@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/fatih/color"
"log"
"net"
"os"
@@ -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"
@@ -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)
@@ -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()
}
}()
}
}