Skip to content

CLI polish and fixes for deployment #44

@tegefaulkes

Description

@tegefaulkes

Specification

While testing hole punching with the testnet, we found a few issues with the CLI.

  1. Nodes Get All is throwing an error
  2. We are getting a weird output format for nodes connections what is the 0 and what is this NA for?
  3. I think nodes connections is better suited for dictionary format - list format or table format (can you check which ones done robustly)
  4. The output changes sometimes, to just join the NA after the ip address, so no port is available
  5. Summary - the nodes connections command is just very non-deterministic
  6. Secret leak is occurring on agent service, there should be no authorisation metadata see --format=json
  7. What's usageCount

Automatic Encoding

For these two formats, encoding is applied by default so that special characters will not mess up the padding for any given output.

  • dict format
    • will automatically encase any string in a \"\" and apply encoding to the input
  • table format
    • will automatically encase any string in a \"\" and apply encoding to the input

Manual Encoding with Utility Functions

For any other format passed into outputFormatter, there will be no encoding of escapable characters by default.

It is up to the user to use the following functions in src/utils/utils.ts to encode parts of their input:

/**
 * This function:
 *
 * 1. Keeps regular spaces, only ' ', as they are.
 * 2. Converts \\n \\r \\t to escaped versions, \\\\n \\\\r and \\\\t.
 * 3. Converts other control characters to their Unicode escape sequences.\
 * 4. Converts ' \` " to escaped versions, \\\\' \\\\\` and \\\\"
 *
 * Unless you're using this in a `JSON.stringify` replacer, you probably want to use {@link encodeEscapedWrapped} instead.
 */
function encodeEscaped(str: string): string
/**
 * This function:
 * 1. Keeps regular spaces, only ' ', as they are.
 * 2. Converts \\n \\r \\t to escaped versions, \\\\n \\\\r and \\\\t.
 * 3. Converts other control characters to their Unicode escape sequences.
 * 4. Converts ' \` " to escaped versions, \\\\' \\\\\` and \\\\"
 * 5. Wraps the whole thing in `""` if any characters have been encoded.
 */
function encodeEscapedWrapped(str: string): string

To use this:

const v = `test ${encodeEscapedWrapped("\u0000\"\n")}` // returns '"\\u0000\\"\\n"'

Note that any encoded strings must be encased in "" anyways. This is so that when the user copy-pastes the output as the input of another command, or pipes the output to another command, those escaped characters will be collapsed correctly.

Additional context

Tasks

  • 1. Fix up nodes getall command, it's throwing an error relating to host not being defined.
  • 2. Review and fix up the nodes connections command output formatting. The output is very unclear.
  • 3. client call metadata is being included in the nodes connections --format json output. This should not be the case.
  • 4. agent status command outputs too much information. We should strip out the key and certificate information.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions