mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-12 19:39:35 +03:00
Add REALITY support to gRPC client and server
Now you are able to configure REALITY gRPC client and server Duplicate of REALITY H2, perhaps, just for fun
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"github.com/xtls/xray-core/transport/internet/grpc/encoding"
|
||||
"github.com/xtls/xray-core/transport/internet/reality"
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
"github.com/xtls/xray-core/transport/internet/tls"
|
||||
"google.golang.org/grpc"
|
||||
@ -77,6 +78,7 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
|
||||
globalDialerMap = make(map[dialerConf]*grpc.ClientConn)
|
||||
}
|
||||
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
|
||||
realityConfig := reality.ConfigFromStreamSettings(streamSettings)
|
||||
sockopt := streamSettings.SocketSettings
|
||||
grpcSettings := streamSettings.ProtocolSettings.(*Config)
|
||||
|
||||
@ -116,7 +118,11 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
|
||||
return nil, err
|
||||
}
|
||||
address := net.ParseAddress(rawHost)
|
||||
return internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt)
|
||||
c, err := internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt)
|
||||
if err == nil && realityConfig != nil {
|
||||
return reality.UClient(c, realityConfig, ctx, dest)
|
||||
}
|
||||
return c, err
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,13 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
goreality "github.com/xtls/reality"
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"github.com/xtls/xray-core/transport/internet/grpc/encoding"
|
||||
"github.com/xtls/xray-core/transport/internet/reality"
|
||||
"github.com/xtls/xray-core/transport/internet/tls"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@ -125,6 +127,9 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
|
||||
|
||||
encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getNormalizedName())
|
||||
|
||||
if config := reality.ConfigFromStreamSettings(settings); config != nil {
|
||||
streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig())
|
||||
}
|
||||
if err = s.Serve(streamListener); err != nil {
|
||||
newError("Listener for gRPC ended").Base(err).WriteToLog()
|
||||
}
|
||||
|
Reference in New Issue
Block a user