Skip to content

Commit

Permalink
use token for communication, change port to 8444 (#12)
Browse files Browse the repository at this point in the history
* use token for communication, change port to 8444

Signed-off-by: Nandor Kracser <[email protected]>

* upgrade ghostunnel

Signed-off-by: Nandor Kracser <[email protected]>
  • Loading branch information
bonifaido authored Mar 16, 2020
1 parent f8f4aa7 commit 98e9740
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions kurun.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
"bytes"
"encoding/base64"
"fmt"
"math/rand"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -206,6 +208,14 @@ var portForwardCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

tokenBytes := make([]byte, 16)
_, err := rand.New(rand.NewSource(time.Now().UnixNano())).Read(tokenBytes)
if err != nil {
return err
}

token := base64.RawStdEncoding.EncodeToString(tokenBytes)

deploymentName := serviceName
if deploymentName != "kurun" {
deploymentName += "-kurun"
Expand Down Expand Up @@ -286,7 +296,7 @@ var portForwardCmd = &cobra.Command{
ports := []corev1.ContainerPort{
{
Name: "inlets",
ContainerPort: 8000,
ContainerPort: 8444,
},
}

Expand All @@ -313,8 +323,8 @@ var portForwardCmd = &cobra.Command{
containers := []corev1.Container{
{
Name: "inlets-server",
Image: "alexellis2/inlets:2.4.1",
Command: []string{"inlets", "server", "-p", fmt.Sprint(inletsPort)},
Image: "inlets/inlets:2.7.0",
Command: []string{"inlets", "server", "-p", fmt.Sprint(inletsPort), "--token", token},
Ports: ports,
},
}
Expand All @@ -325,7 +335,7 @@ var portForwardCmd = &cobra.Command{

containers = append(containers, corev1.Container{
Name: "ghostunnel",
Image: "squareup/ghostunnel:v1.5.0-rc.2",
Image: "squareup/ghostunnel:v1.5.2",
Args: []string{
"server",
"--target",
Expand Down Expand Up @@ -417,7 +427,7 @@ var portForwardCmd = &cobra.Command{
kubectlArgs = []string{
"port-forward",
"deployment/" + deploymentName,
"8000:" + fmt.Sprint(inletsPort),
"8444:" + fmt.Sprint(inletsPort),
}

if namespace != "" {
Expand All @@ -442,7 +452,7 @@ var portForwardCmd = &cobra.Command{

upstream := args[0]

inletsCommand := exec.Command("inlets", "client", "--upstream", upstream)
inletsCommand := exec.Command("inlets", "client", "--upstream", upstream, "--remote", "127.0.0.1:8444", "--token", token)
inletsCommand.Stderr = os.Stderr
inletsCommand.Stdout = os.Stdout

Expand Down

0 comments on commit 98e9740

Please sign in to comment.