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"
@@ -212,20 +213,9 @@ func (d *Dumper) Dump(w io.Writer) error {
212213 if strings .Contains (d .Addr , "/" ) {
213214 args = append (args , fmt .Sprintf ("--socket=%s" , d .Addr ))
214215 } else {
215- ipv6 := strings .Count (d .Addr , ":" ) > 1
216- lastSep := strings .LastIndex (d .Addr , ":" )
217- var host , port string
218- // without port
219- host = d .Addr
220- // ipv6 with port
221- if ipv6 && strings .ContainsAny (d .Addr , "[]" ) {
222- host = strings .Trim (d .Addr [:lastSep ], "[]" )
223- port = d .Addr [lastSep + 1 :]
224- }
225- // ipv4 with port
226- if ! ipv6 && lastSep != - 1 {
227- host = d .Addr [:lastSep ]
228- port = d .Addr [lastSep + 1 :]
216+ host , port , err := net .SplitHostPort (d .Addr )
217+ if err != nil {
218+ host = d .Addr
229219 }
230220
231221 args = append (args , fmt .Sprintf ("--host=%s" , host ))
You can’t perform that action at this time.
0 commit comments