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

Improve in-app Meshnet documentation #84

Merged
merged 2 commits into from Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.sample
Expand Up @@ -13,8 +13,8 @@ QA_PEER_USERNAME=qa
QA_PEER_PASSWORD=********
DEFAULT_LOGIN_TOKEN=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
CI_PERSONAL_TOKEN=********
NEXUS_URL=https://nexus.nexus.com
NEXUS_CREDENTIALS=user:password
CI_API_V4_URL=http://example.com
NVPN_LINUX_GL_DEPS_CREDS=user:password
EVENTS_PROD_DOMAIN=http://example.com
EVENTS_STAGING_DOMAIN=http://example.com
EVENTS_SUBDOMAIN=subdomain
Expand Down
73 changes: 44 additions & 29 deletions cli/cli.go
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"io"
"log"
"os"
"path"
Expand All @@ -20,6 +21,7 @@ import (

"github.com/fatih/color"
"github.com/urfave/cli/v2"
"golang.org/x/term"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
Expand All @@ -33,8 +35,8 @@ Website: https://nordvpn.com
Usage: {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}

Commands:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{end}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}
{{.Name}}:{{end}}{{ $cv := offsetCommands .VisibleCommands 7}}{{range .VisibleCommands}}
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 5) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}
{{if .VisibleFlags}}
Global options:
{{range $index, $option := .VisibleFlags}}{{if $index}}
Expand Down Expand Up @@ -71,8 +73,8 @@ const SubcommandHelpTemplate = `Usage: {{if .UsageText}}{{.UsageText}}{{else}}{{
{{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}}

Commands:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{end}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}
{{.Name}}:{{end}}{{ $cv := offsetCommands .VisibleCommands 7}}{{range .VisibleCommands}}
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 5) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}
{{end}}{{if .VisibleFlags}}
Options:
{{range .VisibleFlags}}{{.}}
Expand Down Expand Up @@ -104,6 +106,13 @@ func NewApp(version, environment, hash, daemonURL, salt string,
cli.AppHelpTemplate = AppHelpTemplate
cli.SubcommandHelpTemplate = SubcommandHelpTemplate
cli.CommandHelpTemplate = CommandHelpTemplate
// Configure line wrapping for command descriptions
keliramu marked this conversation as resolved.
Show resolved Hide resolved
width, _, err := term.GetSize(int(os.Stdout.Fd()))
cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {
funcMap := map[string]interface{}{"wrapAt": func() int { return width }}
cli.HelpPrinterCustom(w, templ, data, funcMap)
}

cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("NordVPN Version %s\n", c.App.Version)
}
Expand Down Expand Up @@ -525,9 +534,10 @@ func NewApp(version, environment, hash, daemonURL, salt string,

func fileshareCommand(c *cmd) *cli.Command {
return &cli.Command{
Name: FileshareName,
Usage: MsgFileshareUsage,
Before: c.IsFileshareDaemonReachable,
Name: FileshareName,
Usage: MsgFileshareUsage,
Description: MsgFileshareDescription,
Before: c.IsFileshareDaemonReachable,
Subcommands: []*cli.Command{
{
Name: FileshareSendName,
Expand Down Expand Up @@ -597,8 +607,9 @@ func meshnetCommand(c *cmd) *cli.Command {
Usage: MsgMeshnetUsage,
Subcommands: []*cli.Command{
{
Name: "peer",
Usage: MsgMeshnetPeerUsage,
Name: "peer",
Usage: MsgMeshnetPeerUsage,
Description: MsgMeshnetPeerDescription,
Subcommands: []*cli.Command{
{
Name: "list",
Expand Down Expand Up @@ -627,48 +638,51 @@ func meshnetCommand(c *cmd) *cli.Command {
Action: c.MeshRefresh,
},
{
Name: "routing",
Usage: MsgMeshnetPeerRoutingUsage,
Name: "incoming",
Usage: MsgMeshnetPeerIncomingUsage,
Description: MsgMeshnetPeerIncomingDescription,
Subcommands: []*cli.Command{
{
Name: "allow",
Usage: MsgMeshnetPeerRoutingAllowUsage,
Usage: MsgMeshnetPeerIncomingAllowUsage,
ArgsUsage: MsgMeshnetPeerArgsUsage,
Action: c.MeshPeerAllowRouting,
Action: c.MeshPeerAllowIncoming,
BashComplete: c.MeshPeerAutoComplete,
},
{
Name: "deny",
Usage: MsgMeshnetPeerRoutingDenyUsage,
Usage: MsgMeshnetPeerIncomingDenyUsage,
ArgsUsage: MsgMeshnetPeerArgsUsage,
Action: c.MeshPeerDenyRouting,
Action: c.MeshPeerDenyIncoming,
BashComplete: c.MeshPeerAutoComplete,
},
},
},
{
Name: "incoming",
Usage: MsgMeshnetPeerIncomingUsage,
Name: "routing",
Usage: MsgMeshnetPeerRoutingUsage,
Description: MsgMeshnetPeerRoutingDescription,
Subcommands: []*cli.Command{
{
Name: "allow",
Usage: MsgMeshnetPeerIncomingAllowUsage,
Usage: MsgMeshnetPeerRoutingAllowUsage,
ArgsUsage: MsgMeshnetPeerArgsUsage,
Action: c.MeshPeerAllowIncoming,
Action: c.MeshPeerAllowRouting,
BashComplete: c.MeshPeerAutoComplete,
},
{
Name: "deny",
Usage: MsgMeshnetPeerIncomingDenyUsage,
Usage: MsgMeshnetPeerRoutingDenyUsage,
ArgsUsage: MsgMeshnetPeerArgsUsage,
Action: c.MeshPeerDenyIncoming,
Action: c.MeshPeerDenyRouting,
BashComplete: c.MeshPeerAutoComplete,
},
},
},
{
Name: "local",
Usage: MsgMeshnetPeerLocalNetworkUsage,
Name: "local",
Usage: MsgMeshnetPeerLocalNetworkUsage,
Description: MsgMeshnetPeerLocalNetworkDescription,
Subcommands: []*cli.Command{
{
Name: "allow",
Expand All @@ -687,8 +701,9 @@ func meshnetCommand(c *cmd) *cli.Command {
},
},
{
Name: "fileshare",
Usage: MsgMeshnetPeerFileshareUsage,
Name: "fileshare",
Usage: MsgMeshnetPeerFileshareUsage,
Description: MsgMeshnetPeerFileshareDescription,
Subcommands: []*cli.Command{
{
Name: "allow",
Expand Down Expand Up @@ -736,10 +751,10 @@ func meshnetCommand(c *cmd) *cli.Command {
},
},
{
Name: "invite",
Aliases: []string{"inv"},
Usage: MsgMeshnetInviteUsage,
ArgsUsage: MsgMeshnetInviteArgsUsage,
Name: "invite",
Aliases: []string{"inv"},
Usage: MsgMeshnetInviteUsage,
Description: MsgMeshnetInviteDescription,
Subcommands: []*cli.Command{
{
Name: "list",
Expand Down
63 changes: 37 additions & 26 deletions cli/messages.go
Expand Up @@ -113,9 +113,9 @@ Example: nordvpn set %s on`
NoSuchCommand = "Command '%s' doesn't exist."

