enable use cdn edge ip to accelerate cdn transport when wss
This commit is contained in:
parent
41ccf890e9
commit
661e4b2d3e
@ -170,6 +170,7 @@ func parseChainNode(ns string) (nodes []gost.Node, err error) {
|
||||
wsOpts.WriteBufferSize = node.GetInt("wbuf")
|
||||
wsOpts.UserAgent = node.Get("agent")
|
||||
wsOpts.Path = node.Get("path")
|
||||
wsOpts.Host = node.Get("host")
|
||||
|
||||
timeout := node.GetDuration("timeout")
|
||||
|
||||
|
12
ws.go
12
ws.go
@ -5,15 +5,15 @@ import (
|
||||
"crypto/sha1"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"net/url"
|
||||
|
||||
"github.com/go-log/log"
|
||||
"github.com/gorilla/websocket"
|
||||
smux "github.com/xtaci/smux"
|
||||
@ -31,6 +31,7 @@ type WSOptions struct {
|
||||
EnableCompression bool
|
||||
UserAgent string
|
||||
Path string
|
||||
Host string
|
||||
}
|
||||
|
||||
type wsTransporter struct {
|
||||
@ -749,6 +750,13 @@ func websocketClientConn(url string, conn net.Conn, tlsConfig *tls.Config, optio
|
||||
if options.UserAgent != "" {
|
||||
header.Set("User-Agent", options.UserAgent)
|
||||
}
|
||||
if options.Host != "" {
|
||||
fmt.Println("获取到命令行传参host==>", options.Host)
|
||||
dialer.TLSClientConfig.ServerName = options.Host
|
||||
header.Set("Host", options.Host)
|
||||
}
|
||||
|
||||
fmt.Printf("TLSClientConfig==>%+v\n", dialer.TLSClientConfig)
|
||||
c, resp, err := dialer.Dial(url, header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user