mirror of
https://github.com/wahyd4/kt-connect.git
synced 2026-08-09 05:16:02 +10:00
improve: rename shadow interface
This commit is contained in:
@@ -116,7 +116,7 @@ func (action *Action) Connect(options *options.DaemonOptions) (err error) {
|
||||
}
|
||||
|
||||
shadow := connect.Create(options)
|
||||
err = shadow.Connect(podName, endPointIP, cidrs)
|
||||
err = shadow.Outbound(podName, endPointIP, cidrs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (action *Action) Exchange(exchange string, options *options.DaemonOptions)
|
||||
kubernetes.Scale(app, &down)
|
||||
|
||||
shadow := connect.Create(options)
|
||||
shadow.RemotePortForward(options.ExchangeOptions.Expose, podName, podIP)
|
||||
shadow.Inbound(options.ExchangeOptions.Expose, podName, podIP)
|
||||
|
||||
s := <-ch
|
||||
log.Info().Msgf("Terminal Signal is %s", s)
|
||||
|
||||
@@ -84,7 +84,7 @@ func (action *Action) Mesh(mesh string, options *options.DaemonOptions) error {
|
||||
options.RuntimeOptions.Shadow = workload
|
||||
|
||||
shadow := connect.Create(options)
|
||||
err = shadow.RemotePortForward(options.MeshOptions.Expose, podName, podIP)
|
||||
err = shadow.Inbound(options.MeshOptions.Expose, podName, podIP)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -81,7 +81,7 @@ func (action *Action) Run(service string, options *options.DaemonOptions) error
|
||||
options.RuntimeOptions.Shadow = service
|
||||
|
||||
shadow := connect.Create(options)
|
||||
err = shadow.RemotePortForward(strconv.Itoa(options.RunOptions.Port), podName, podIP)
|
||||
err = shadow.Inbound(strconv.Itoa(options.RunOptions.Port), podName, podIP)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// RemotePortForward mapping local port from cluster
|
||||
func (s *Shadow) RemotePortForward(expose, podName, remoteIP string) (err error) {
|
||||
// Inbound mapping local port from cluster
|
||||
func (s *Shadow) Inbound(exposePort, podName, remoteIP string) (err error) {
|
||||
debug := s.Options.Debug
|
||||
kubeConfig := s.Options.KubeConfig
|
||||
namespace := s.Options.Namespace
|
||||
log.Info().Msgf("remote %s forward to local %s", remoteIP, expose)
|
||||
log.Info().Msgf("remote %s forward to local %s", remoteIP, exposePort)
|
||||
localSSHPort, err := strconv.Atoi(util.GetRandomSSHPort(remoteIP))
|
||||
if err != nil {
|
||||
return
|
||||
@@ -34,9 +34,9 @@ func (s *Shadow) RemotePortForward(expose, podName, remoteIP string) (err error)
|
||||
return
|
||||
}
|
||||
log.Printf("SSH Remote port-forward POD %s 22 to 127.0.0.1:%d starting\n", remoteIP, localSSHPort)
|
||||
localPort := expose
|
||||
remotePort := expose
|
||||
ports := strings.SplitN(expose, ":", 2)
|
||||
localPort := exposePort
|
||||
remotePort := exposePort
|
||||
ports := strings.SplitN(exposePort, ":", 2)
|
||||
if len(ports) > 1 {
|
||||
localPort = ports[1]
|
||||
remotePort = ports[0]
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// Connect start vpn connection
|
||||
func (s *Shadow) Connect(name, podIP string, cidrs []string) (err error) {
|
||||
// Outbound start vpn connection
|
||||
func (s *Shadow) Outbound(name, podIP string, cidrs []string) (err error) {
|
||||
options := s.Options
|
||||
err = util.PrepareSSHPrivateKey()
|
||||
if err != nil {
|
||||
|
||||
@@ -4,8 +4,8 @@ import "github.com/alibaba/kt-connect/pkg/kt/options"
|
||||
|
||||
// ShadowInterface shadow interface
|
||||
type ShadowInterface interface {
|
||||
Connect(name, podIP string, cidrs []string, options *options.DaemonOptions) (err error)
|
||||
RemotePortForward(expose, kubeconfig, namespace, target, remoteIP string, debug bool) (err error)
|
||||
Inbound(exposePort, podName, remoteIP string) (err error)
|
||||
Outbound(name, podIP string, cidrs []string) (err error)
|
||||
}
|
||||
|
||||
// Shadow shadow
|
||||
|
||||
Reference in New Issue
Block a user