Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/XTLS/Xray-core:
  Fix available mux picker in reverse portal (XTLS#274)
  Fix XTLS#289 (XTLS#300)
  Fix XTLS#320
  • Loading branch information
github-actions[bot] committed Mar 1, 2021
2 parents 6afa3d9 + c345d48 commit 695c0c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/reverse/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (p *StaticMuxPicker) PickAvailable() (*mux.ClientWorker, error) {
if w.draining {
continue
}
if w.client.Closed() {
continue
}
if w.client.ActiveConnections() < minConn {
minConn = w.client.ActiveConnections()
minIdx = i
Expand Down
9 changes: 5 additions & 4 deletions main/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/xtls/xray-core/common/cmdarg"
"github.com/xtls/xray-core/common/platform"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/infra/conf"
"github.com/xtls/xray-core/main/commands/base"
)

Expand Down Expand Up @@ -82,9 +81,11 @@ func executeRun(cmd *base.Command, args []string) {
}
defer server.Close()

conf.FileCache = nil
conf.IPCache = nil
conf.SiteCache = nil
/*
conf.FileCache = nil
conf.IPCache = nil
conf.SiteCache = nil
*/

// Explicitly triggering GC to remove garbage from config loading.
runtime.GC()
Expand Down
14 changes: 11 additions & 3 deletions transport/internet/http/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/net/cnc"
"github.com/xtls/xray-core/common/session"
"github.com/xtls/xray-core/transport/internet"
"github.com/xtls/xray-core/transport/internet/tls"
"github.com/xtls/xray-core/transport/pipe"
Expand All @@ -22,7 +23,7 @@ var (
globalDialerAccess sync.Mutex
)

func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config) (*http.Client, error) {
func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config, sockopt *internet.SocketConfig) (*http.Client, error) {
globalDialerAccess.Lock()
defer globalDialerAccess.Unlock()

Expand All @@ -49,17 +50,24 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
}
address := net.ParseAddress(rawHost)

pconn, err := internet.DialSystem(ctx, net.TCPDestination(address, port), nil)
dctx := context.Background()
dctx = session.ContextWithID(dctx, session.IDFromContext(ctx))
dctx = session.ContextWithOutbound(dctx, session.OutboundFromContext(ctx))

pconn, err := internet.DialSystem(dctx, net.TCPDestination(address, port), sockopt)
if err != nil {
newError("failed to dial to " + addr).Base(err).AtError().WriteToLog()
return nil, err
}

cn := gotls.Client(pconn, tlsConfig)
if err := cn.Handshake(); err != nil {
newError("failed to dial to " + addr).Base(err).AtError().WriteToLog()
return nil, err
}
if !tlsConfig.InsecureSkipVerify {
if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil {
newError("failed to dial to " + addr).Base(err).AtError().WriteToLog()
return nil, err
}
}
Expand Down Expand Up @@ -90,7 +98,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
if tlsConfig == nil {
return nil, newError("TLS must be enabled for http transport.").AtWarning()
}
client, err := getHTTPClient(ctx, dest, tlsConfig)
client, err := getHTTPClient(ctx, dest, tlsConfig, streamSettings.SocketSettings)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 695c0c2

Please sign in to comment.