Skip to content

Commit 5a9a546

Browse files
committed
hardcode dial timeout seconds
1 parent ed19197 commit 5a9a546

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

vpn/client.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ var (
2525

2626
// ErrNotReady is returned when a Read/Write attempt is made before the tunnel is ready.
2727
ErrNotReady = errors.New("tunnel not ready")
28+
29+
// ErrBadProxy is returned when attempting to use an unregistered proxy.
30+
ErrBadProxy = errors.New("unknown proxy")
31+
)
32+
33+
const (
34+
// dialTimeoutInSeconds tells how long to wait on Dial
35+
dialTimeoutInSeconds = 10
2836
)
2937

3038
// tunnelInfo holds state about the VPN tunnelInfo that has longer duration than a
@@ -119,7 +127,12 @@ func (c *Client) Start(ctx context.Context) error {
119127
func (c *Client) start(ctx context.Context) error {
120128
c.emit(EventReady)
121129

122-
conn, err := c.dial(ctx)
130+
// we hardcode a lesser-lived context for dial step for now.
131+
dialCtx, cancel := context.WithDeadline(
132+
context.Background(),
133+
time.Now().Add(dialTimeoutInSeconds*time.Second))
134+
defer cancel()
135+
conn, err := c.dial(dialCtx)
123136
if err != nil {
124137
return err
125138
}

0 commit comments

Comments
 (0)