Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: add NetDialContext to config #27

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
package wsc

import (
"context"
"crypto/tls"
"net"
"net/http"
"time"
)

// Config contains configuration for the webbsocket.
type Config struct {
WriteWait time.Duration
PongWait time.Duration
PingPeriod time.Duration
TLSConfig *tls.Config
ReadBufferSize int
ReadChanSize int
WriteBufferSize int
WriteChanSize int
EnableCompression bool
Headers http.Header
TLSConfig *tls.Config
Headers http.Header
NetDialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
WriteWait time.Duration
PongWait time.Duration
PingPeriod time.Duration
ReadBufferSize int
ReadChanSize int
WriteBufferSize int
WriteChanSize int
EnableCompression bool
}
3 changes: 2 additions & 1 deletion wsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ func Connect(ctx context.Context, url string, config Config) (Websocket, *http.R
ReadBufferSize: config.ReadBufferSize,
WriteBufferSize: config.WriteBufferSize,
EnableCompression: config.EnableCompression,
NetDialContext: config.NetDialContextFunc,
}

conn, resp, err := dialer.Dial(url, config.Headers)
conn, resp, err := dialer.DialContext(ctx, url, config.Headers)
if err != nil {
return nil, resp, err
}
Expand Down