mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-11 17:47:20 +10:00
ktls: Add warning for inappropriate scenarios
This commit is contained in:
@@ -43,7 +43,12 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
authenticator: auth.NewAuthenticator(options.Users),
|
||||
}
|
||||
if options.TLS != nil {
|
||||
tlsConfig, err := tls.NewServer(ctx, logger, common.PtrValueOrDefault(options.TLS))
|
||||
tlsConfig, err := tls.NewServerWithOptions(tls.ServerOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,12 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
authenticator: auth.NewAuthenticator(options.Users),
|
||||
}
|
||||
if options.TLS != nil {
|
||||
tlsConfig, err := tls.NewServer(ctx, logger, common.PtrValueOrDefault(options.TLS))
|
||||
tlsConfig, err := tls.NewServerWithOptions(tls.ServerOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -50,7 +50,13 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
users: options.Users,
|
||||
}
|
||||
if options.TLS != nil {
|
||||
tlsConfig, err := tls.NewServer(ctx, logger, common.PtrValueOrDefault(options.TLS))
|
||||
tlsConfig, err := tls.NewServerWithOptions(tls.ServerOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: common.PtrValueOrDefault(options.Transport).Type == "" &&
|
||||
!common.PtrValueOrDefault(options.Multiplex).Enabled,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -51,7 +51,14 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
key: trojan.Key(options.Password),
|
||||
}
|
||||
if options.TLS != nil {
|
||||
outbound.tlsConfig, err = tls.NewClient(ctx, logger, options.Server, common.PtrValueOrDefault(options.TLS))
|
||||
outbound.tlsConfig, err = tls.NewClientWithOptions(tls.ClientOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
ServerAddress: options.Server,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: common.PtrValueOrDefault(options.Transport).Type == "" &&
|
||||
!common.PtrValueOrDefault(options.Multiplex).Enabled,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -68,7 +68,16 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
}))
|
||||
inbound.service = service
|
||||
if options.TLS != nil {
|
||||
inbound.tlsConfig, err = tls.NewServer(ctx, logger, common.PtrValueOrDefault(options.TLS))
|
||||
inbound.tlsConfig, err = tls.NewServerWithOptions(tls.ServerOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: common.PtrValueOrDefault(options.Transport).Type == "" &&
|
||||
!common.PtrValueOrDefault(options.Multiplex).Enabled &&
|
||||
common.All(options.Users, func(it option.VLESSUser) bool {
|
||||
return it.Flow == ""
|
||||
}),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
serverAddr: options.ServerOptions.Build(),
|
||||
}
|
||||
if options.TLS != nil {
|
||||
outbound.tlsConfig, err = tls.NewClient(ctx, logger, options.Server, common.PtrValueOrDefault(options.TLS))
|
||||
outbound.tlsConfig, err = tls.NewClientWithOptions(tls.ClientOptions{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
ServerAddress: options.Server,
|
||||
Options: common.PtrValueOrDefault(options.TLS),
|
||||
KTLSCompatible: common.PtrValueOrDefault(options.Transport).Type == "" &&
|
||||
!common.PtrValueOrDefault(options.Multiplex).Enabled &&
|
||||
options.Flow == "",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user