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

cmd/p9: allow implicit address in paths #59

Open
DeedleFake opened this issue Oct 11, 2019 · 0 comments
Open

cmd/p9: allow implicit address in paths #59

DeedleFake opened this issue Oct 11, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@DeedleFake
Copy link
Owner

Currently, the only way to specify an address to connect to is to use the -addr flag. This is not a problem, per se, but I think it might be useful to also be able to imply the address in the argument itself when only dealing with a single argument if the -addr flag isn't specified. For example, running p9 ls -l ./example.sock/path/to/a/file would dial example.sock and then request path/to/a/file. I think that a simple heuristic for determining what to do should work for most cases:

  • If the path starts with ./, assume that it is a Unix socket relative to the current directory. Traverse the path one element at a time until that socket is found, then dial it and use the remainder of the path for the request.
  • If the path starts with /, assume that it is an absolute path to a Unix socket. Find it in the same was as for ./.
  • If the path does not start with a slash but contains a colon before the first slash, assume everything before the first slash is a TCP address.
  • If the path does not start with a slash but contains a !, assume that separates a network type from an address. If it is a Unix network, find it in the same way as above. If it contains two !, assume that the second separates a port number and replace it with a :.
  • If it does not start with a slash and does not contain a : or a ! and doesn't seem to point to an existing Unix socket, assume that the first element is a Plan 9 namespace and look it up as appropriate.

The existing parseAddr() function can be reworked to have this functionality. That should simplify implementation and ensure consistency in how the dialing works.

@DeedleFake DeedleFake added the enhancement New feature or request label Oct 11, 2019
@DeedleFake DeedleFake self-assigned this Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant