2019-01-01 08:23:01 +00:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2019-05-29 18:53:51 +00:00
|
|
|
"github.com/google/tcpproxy"
|
2019-01-09 16:54:15 +00:00
|
|
|
"github.com/rancher/k3s/pkg/daemons/config"
|
2019-01-01 08:23:01 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
func Run(config *config.Node) error {
|
2019-05-29 18:53:51 +00:00
|
|
|
logrus.Infof("Starting proxy %s -> %s", config.LocalAddress, config.ServerAddress)
|
|
|
|
var proxy tcpproxy.Proxy
|
|
|
|
proxy.AddRoute(config.LocalAddress, tcpproxy.To(config.ServerAddress))
|
2019-01-01 08:23:01 +00:00
|
|
|
go func() {
|
2019-05-29 18:53:51 +00:00
|
|
|
err := proxy.Run()
|
2019-01-01 08:23:01 +00:00
|
|
|
logrus.Fatalf("TLS proxy stopped: %v", err)
|
|
|
|
}()
|
|
|
|
return nil
|
|
|
|
}
|