From aea90a3c8253b9fa9bee664090188889bf584026 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Wed, 29 Dec 2021 12:43:18 +0100 Subject: [PATCH] refactor client to be a generic proxy --- client/cmd.go | 6 +++--- client/load_certificate.go | 2 +- client/proxy.go | 2 +- client/rewrite_request_url.go | 2 +- cmd/generate_certificate.go | 2 +- main.go | 4 ++-- terraform/iap-proxy.service | 2 +- terraform/main.tf | 4 ++-- terraform/output.tf | 5 +++-- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/client/cmd.go b/client/cmd.go index 1b1e57d..5bdb050 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -1,4 +1,4 @@ -package gkeclient +package client import ( "log" @@ -7,8 +7,8 @@ import ( "github.com/spf13/cobra" ) -// NewGKEClientCmd create a gke client command -func NewGKEClientCmd() *cobra.Command { +// NewClientCmd create a gke client command +func NewClientCmd() *cobra.Command { c := Proxy{ RootCommand: cmd.RootCommand{ Command: cobra.Command{ diff --git a/client/load_certificate.go b/client/load_certificate.go index 3d50c86..ad63989 100644 --- a/client/load_certificate.go +++ b/client/load_certificate.go @@ -1,4 +1,4 @@ -package gkeclient +package client import ( "crypto/tls" diff --git a/client/proxy.go b/client/proxy.go index 06cbd50..2d48f1c 100644 --- a/client/proxy.go +++ b/client/proxy.go @@ -1,4 +1,4 @@ -package gkeclient +package client import ( "context" diff --git a/client/rewrite_request_url.go b/client/rewrite_request_url.go index dd29fcd..0a0a56e 100644 --- a/client/rewrite_request_url.go +++ b/client/rewrite_request_url.go @@ -1,4 +1,4 @@ -package gkeclient +package client import ( "net/http" diff --git a/cmd/generate_certificate.go b/cmd/generate_certificate.go index c36f969..d1ffcd1 100644 --- a/cmd/generate_certificate.go +++ b/cmd/generate_certificate.go @@ -15,7 +15,7 @@ import ( "github.com/spf13/cobra" ) -// GeneratedCertificate command +// GenerateCertificate represents the command to generate a certificate type GenerateCertificate struct { RootCommand DNSName string diff --git a/main.go b/main.go index 7003670..2de61bc 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "log" "github.com/binxio/simple-iap-proxy/cmd" - "github.com/binxio/simple-iap-proxy/gkeclient" + "github.com/binxio/simple-iap-proxy/client" "github.com/binxio/simple-iap-proxy/gkeserver" "github.com/spf13/cobra" ) @@ -24,7 +24,7 @@ is run inside the VPC. } c.AddPersistentFlags() c.AddCommand(cmd.NewGenerateCertificateCmd()) - c.AddCommand(gkeclient.NewGKEClientCmd()) + c.AddCommand(client.NewClientCmd()) c.AddCommand(gkeserver.NewGKEServerCmd()) return &c } diff --git a/terraform/iap-proxy.service b/terraform/iap-proxy.service index 53f9019..838f23b 100644 --- a/terraform/iap-proxy.service +++ b/terraform/iap-proxy.service @@ -5,7 +5,7 @@ After=docker.service network-online.target [Service] -Environment="IMAGE=gcr.io/binx-io-public/simple-iap-proxy:0.4.1" +Environment="IMAGE=gcr.io/binx-io-public/simple-iap-proxy:0.5.1" ExecStartPre=ctr images pull ${IMAGE} diff --git a/terraform/main.tf b/terraform/main.tf index 26ce83d..a81838f 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -203,8 +203,8 @@ locals { cloud_config = { runcmd = [ "c_rehash > /dev/null", - "iptables -I INPUT -p tcp -j ACCEPT", - "i6ptables -I INPUT -p tcp -j ACCEPT", + "iptables -I INPUT -p tcp -j ACCEPT --dport 8443", + "i6ptables -I INPUT -p tcp -j ACCEPT --dport 8443", "systemctl daemon-reload", "systemctl enable --now iap-proxy.service" ] diff --git a/terraform/output.tf b/terraform/output.tf index 99bd818..37114e7 100644 --- a/terraform/output.tf +++ b/terraform/output.tf @@ -53,12 +53,13 @@ EOF output "iap_proxy_command" { value = <