mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-13 15:48:39 +00:00
Add gRPC Transport support (#356)
Co-authored-by: JimhHan <50871214+JimhHan@users.noreply.github.com>
This commit is contained in:
parent
60b06877bf
commit
a0a32ee00d
23 changed files with 1564 additions and 4 deletions
|
@ -18,8 +18,13 @@ import (
|
|||
"golang.org/x/net/http2"
|
||||
)
|
||||
|
||||
type dialerConf struct {
|
||||
net.Destination
|
||||
*internet.SocketConfig
|
||||
}
|
||||
|
||||
var (
|
||||
globalDialerMap map[net.Destination]*http.Client
|
||||
globalDialerMap map[dialerConf]*http.Client
|
||||
globalDialerAccess sync.Mutex
|
||||
)
|
||||
|
||||
|
@ -28,10 +33,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
|
|||
defer globalDialerAccess.Unlock()
|
||||
|
||||
if globalDialerMap == nil {
|
||||
globalDialerMap = make(map[net.Destination]*http.Client)
|
||||
globalDialerMap = make(map[dialerConf]*http.Client)
|
||||
}
|
||||
|
||||
if client, found := globalDialerMap[dest]; found {
|
||||
if client, found := globalDialerMap[dialerConf{dest, sockopt}]; found {
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
@ -87,7 +92,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
|
|||
Transport: transport,
|
||||
}
|
||||
|
||||
globalDialerMap[dest] = client
|
||||
globalDialerMap[dialerConf{dest, sockopt}] = client
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue