Add v2ray WebSocket transport

This commit is contained in:
世界 2022-08-22 20:20:56 +08:00
parent 082872b2f3
commit 77c98fd042
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
13 changed files with 475 additions and 53 deletions

View file

@ -8,6 +8,7 @@ import (
"time"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
@ -31,7 +32,7 @@ type Client struct {
connAccess sync.Mutex
}
func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, serviceName string, tlsConfig *tls.Config) adapter.V2RayClientTransport {
func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, options option.V2RayGRPCOptions, tlsConfig *tls.Config) adapter.V2RayClientTransport {
var dialOptions []grpc.DialOption
if tlsConfig != nil {
dialOptions = append(dialOptions, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
@ -55,7 +56,7 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, ser
ctx: ctx,
dialer: dialer,
serverAddr: serverAddr.String(),
serviceName: serviceName,
serviceName: options.ServiceName,
dialOptions: dialOptions,
}
}