File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change 44 "bytes"
55 "fmt"
66 "io"
7+ "net"
78 "os"
89 "os/exec"
910 "regexp"
@@ -202,20 +203,9 @@ func (d *Dumper) Dump(w io.Writer) error {
202203 if strings .Contains (d .Addr , "/" ) {
203204 args = append (args , fmt .Sprintf ("--socket=%s" , d .Addr ))
204205 } else {
205- ipv6 := strings .Count (d .Addr , ":" ) > 1
206- lastSep := strings .LastIndex (d .Addr , ":" )
207- var host , port string
208- // without port
209- host = d .Addr
210- // ipv6 with port
211- if ipv6 && strings .ContainsAny (d .Addr , "[]" ) {
212- host = strings .Trim (d .Addr [:lastSep ], "[]" )
213- port = d .Addr [lastSep + 1 :]
214- }
215- // ipv4 with port
216- if ! ipv6 && lastSep != - 1 {
217- host = d .Addr [:lastSep ]
218- port = d .Addr [lastSep + 1 :]
206+ host , port , err := net .SplitHostPort (d .Addr )
207+ if err != nil {
208+ host = d .Addr
219209 }
220210
221211 args = append (args , fmt .Sprintf ("--host=%s" , host ))
You can’t perform that action at this time.
0 commit comments