add tls config option
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
package ws
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
tls_util "github.com/go-gost/gost/pkg/common/util/tls"
|
||||
mdata "github.com/go-gost/gost/pkg/metadata"
|
||||
)
|
||||
|
||||
@ -15,9 +12,8 @@ const (
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
path string
|
||||
host string
|
||||
tlsConfig *tls.Config
|
||||
host string
|
||||
path string
|
||||
|
||||
handshakeTimeout time.Duration
|
||||
readHeaderTimeout time.Duration
|
||||
@ -30,14 +26,8 @@ type metadata struct {
|
||||
|
||||
func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
path = "path"
|
||||
host = "host"
|
||||
|
||||
certFile = "certFile"
|
||||
keyFile = "keyFile"
|
||||
caFile = "caFile"
|
||||
secure = "secure"
|
||||
serverName = "serverName"
|
||||
path = "path"
|
||||
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
readHeaderTimeout = "readHeaderTimeout"
|
||||
@ -48,25 +38,13 @@ func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
header = "header"
|
||||
)
|
||||
|
||||
d.md.host = mdata.GetString(md, host)
|
||||
|
||||
d.md.path = mdata.GetString(md, path)
|
||||
if d.md.path == "" {
|
||||
d.md.path = defaultPath
|
||||
}
|
||||
|
||||
d.md.host = mdata.GetString(md, host)
|
||||
|
||||
sn, _, _ := net.SplitHostPort(mdata.GetString(md, serverName))
|
||||
if sn == "" {
|
||||
sn = "localhost"
|
||||
}
|
||||
d.md.tlsConfig, err = tls_util.LoadClientConfig(
|
||||
mdata.GetString(md, certFile),
|
||||
mdata.GetString(md, keyFile),
|
||||
mdata.GetString(md, caFile),
|
||||
mdata.GetBool(md, secure),
|
||||
sn,
|
||||
)
|
||||
|
||||
d.md.handshakeTimeout = mdata.GetDuration(md, handshakeTimeout)
|
||||
d.md.readHeaderTimeout = mdata.GetDuration(md, readHeaderTimeout)
|
||||
d.md.readBufferSize = mdata.GetInt(md, readBufferSize)
|
||||
|
Reference in New Issue
Block a user