File tree 1 file changed +4
-14
lines changed
1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change 4
4
"bytes"
5
5
"fmt"
6
6
"io"
7
+ "net"
7
8
"os"
8
9
"os/exec"
9
10
"regexp"
@@ -202,20 +203,9 @@ func (d *Dumper) Dump(w io.Writer) error {
202
203
if strings .Contains (d .Addr , "/" ) {
203
204
args = append (args , fmt .Sprintf ("--socket=%s" , d .Addr ))
204
205
} 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
219
209
}
220
210
221
211
args = append (args , fmt .Sprintf ("--host=%s" , host ))
You can’t perform that action at this time.
0 commit comments