Skip to content

Commit

Permalink
refactor: return context error
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Jan 22, 2024
1 parent 666e24e commit f39f9e1
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions internal/tun/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tun
import (
"bytes"
"context"
"errors"
"net"
"os"
"sync"
Expand All @@ -15,10 +14,6 @@ import (
"github.com/ooni/minivpn/internal/session"
)

var (
ErrInitializationTimeout = errors.New("timeout while waiting for TUN to start")
)

// StartTUN initializes and starts the TUN device over the vpn.
// If the passed context expires before the TUN device is ready,
func StartTUN(ctx context.Context, conn networkio.FramingConn, options *model.Options) (*TUN, error) {
Expand All @@ -44,7 +39,7 @@ func StartTUN(ctx context.Context, conn networkio.FramingConn, options *model.Op

select {
case <-ctx.Done():
return nil, ErrInitializationTimeout
return nil, ctx.Err()
case <-sessionManager.Ready:
return tunnel, nil
}
Expand Down

0 comments on commit f39f9e1

Please sign in to comment.