Skip to content

Commit

Permalink
Merge pull request #773 from openziti/sdk_dial_timeout
Browse files Browse the repository at this point in the history
Change SDK Dial Timeout to 30 Seconds (#772)
  • Loading branch information
michaelquigley authored Oct 18, 2024
2 parents 2981433 + ae86dc0 commit ef1795f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## v0.4.42

CHANGE: Switch all `Dial` operations made into the OpenZiti overlay to use `DialWithOptions(..., &ziti.DialOptions{ConnectTimeout: 30 * time.Second})`, switching to a 30 second timeout from a 5 second default (https://github.com/openziti/zrok/issues/772)

FIX: Removed the `--basic-auth` flag from `zrok share private` as this was ignored... even if `zrok access private` honored the `ziti.proxy.v1` config to ask for basic auth, it would still be easy to write a custom SDK client that ignored the basic auth and accessed the share directly; better to remove the option than to allow confusing usage (https://github.com/openziti/zrok/issues/770)

FIX: always append common options like `--headless` and conditionally append `--verbose --insecure` if their respective env vars are set to when running in a service manager like systemd or Docker and wrapping the `zrok` command with the `zrok-share.bash` shell script (https://openziti.discourse.group/t/question-about-reserved-public-vs-temp-public-shares/3169)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/testWebsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (cmd *testWebsocketCommand) run(_ *cobra.Command, args []string) {
}
dial := func(_ context.Context, _, addr string) (net.Conn, error) {
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()
Expand Down
2 changes: 1 addition & 1 deletion endpoints/proxy/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type zitiDialContext struct {
}

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 {
return conn, err
}
Expand Down
2 changes: 1 addition & 1 deletion endpoints/publicProxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type zitiDialContext struct {

func (c *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
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 {
return conn, err
}
Expand Down
2 changes: 1 addition & 1 deletion endpoints/tcpTunnel/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (f *Frontend) Run() error {
}

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(zConn, conn)
if f.cfg.RequestsChan != nil {
Expand Down
2 changes: 1 addition & 1 deletion endpoints/udpTunnel/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (f *Frontend) Run() error {
_ = clt.zitiConn.Close()
}
} 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 {
logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err)
continue
Expand Down
2 changes: 1 addition & 1 deletion endpoints/vpn/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
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 {
zCtx.Close()
return nil, errors.Wrap(err, "error connecting to ziti")
Expand Down
3 changes: 2 additions & 1 deletion sdk/golang/sdk/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/openziti/sdk-golang/ziti/edge"
"github.com/openziti/zrok/environment/env_core"
"github.com/pkg/errors"
"time"
)

func NewDialer(shrToken string, root env_core.Root) (edge.Conn, error) {
Expand All @@ -23,7 +24,7 @@ func NewDialer(shrToken string, root env_core.Root) (edge.Conn, error) {
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 {
return nil, errors.Wrapf(err, "error dialing '%v'", shrToken)
}
Expand Down

0 comments on commit ef1795f

Please sign in to comment.