Skip to content

Commit

Permalink
Add inlets-pro example
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Oct 29, 2019
1 parent cd44ef8 commit c31d4f0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ inletsctl create --access-token-file $HOME/Downloads/do-access-token \
--region="nyc1"
```

## Example with inlets-pro

Let's say we want to forward TCP connections to the IP `192.168.0.26` within our client's network, using inlets-pro, we'd run this using the `--remote-tcp` flag.

```sh
inletsctl create digitalocean --access-token-file ~/Downloads/do-access-token \
--remote-tcp 192.168.0.26
```

### Example usage with Scaleway

```sh
Expand Down
38 changes: 34 additions & 4 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func init() {
createCmd.Flags().String("secret-key-file", "", "Read this file for the access token for your cloud (Scaleway)")
createCmd.Flags().String("organisation-id", "", "Organisation ID (Scaleway)")

createCmd.Flags().StringP("remote-tcp", "c", "", `Comma-separated TCP ports for inlets-pro i.e. "80,443"`)
createCmd.Flags().StringP("remote-tcp", "c", "", `Remote host for inlets-pro to use for forwarding TCP connections`)
}

// clientCmd represents the client sub command.
Expand Down Expand Up @@ -96,9 +96,10 @@ func runCreate(cmd *cobra.Command, _ []string) error {
return errors.Wrap(err, "failed to get 'region' value.")
}

remoteTCP, _ := cmd.Flags().GetString("remoteTCP")
remoteTCP, _ := cmd.Flags().GetString("remote-tcp")

name := strings.Replace(pkg.GetRandomName(10), "_", "-", -1)

inletsControlPort := 8080

userData := makeUserdata(inletsToken, inletsControlPort, remoteTCP)
Expand Down Expand Up @@ -127,7 +128,8 @@ func runCreate(cmd *cobra.Command, _ []string) error {
fmt.Printf("Host: %s, status: %s\n", hostStatus.ID, hostStatus.Status)

if hostStatus.Status == "active" {
fmt.Printf(`Exit-node summary:
if len(remoteTCP) == 0 {
fmt.Printf(`Inlets OSS exit-node summary:
IP: %s
Auth-token: %s
Expand All @@ -137,7 +139,35 @@ Command:
--token "%s" \
--upstream $UPSTREAM
`,
hostStatus.IP, inletsToken, hostStatus.IP, inletsControlPort, inletsToken)
hostStatus.IP, inletsToken, hostStatus.IP, inletsControlPort, inletsToken)
fmt.Printf(`Inlets OSS exit-node summary:
IP: %s
Auth-token: %s
Command:
export UPSTREAM=http://127.0.0.1:8000
inlets client --remote "ws://%s:%d" \
--token "%s" \
--upstream $UPSTREAM
`,
hostStatus.IP, inletsToken, hostStatus.IP, inletsControlPort, inletsToken)
} else {
proPort := 8123
fmt.Printf(`inlets-pro exit-node summary:
IP: %s
Auth-token: %s
Command:
export TCP_PORTS="8000"
export LICENSE=""
inlets-pro client --connect "ws://%s:%d/connect" \
--token "%s" \
--license "$LICENSE" \
--tcp-ports 8000
`,
hostStatus.IP, inletsToken, hostStatus.IP, proPort, inletsToken)
}

return nil
}
}
Expand Down

0 comments on commit c31d4f0

Please sign in to comment.