// Meshnet
MsgSetMeshnetUsage = "Enables or disables meshnet on this device."
MsgSetMeshnetUsage = "Enables or disables Meshnet on this device."
MsgSetMeshnetArgsUsage = `<enabled>|<disabled>`
MsgSetMeshnetDescription = `Use this command to enable or disable meshnet.
MsgSetMeshnetDescription = `Use this command to enable or disable Meshnet.

Supported values for <disabled>: 0, false, disable, off, disabled
Example: nordvpn set meshnet off
Expand All @@ -126,17 +126,18 @@ Example: nordvpn set meshnet on`
MsgSetMeshnetSuccess = "Meshnet is set to '%s' successfully."
MsgMeshnetAlreadyEnabled = "Meshnet is already enabled."
MsgMeshnetAlreadyDisabled = "Meshnet is already disabled."
MsgMeshnetNotEnabled = "Meshnet is not enabled."
MsgMeshnetNotEnabled = "Meshnet is not enabled. Use the \"nordvpn set meshnet on\" command to enable it."
MsgMeshnetNordlynxMustBeEnabled = "NordLynx technology must be set to use this feature."
MsgMeshnetVersionNotSupported = "Current application version does not support the meshnet feature."
MsgMeshnetUsage = "Manages mesh network and access to it. In order to enable the feature, execute `nordvpn set meshnet on`"
MsgMeshnetRefreshUsage = "Refreshes the meshnet in case it was not updated automatically."
MsgMeshnetPeerUnknown = "Peer '%s' is unknown."
MsgMeshnetVersionNotSupported = "Current application version does not support the Meshnet feature."
MsgMeshnetUsage = "Meshnet is a way to safely access other devices, no matter where in the world they are. Once set up, Meshnet functions just like a secure local area network (LAN) — it connects devices directly. It also allows securely sending files to other devices. Use the \"nordvpn set meshnet on\" command to enable Meshnet. Learn more: https://meshnet.nordvpn.com/"

MsgMeshnetRefreshUsage = "Refreshes the Meshnet in case it was not updated automatically."
MsgMeshnetPeerUnknown = "Peer '%s' is unknown."

// Invites
MsgMeshnetInviteUsage = "Displays the list of all sent and received meshnet invitations. " +
"If [email] argument is passed, sends an invitation to join the mesh network to a specified email."
MsgMeshnetInviteListUsage = "Displays the list of all sent and received meshnet invitations."
MsgMeshnetInviteUsage = "Add other users' devices to your Meshnet."
MsgMeshnetInviteDescription = MsgMeshnetInviteUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/linking-devices-in-meshnet"
MsgMeshnetInviteListUsage = "Displays the list of all sent and received Meshnet invitations."
MsgMeshnetInviteAcceptUsage = "Accepts an invitation to join inviter's mesh network."
MsgMeshnetInviteDenyUsage = "Denies an invitation to join inviter's mesh network."
MsgMeshnetInviteRevokeUsage = "Revokes a sent invitation."
Expand All @@ -159,46 +160,55 @@ Example: nordvpn set meshnet on`
MsgMeshnetAllowFileshare = "Allow the peer to send you files."

