Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]Support collapsed zeroes format for ipv6 host addresses (i.e. ::1 for 0:0:0:0:0:0:0:1) #537

Closed
jshort opened this issue Oct 12, 2022 · 1 comment · Fixed by #539

Comments

@jshort
Copy link
Collaborator

jshort commented Oct 12, 2022

Now that the et terminal client supports ipv6 host positional args (with or without port specified), we should move the host argument parsing logic out of main() into a helper that has more powerful ipv6 parsing logic (not just counting 7 colons or 8 colons if a port is specified.

ipv4 ip or hostname will have at most 1 colon (if a port is specified).

ipv6 ip will have at least 2 colons (for a collapsed form with no port specified) and up to 8 if the address is fully expressed and a port is specified.

Ex:

  • 1::1 => 1:0:0:0:0:0:0:1 (default port)
  • [1::1]:2022 => 1:0:0:0:0:0:0:1 (port 2022) (need brackets though this format is not supported by OpenSSH
  • 1:1:1:1:1:1::1 => 1:1:1:1:1:1:0:1 (default port)
@jshort
Copy link
Collaborator Author

jshort commented Oct 13, 2022

So OpenSSH decided not to support ipv6 addresses with ports specified in the host positional argument. However, it is standard, particularly if there is a :: in the address, to support [ipv6_addr]:port in say a URL. Et can do one of 3 options:

  1. support this bracketed format exclusively for ipv6 (with or without a port or :: abbreviation)
  2. support fully expanded ipv6 address without square brackets (with or without port...this is current the case after Support for ipv6 addresses (with or without port specified) #536) and partially expanded ipv6 addresses without square brackets but with no port and finally, partially expanded ipv6 addresses in square brackets with a port specified
  3. support passing an ipv6 host argument (expanded or not) without square brackets but not with a port (you must pass --port for ipv6 addresses)

I'm leaning towards the first option (particularly since OpenSsh makes you pass -p or set Port in your ssh config file if you want a non-standard ssh port with an ipv6 address). Or even the third.

The 2nd option is complicated and hard to document in the small --help menu of a cli executable.

Remember that the port specified by the host positional arg or the -p of the et client is the port for etserver not ssh. The ssh port is either default (22) or determined from --ssh-option or your .ssh/config file.

EDIT: Yuck, the shell will require that you quote your argument if you pass square brackets for an ipv6 address. Maybe I'm leaning towards option 3 :). Or maybe a hybrid of option 2 where if you pass an ipv6 address with ::, you cannot set port in the host arg and must do so in the -p option.

jshort added a commit to jshort/EternalTerminal that referenced this issue Oct 13, 2022
Help output:

```
$> ./et --help
Remote shell for the busy and impatient
Usage:
  et [OPTION...] [user@]host[:port]

  Note that 'host' can be a hostname or ipv4 address with or without a port
  or an ipv6 address. If the ipv6 address is abbreviated with :: then it must
  be specfied without a port (use -p,--port).

  -h, --help                 Print help
      --version              Print version
  -u, --username             Username
      --host arg             Remote host name
  ...
```
Tests:

```
$> ./et ::1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1:8080 --macserver
$> ./et ::1 -p 8080 --macserver # fails because defaults to port 2022
```
Fixes MisterTea#537
jshort added a commit to jshort/EternalTerminal that referenced this issue Oct 13, 2022
This will support ipv6 addresses that are abbreviated with `::` such as
::1 (for 0:0:0:0:0:0:0:1) with some caveats around specifying the port
in the host positional argument.

Help output:

```
$> ./et --help
Remote shell for the busy and impatient
Usage:
  et [OPTION...] [user@]host[:port]

  Note that 'host' can be a hostname or ipv4 address with or without a port
  or an ipv6 address. If the ipv6 address is abbreviated with :: then it must
  be specfied without a port (use -p,--port).

  -h, --help                 Print help
      --version              Print version
  -u, --username             Username
      --host arg             Remote host name
  ...
```
Tests:

```
$> ./et ::1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1:8080 --macserver
$> ./et ::1 -p 8080 --macserver # fails because defaults to port 2022
```
Fixes MisterTea#537
MisterTea pushed a commit that referenced this issue Oct 13, 2022
This will support ipv6 addresses that are abbreviated with `::` such as
::1 (for 0:0:0:0:0:0:0:1) with some caveats around specifying the port
in the host positional argument.

Help output:

```
$> ./et --help
Remote shell for the busy and impatient
Usage:
  et [OPTION...] [user@]host[:port]

  Note that 'host' can be a hostname or ipv4 address with or without a port
  or an ipv6 address. If the ipv6 address is abbreviated with :: then it must
  be specfied without a port (use -p,--port).

  -h, --help                 Print help
      --version              Print version
  -u, --username             Username
      --host arg             Remote host name
  ...
```
Tests:

```
$> ./et ::1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1 -p 8080 --macserver
$> ./et 0:0:0:0:0:0:0:1:8080 --macserver
$> ./et ::1 -p 8080 --macserver # fails because defaults to port 2022
```
Fixes #537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant