@ -70,12 +70,12 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
// Process implements proxy.Outbound.Process().
// Process implements proxy.Outbound.Process().
func ( h * Handler ) Process ( ctx context . Context , link * transport . Link , dialer internet . Dialer ) error {
func ( h * Handler ) Process ( ctx context . Context , link * transport . Link , dialer internet . Dialer ) error {
outbound := session . OutboundFromContext ( ctx )
outbounds := session . OutboundsFromContext ( ctx )
if outbound == nil || ! outbound . Target . IsValid ( ) {
ob := outbounds [ len ( outbounds ) - 1 ]
if ! ob . Target . IsValid ( ) {
return newError ( "target not specified" ) . AtError ( )
return newError ( "target not specified" ) . AtError ( )
}
}
outbound . Name = "vless"
ob . Name = "vless"
inbound := session . InboundFromContext ( ctx )
var rec * protocol . ServerSpec
var rec * protocol . ServerSpec
var conn stat . Connection
var conn stat . Connection
@ -96,7 +96,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
if statConn , ok := iConn . ( * stat . CounterConnection ) ; ok {
if statConn , ok := iConn . ( * stat . CounterConnection ) ; ok {
iConn = statConn . Connection
iConn = statConn . Connection
}
}
target := o ut bound . Target
target := o b. Target
newError ( "tunneling request to " , target , " via " , rec . Destination ( ) . NetAddr ( ) ) . AtInfo ( ) . WriteToLog ( session . ExportIDToError ( ctx ) )
newError ( "tunneling request to " , target , " via " , rec . Destination ( ) . NetAddr ( ) ) . AtInfo ( ) . WriteToLog ( session . ExportIDToError ( ctx ) )
command := protocol . RequestCommandTCP
command := protocol . RequestCommandTCP
@ -130,9 +130,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
requestAddons . Flow = requestAddons . Flow [ : 16 ]
requestAddons . Flow = requestAddons . Flow [ : 16 ]
fallthrough
fallthrough
case vless . XRV :
case vless . XRV :
if inbound != nil {
ob . CanSpliceCopy = 2
inbound . SetCanSpliceCopy ( 2 )
}
switch request . Command {
switch request . Command {
case protocol . RequestCommandUDP :
case protocol . RequestCommandUDP :
if ! allowUDP443 && request . Port == 443 {
if ! allowUDP443 && request . Port == 443 {
@ -161,9 +159,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
rawInput = ( * bytes . Buffer ) ( unsafe . Pointer ( p + r . Offset ) )
rawInput = ( * bytes . Buffer ) ( unsafe . Pointer ( p + r . Offset ) )
}
}
default :
default :
if inbound != nil {
ob . CanSpliceCopy = 3
inbound . SetCanSpliceCopy ( 3 )
}
}
}
var newCtx context . Context
var newCtx context . Context
@ -238,8 +234,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
return newError ( ` failed to use ` + requestAddons . Flow + ` , found outer tls version ` , utlsConn . ConnectionState ( ) . Version ) . AtWarning ( )
return newError ( ` failed to use ` + requestAddons . Flow + ` , found outer tls version ` , utlsConn . ConnectionState ( ) . Version ) . AtWarning ( )
}
}
}
}
ctx1 := session . ContextWith Out bound( ctx , nil ) // TODO enable splice
ctx1 := session . ContextWith In bound( ctx , nil ) // TODO enable splice
err = encoding . XtlsWrite ( clientReader , serverWriter , timer , conn , trafficState , ctx1)
err = encoding . XtlsWrite ( clientReader , serverWriter , timer , conn , trafficState , ob, ctx1)
} else {
} else {
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
err = buf . Copy ( clientReader , serverWriter , buf . UpdateActivity ( timer ) )
err = buf . Copy ( clientReader , serverWriter , buf . UpdateActivity ( timer ) )
@ -277,7 +273,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
}
}
if requestAddons . Flow == vless . XRV {
if requestAddons . Flow == vless . XRV {
err = encoding . XtlsRead ( serverReader , clientWriter , timer , conn , input , rawInput , trafficState , ctx)
err = encoding . XtlsRead ( serverReader , clientWriter , timer , conn , input , rawInput , trafficState , ob, ctx)
} else {
} else {
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
err = buf . Copy ( serverReader , clientWriter , buf . UpdateActivity ( timer ) )
err = buf . Copy ( serverReader , clientWriter , buf . UpdateActivity ( timer ) )