package proxy import ( "github.com/openziti-test-kitchen/zrok/util" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/config" "github.com/pkg/errors" "net/http" ) func Run(cfg *Config) error { zCfg, err := config.NewFromFile(cfg.IdentityPath) if err != nil { return errors.Wrap(err, "error loading config") } zCtx := ziti.NewContextWithConfig(zCfg) zDialCtx := util.ZitiDialContext{Context: zCtx} zTransport := http.DefaultTransport.(*http.Transport).Clone() zTransport.DialContext = zDialCtx.Dial proxy, err := util.NewProxy("http://zrok") if err != nil { return err } proxy.Transport = zTransport return http.ListenAndServe(cfg.Address, util.NewProxyHandler(proxy)) }