From 717daa28cc4805290b5fa6d1890a68f1d469c097 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 9 Feb 2024 09:17:30 +0000 Subject: [PATCH 1/3] Allow a custom name, not just auto-generated This affected @richardcase when a team-mate deleted his VM from a common company cloud account not knowing what it was for, or who it belonged to. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- cmd/create.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 3d63727c..256a27c3 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -19,7 +19,7 @@ import ( "github.com/spf13/cobra" ) -const inletsProDefaultVersion = "0.9.25" +const inletsProDefaultVersion = "0.9.28" const inletsProControlPort = 8123 func init() { @@ -71,19 +71,25 @@ var createCmd = &cobra.Command{ with inlets preloaded as a systemd service. The estimated cost of each VM along with what OS version and spec will be used is explained in the project docs.`, - Example: ` # Create a TCP tunnel server - inletsctl create \ - --provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \ - --access-token-file $HOME/access-token \ - --region lon1 - + Example: ` # Create a HTTPS tunnel server, terminating TLS with a certificate - # from Let's Encrypt + # from Let's Encrypt called "tunnel-richardcase" so your team mates + # don't delete your VM unintentionally. inletsctl create \ + tunnel-richardcase \ --letsencrypt-domain inlets.example.com \ --letsencrypt-email webmaster@example.com - # Create a HTTPS tunnel server with multiple domains + # Create a TCP tunnel server with a VM name of ssh-tunnel + inletsctl create \ + ssh-tunnel \ + --tcp \ + --provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \ + --access-token-file $HOME/access-token \ + --region lon1 + + # Create a HTTPS tunnel server with multiple domains and an auto-generated + # VM name inletsctl create \ --letsencrypt-domain tunnel1.example.com \ --letsencrypt-domain tunnel2.example.com \ @@ -99,6 +105,12 @@ const EquinixMetalProvider = "equinix-metal" func runCreate(cmd *cobra.Command, _ []string) error { + // Get name from the Args, if not provided, generate a random name + name := strings.Replace(names.GetRandomName(10), "_", "-", -1) + if len(cmd.Flags().Args()) > 0 { + name = cmd.Flags().Args()[0] + } + inletsProVersion, err := cmd.Flags().GetString("inlets-version") if err != nil { return err @@ -301,8 +313,6 @@ func runCreate(cmd *cobra.Command, _ []string) error { tcp = false } - name := strings.Replace(names.GetRandomName(10), "_", "-", -1) - var userData string if len(letsencryptDomains) > 0 { userData = MakeHTTPSUserdata(inletsToken, @@ -341,9 +351,9 @@ func runCreate(cmd *cobra.Command, _ []string) error { } if provider == "gce" { - fmt.Printf("Requesting host: %s in %s, from %s\n", name, zone, provider) + fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, zone, provider) } else { - fmt.Printf("Requesting host: %s in %s, from %s\n", name, region, provider) + fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, region, provider) } hostRes, err := provisioner.Provision(*hostReq) From 31e2f8af105174d69dc9c240a1ee90260cc371ea Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 9 Feb 2024 09:28:43 +0000 Subject: [PATCH 2/3] Make HTTPS tunnels the default This commit makes HTTPS tunnels the default, and a TCP tunnel can still be created with --tcp. Tested against digitalocean Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- cmd/create.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 256a27c3..8018c7a6 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -49,15 +49,13 @@ func init() { createCmd.Flags().String("endpoint", "ovh-eu", "API endpoint (ovh), default: ovh-eu") createCmd.Flags().String("consumer-key", "", "The Consumer Key for using the OVH API") - createCmd.Flags().Bool("tcp", true, `Provision an exit-server with inlets running as a TCP server`) + createCmd.Flags().Bool("tcp", false, `Provision an exit-server with inlets running as a TCP server`) createCmd.Flags().String("aws-key-name", "", "The name of an existing SSH key on AWS to be used to access the EC2 instance for maintenance (optional)") createCmd.Flags().StringArray("letsencrypt-domain", []string{}, `Domains you want to get a Let's Encrypt certificate for`) - createCmd.Flags().String("letsencrypt-issuer", "prod", `The issuer endpoint to use with Let's Encrypt - \"prod\" or \"staging\"`) + createCmd.Flags().String("letsencrypt-issuer", "prod", `The issuer endpoint to use with Let's Encrypt - "prod" or "staging"`) createCmd.Flags().String("letsencrypt-email", "", `The email to register with Let's Encrypt for renewal notices (required)`) - createCmd.Flags().Bool("pro", true, `Provision an exit-server with inlets Pro (Deprecated)`) - _ = createCmd.Flags().MarkHidden("pro") createCmd.Flags().DurationP("poll", "n", time.Second*2, "poll every N seconds, use a higher value if you encounter rate-limiting") createCmd.Flags().String("inlets-version", inletsProDefaultVersion, `Binary release version for inlets`) @@ -120,12 +118,7 @@ func runCreate(cmd *cobra.Command, _ []string) error { inletsProVersion = inletsProDefaultVersion } - tcp := true - - if cmd.Flags().Changed("pro") { - fmt.Printf("WARN: --pro is deprecated, use --tcp instead.") - tcp, _ = cmd.Flags().GetBool("pro") - } + tcp := false if cmd.Flags().Changed("tcp") { tcp, _ = cmd.Flags().GetBool("tcp") } @@ -150,7 +143,7 @@ func runCreate(cmd *cobra.Command, _ []string) error { serverMode = "L7 HTTPS" } - fmt.Printf("inletsctl version: %v\nTunnel server: %s\tProvider: %s\tVersion: %s\n", + fmt.Printf("inletsctl version: %v\nTunnel server: %s\tProvider: %s\tinlets-pro version: %s\n", getVersion(), serverMode, provider, inletsProVersion) @@ -303,6 +296,10 @@ func runCreate(cmd *cobra.Command, _ []string) error { letsencryptEmail, _ := cmd.Flags().GetString("letsencrypt-email") letsencryptIssuer, _ := cmd.Flags().GetString("letsencrypt-issuer") + if len(letsencryptDomains) == 0 && !tcp { + return fmt.Errorf("either --letsencrypt-domain (for a HTTPS tunnel) or --tcp (for a TCP tunnel) must be set") + } + if len(letsencryptDomains) > 0 { if len(letsencryptEmail) == 0 { return fmt.Errorf("--letsencrypt-email is required when --letsencrypt-domain is given") From 3afa90a3b539f28f16b8d7053f1a274f7370e325 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 9 Feb 2024 09:34:25 +0000 Subject: [PATCH 3/3] Link for subscription Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 55891817..0a796a4b 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ [![Documentation](https://godoc.org/github.com/inlets/inletsctl?status.svg)](http://godoc.org/github.com/inlets/inletsctl) ![Downloads](https://img.shields.io/github/downloads/inlets/inletsctl/total) Arm CI sponsored by Actuated - inletsctl automates the task of creating an exit-server (tunnel server) on public cloud infrastructure. -The `create` command provisions a cheap cloud VM with a public IP and pre-installs inlets Pro for you. You'll then get a connection string that you can use with the inlets client. +The `create` command provisions a cheap cloud VM with a public IP and pre-installs inlets for you. You'll then get a connection string that you can use with the inlets client. **Conceptual diagram** @@ -16,7 +15,7 @@ The `create` command provisions a cheap cloud VM with a public IP and pre-instal Use-cases: -* Setup L4 TCP and HTTPS tunnels for your local services using [inlets Pro](https://inlets.dev/) with `inletsctl create` +* Setup L4 TCP and HTTPS tunnels for your local services using [inlets-pro](https://inlets.dev/) with `inletsctl create` * Create tunnels for use with Kubernetes clusters, create the tunnel and use it whenever you need it * Port-forward services your local Kubernetes cluster using `inletsctl kfwd` @@ -47,7 +46,6 @@ In the demo we: [![asciicast](https://asciinema.org/a/q8vqJ0Fwug47T62biscp7cJ5O.svg)](https://asciinema.org/a/q8vqJ0Fwug47T62biscp7cJ5O) - inletsctl is the quickest and easiest way to automate tunnels, whilst retaining complete control of your tunnel and data. ## Features @@ -114,5 +112,4 @@ type Provisioner interface { inletsctl is distributed under the MIT license. inlets-pro, which inletsctl uses is licensed under the [inlets-pro End User License Agreement (EULA)](https://github.com/inlets/inlets-pro/blob/master/EULA.md). -A valid inlets license or Gumroad subscription is required to create tunnel servers with inletsctl. - +[A valid static inlets license or a Gumroad subscription](https://store.openfaas.com/) is required to create tunnel servers with inletsctl.