// Peers
MsgMeshnetPeerListFilters = "Filters list of available peers in a meshnet. To apply multiple filters, separate them with a comma. Please note that you will see an empty list if you apply contradictory filters."
MsgMeshnetPeerUsage = "Handles meshnet peer list."
MsgMeshnetPeerListFilters = "Filters list of available peers in a Meshnet. To apply multiple filters, separate them with a comma. Please note that you will see an empty list if you apply contradictory filters."
MsgMeshnetPeerUsage = "Manage Meshnet peers."
MsgMeshnetPeerDescription = `Manage your Meshnet devices.
Learn more:
Managing Meshnet devices - https://meshnet.nordvpn.com/getting-started/how-to-start-using-meshnet/using-meshnet-on-linux#manage-devices
Meshnet permissions explained - https://meshnet.nordvpn.com/features/explaining-permissions
Routing traffic in Meshnet - https://meshnet.nordvpn.com/features/routing-traffic-in-meshnet`
MsgMeshnetPeerArgsUsage = "<public_key>|<hostname>|<ip>"
MsgMeshnetPeerListUsage = "Lists available peers in a meshnet."
MsgMeshnetPeerRemoveUsage = "Removes a peer from a meshnet."
MsgMeshnetPeerRemoveSuccess = "Peer '%s' has been removed from the meshnet."
MsgMeshnetPeerListUsage = "Lists available peers in a Meshnet."
MsgMeshnetPeerRemoveUsage = "Removes a peer from a Meshnet."
MsgMeshnetPeerRemoveSuccess = "Peer '%s' has been removed from the Meshnet."

MsgMeshnetPeerRoutingUsage = "Allows/denies a peer device to route all traffic through this device."
MsgMeshnetPeerRoutingAllowUsage = "Allows a meshnet peer to route its' traffic through this device."
MsgMeshnetPeerRoutingDenyUsage = "Denies a meshnet peer to route its' traffic through this device."
MsgMeshnetPeerRoutingDescription = MsgMeshnetPeerRoutingUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/explaining-permissions/traffic-routing-permissions"
MsgMeshnetPeerRoutingAllowUsage = "Allows a Meshnet peer to route its' traffic through this device."
MsgMeshnetPeerRoutingDenyUsage = "Denies a Meshnet peer to route its' traffic through this device."
MsgMeshnetPeerRoutingAlreadyAllowed = "Traffic routing for '%s' is already allowed."
MsgMeshnetPeerRoutingAlreadyDenied = "Traffic routing for '%s' is already denied."
MsgMeshnetPeerRoutingAllowSuccess = "Traffic routing for '%s' has been allowed."
MsgMeshnetPeerRoutingDenySuccess = "Traffic routing for '%s' has been denied."

MsgMeshnetPeerIncomingUsage = "Allows/denies a peer device to access this device remotely (incoming connections)."
MsgMeshnetPeerIncomingAllowUsage = "Allows a meshnet peer to send traffic to this device."
MsgMeshnetPeerIncomingDenyUsage = "Denies a meshnet peer to send traffic to this device."
MsgMeshnetPeerIncomingDescription = MsgMeshnetPeerIncomingUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/explaining-permissions/remote-access-permissions"
MsgMeshnetPeerIncomingAllowUsage = "Allows a Meshnet peer to send traffic to this device."
MsgMeshnetPeerIncomingDenyUsage = "Denies a Meshnet peer to send traffic to this device."
MsgMeshnetPeerIncomingAlreadyAllowed = "Incoming traffic for '%s' is already allowed."
MsgMeshnetPeerIncomingAlreadyDenied = "Incoming traffic for '%s' is already denied."
MsgMeshnetPeerIncomingAllowSuccess = "Incoming traffic for '%s' has been allowed."
MsgMeshnetPeerIncomingDenySuccess = "Incoming traffic for '%s' has been denied."

