Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 08f00dc

Browse files
committed
Fix sshcode only accepting ip addresses
1 parent ff782b1 commit 08f00dc

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

sshcode.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type options struct {
3232
func sshCode(host, dir string, o options) error {
3333
flog.Info("ensuring code-server is updated...")
3434

35-
host, extraSSHFlags, err := parseIP(host)
35+
host, extraSSHFlags, err := parseHost(host)
3636
if err != nil {
3737
return xerrors.Errorf("failed to parse host IP: %w", err)
3838
}
@@ -350,19 +350,17 @@ func ensureDir(path string) error {
350350
return nil
351351
}
352352

353-
// parseIP parses the host to a valid IP address. If 'gcp:' is prefixed to the
353+
// parseHost parses the host argument. If 'gcp:' is prefixed to the
354354
// host then a lookup is done using gcloud to determine the external IP and any
355-
// additional SSH arguments that should be used for ssh commands.
356-
func parseIP(host string) (ip string, additionalFlags string, err error) {
355+
// additional SSH arguments that should be used for ssh commands. Otherwise, host
356+
// is returned.
357+
func parseHost(host string) (parsedHost string, additionalFlags string, err error) {
357358
host = strings.TrimSpace(host)
358359
switch {
359360
case strings.HasPrefix(host, "gcp:"):
360361
instance := strings.TrimPrefix(host, "gcp:")
361362
return parseGCPSSHCmd(instance)
362363
default:
363-
if net.ParseIP(host) == nil {
364-
return "", "", xerrors.New("host argument is not a valid IP address")
365-
}
366364
return host, "", nil
367365
}
368366
}

0 commit comments

Comments
 (0)