diff options
author | atanarjuat <atanarjuat@example.com> | 2022-06-06 14:46:49 +0200 |
---|---|---|
committer | atanarjuat <atanarjuat@example.com> | 2022-06-06 14:46:49 +0200 |
commit | e36993da03ee0acdb19bfe8e66afe8e5a993b544 (patch) | |
tree | 8a58165a3ed88b65d6c3520b4afef36b88b3bca1 | |
parent | 091c162ffd0cad17033b1ef6b3698f168193eeb4 (diff) |
avoid panic
-rw-r--r-- | dialer.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 }) } |