MsgMeshnetPeerLocalNetworkUsage = "Allows/denies access to your local network when a peer device is routing traffic through this device."
MsgMeshnetPeerLocalNetworkAllowUsage = "Allows a meshnet peer to access local network when routing traffic through this device."
MsgMeshnetPeerLocalNetworkDenyUsage = "Denies a meshnet peer to access local network when routing traffic through this device."
MsgMeshnetPeerLocalNetworkDescription = MsgMeshnetPeerLocalNetworkUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/explaining-permissions/local-network-permissions"
MsgMeshnetPeerLocalNetworkAllowUsage = "Allows a Meshnet peer to access local network when routing traffic through this device."
MsgMeshnetPeerLocalNetworkDenyUsage = "Denies a Meshnet peer to access local network when routing traffic through this device."
MsgMeshnetPeerLocalNetworkAlreadyAllowed = "Local network access for '%s' is already allowed."
MsgMeshnetPeerLocalNetworkAlreadyDenied = "Local network access for '%s' is already denied."
MsgMeshnetPeerLocalNetworkAllowSuccess = "Local network access for '%s' has been allowed."
MsgMeshnetPeerLocalNetworkDenySuccess = "Local network access for '%s' has been denied."

MsgMeshnetPeerFileshareUsage = "Allows/denies peer to send files to this device."
MsgMeshnetPeerFileshareAllowUsage = "Allows a meshnet peer to send files to this device."
MsgMeshnetPeerFileshareDenyUsage = "Denies a meshnet peer to send files to this device."
MsgMeshnetPeerFileshareDescription = MsgMeshnetPeerFileshareUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/explaining-permissions/file-sharing-permissions"
MsgMeshnetPeerFileshareAllowUsage = "Allows a Meshnet peer to send files to this device."
MsgMeshnetPeerFileshareDenyUsage = "Denies a Meshnet peer to send files to this device."
MsgMeshnetPeerFileshareAlreadyAllowed = "Fileshare for '%s' is already allowed."
MsgMeshnetPeerFileshareAlreadyDenied = "Fileshare for '%s' is already denied."
MsgMeshnetPeerFileshareAllowSuccess = "Fileshare for '%s' has been allowed."
MsgMeshnetPeerFileshareDenySuccess = "Fileshare for '%s' has been denied."

MsgMeshnetPeerAutomaticFileshareUsage = "Always accept transfers from a specific peer. We won’t ask you to approve each transfer – files will start downloading automatically."
MsgMeshnetPeerAutomaticFileshareUsage = "Always accept file transfers from a specific peer. We won’t ask you to approve each transfer – files will start downloading automatically."
MsgMeshnetPeerAutomaticFileshareAllowUsage = "Enables automatic fileshare from device."
MsgMeshnetPeerAutomaticFileshareDenyUsage = "Denies automatic fileshare from device."
MsgMeshnetPeerAutomaticFileshareAlreadyEnabled = "Automatic fileshare for '%s' is already allowed."
Expand All @@ -208,7 +218,7 @@ Example: nordvpn set meshnet on`
MsgMeshnetPeerAutomaticFileshareDefaultDirNotFound = "We couldn't enable auto-accept because the download directory doesn't exist."

MsgMeshnetPeerConnectUsage = "Treats a peer as a VPN server and connects to it if the peer has allowed traffic routing."
MsgMeshnetPeerConnectSuccess = "You are connected to meshnet exit node '%s'."
MsgMeshnetPeerConnectSuccess = "You are connected to Meshnet exit node '%s'."
MsgMeshnetPeerDoesNotAllowRouting = "Meshnet peer '%s' does not allow traffic routing."
MsgMeshnetPeerAlreadyConnected = "You are already connected."
MsgMeshnetPeerConnectFailed = "Connect to other mesh peer failed - check if peer '%s' is online."
Expand All @@ -225,7 +235,8 @@ Example: nordvpn set meshnet on`
flagFileshareListIn = "incoming"
flagFileshareListOut = "outgoing"

MsgFileshareUsage = "Transfer files of any size between Meshnet peers securely and privately."
MsgFileshareUsage = "Transfer files of any size between Meshnet peers securely and privately"
MsgFileshareDescription = MsgFileshareUsage + "\n" + "Learn more: https://meshnet.nordvpn.com/features/sharing-files-in-meshnet\n\nNote: most arguments (peer name, transfer ID, file name) in fileshare commands can be entered faster using auto-completion. Simply press Tab and the app will suggest valid options for you."
MsgFileshareTransferNotFound = "Transfer not found."
MsgFileshareInvalidPath = "Invalid path provided: %s"
MsgFilesharePathNotFound = "Download directory %q does not exist. Make sure the directory exists or provide an alternative via --" + flagFilesharePath
Expand Down