mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-19 09:24:59 +03:00
Add v2ray HTTP transport
This commit is contained in:
@@ -114,7 +114,7 @@ func NewHysteria(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
udpSessions: make(map[uint32]chan *hysteria.UDPMessage),
|
||||
}
|
||||
if options.TLS == nil || !options.TLS.Enabled {
|
||||
return nil, errTLSRequired
|
||||
return nil, C.ErrTLSRequired
|
||||
}
|
||||
if len(options.TLS.ALPN) == 0 {
|
||||
options.TLS.ALPN = []string{hysteria.DefaultALPN}
|
||||
|
||||
@@ -44,8 +44,6 @@ type Naive struct {
|
||||
h3Server any
|
||||
}
|
||||
|
||||
var errTLSRequired = E.New("TLS required")
|
||||
|
||||
func NewNaive(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.NaiveInboundOptions) (*Naive, error) {
|
||||
inbound := &Naive{
|
||||
ctx: ctx,
|
||||
@@ -57,7 +55,7 @@ func NewNaive(ctx context.Context, router adapter.Router, logger log.ContextLogg
|
||||
authenticator: auth.NewAuthenticator(options.Users),
|
||||
}
|
||||
if options.TLS == nil || !options.TLS.Enabled {
|
||||
return nil, errTLSRequired
|
||||
return nil, C.ErrTLSRequired
|
||||
}
|
||||
if len(options.Users) == 0 {
|
||||
return nil, E.New("missing users")
|
||||
|
||||
@@ -63,9 +63,13 @@ func NewVMess(ctx context.Context, router adapter.Router, logger log.ContextLogg
|
||||
}
|
||||
}
|
||||
if options.Transport != nil {
|
||||
inbound.transport, err = v2ray.NewServerTransport(ctx, common.PtrValueOrDefault(options.Transport), inbound.tlsConfig.Config(), adapter.NewUpstreamHandler(adapter.InboundContext{}, inbound.newTransportConnection, nil, nil), inbound)
|
||||
var tlsConfig *tls.Config
|
||||
if inbound.tlsConfig != nil {
|
||||
tlsConfig = inbound.tlsConfig.Config()
|
||||
}
|
||||
inbound.transport, err = v2ray.NewServerTransport(ctx, common.PtrValueOrDefault(options.Transport), tlsConfig, adapter.NewUpstreamHandler(adapter.InboundContext{}, inbound.newTransportConnection, nil, nil), inbound)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, E.Cause(err, "create server transport: ", options.Transport.Type)
|
||||
}
|
||||
}
|
||||
inbound.connHandler = inbound
|
||||
@@ -75,7 +79,7 @@ func NewVMess(ctx context.Context, router adapter.Router, logger log.ContextLogg
|
||||
func (h *VMess) Start() error {
|
||||
err := common.Start(
|
||||
h.service,
|
||||
h.tlsConfig,
|
||||
common.PtrOrNil(h.tlsConfig),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user