Dial(shr) -> DialWithOptions(shr, ...) (#772)

This commit is contained in:
Michael Quigley 2024-10-18 11:36:13 -04:00
parent 9b83157a9b
commit 2a1e39e1e6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
7 changed files with 8 additions and 7 deletions

View File

@ -76,7 +76,7 @@ func (cmd *testWebsocketCommand) run(_ *cobra.Command, args []string) {
} }
dial := func(_ context.Context, _, addr string) (net.Conn, error) { dial := func(_ context.Context, _, addr string) (net.Conn, error) {
service := strings.Split(addr, ":")[0] service := strings.Split(addr, ":")[0]
return zitiContext.Dial(service) return zitiContext.DialWithOptions(service, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
} }
zitiTransport := http.DefaultTransport.(*http.Transport).Clone() zitiTransport := http.DefaultTransport.(*http.Transport).Clone()

View File

@ -91,7 +91,7 @@ type zitiDialContext struct {
} }
func (zdc *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { func (zdc *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
conn, err := zdc.ctx.Dial(zdc.shrToken) conn, err := zdc.ctx.DialWithOptions(zdc.shrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
if err != nil { if err != nil {
return conn, err return conn, err
} }

View File

@ -95,7 +95,7 @@ type zitiDialContext struct {
func (c *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { func (c *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
shrToken := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port') shrToken := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port')
conn, err := c.ctx.Dial(shrToken) conn, err := c.ctx.DialWithOptions(shrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
if err != nil { if err != nil {
return conn, err return conn, err
} }

View File

@ -69,7 +69,7 @@ func (f *Frontend) Run() error {
} }
func (f *Frontend) accept(conn net.Conn) { func (f *Frontend) accept(conn net.Conn) {
if zConn, err := f.zCtx.Dial(f.cfg.ShrToken); err == nil { if zConn, err := f.zCtx.DialWithOptions(f.cfg.ShrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second}); err == nil {
go endpoints.TXer(conn, zConn) go endpoints.TXer(conn, zConn)
go endpoints.TXer(zConn, conn) go endpoints.TXer(zConn, conn)
if f.cfg.RequestsChan != nil { if f.cfg.RequestsChan != nil {

View File

@ -148,7 +148,7 @@ func (f *Frontend) Run() error {
_ = clt.zitiConn.Close() _ = clt.zitiConn.Close()
} }
} else { } else {
zitiConn, err := f.zCtx.Dial(f.cfg.ShrToken) zitiConn, err := f.zCtx.DialWithOptions(f.cfg.ShrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
if err != nil { if err != nil {
logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err) logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err)
continue continue

View File

@ -45,7 +45,7 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading ziti context") return nil, errors.Wrap(err, "error loading ziti context")
} }
zConn, err := zCtx.Dial(cfg.ShrToken) zConn, err := zCtx.DialWithOptions(cfg.ShrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
if err != nil { if err != nil {
zCtx.Close() zCtx.Close()
return nil, errors.Wrap(err, "error connecting to ziti") return nil, errors.Wrap(err, "error connecting to ziti")

View File

@ -5,6 +5,7 @@ import (
"github.com/openziti/sdk-golang/ziti/edge" "github.com/openziti/sdk-golang/ziti/edge"
"github.com/openziti/zrok/environment/env_core" "github.com/openziti/zrok/environment/env_core"
"github.com/pkg/errors" "github.com/pkg/errors"
"time"
) )
func NewDialer(shrToken string, root env_core.Root) (edge.Conn, error) { func NewDialer(shrToken string, root env_core.Root) (edge.Conn, error) {
@ -23,7 +24,7 @@ func NewDialer(shrToken string, root env_core.Root) (edge.Conn, error) {
return nil, errors.Wrap(err, "error getting ziti context") return nil, errors.Wrap(err, "error getting ziti context")
} }
conn, err := zctx.Dial(shrToken) conn, err := zctx.DialWithOptions(shrToken, &ziti.DialOptions{ConnectTimeout: 30 * time.Second})
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error dialing '%v'", shrToken) return nil, errors.Wrapf(err, "error dialing '%v'", shrToken)
} }