summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoratanarjuat <atanarjuat@example.com>2022-06-06 14:46:49 +0200
committeratanarjuat <atanarjuat@example.com>2022-06-06 14:46:49 +0200
commite36993da03ee0acdb19bfe8e66afe8e5a993b544 (patch)
tree8a58165a3ed88b65d6c3520b4afef36b88b3bca1
parent091c162ffd0cad17033b1ef6b3698f168193eeb4 (diff)
avoid panic
-rw-r--r--dialer.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/dialer.go b/dialer.go
index f38586d..402ac7e 100644
--- a/dialer.go
+++ b/dialer.go
@@ -3,6 +3,7 @@ package obfsvpn
import (
"context"
"encoding/base64"
+ "errors"
"fmt"
"net"
"strconv"
@@ -24,6 +25,10 @@ const (
certLength = ntor.NodeIDLength + ntor.PublicKeyLength
)
+var (
+ ErrCannotDial = errors.New("cannot dial")
+)
+
// IATMode determines the amount of time sent between packets.
type IATMode int
@@ -137,6 +142,9 @@ func (d *Dialer) Dial(network, address string) (net.Conn, error) {
ctx := context.Background()
return d.dial(ctx, network, address, func(network, address string) (net.Conn, error) {
conn, err := d.Dialer.DialContext(ctx, network, address)
+ if err != nil {
+ return nil, fmt.Errorf("%w: %s", ErrCannotDial, err)
+ }
return conn.(*net.TCPConn), err
})
}