mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Add XTLS Splice to Trojan Outbound
This commit is contained in:
parent
ee19bcc08c
commit
b4e84603a2
3 changed files with 48 additions and 9 deletions
|
@ -94,15 +94,16 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|||
}
|
||||
|
||||
var rawConn syscall.RawConn
|
||||
var sctx context.Context
|
||||
|
||||
connWriter := &ConnWriter{}
|
||||
allowUDP443 := false
|
||||
switch account.Flow {
|
||||
case XRO + "-udp443", XRD + "-udp443":
|
||||
case XRO + "-udp443", XRD + "-udp443", XRS + "-udp443":
|
||||
allowUDP443 = true
|
||||
account.Flow = account.Flow[:16]
|
||||
fallthrough
|
||||
case XRO, XRD:
|
||||
case XRO, XRD, XRS:
|
||||
if destination.Address.Family().IsDomain() && destination.Address.Domain() == muxCoolAddress {
|
||||
return newError(account.Flow + " doesn't support Mux").AtWarning()
|
||||
}
|
||||
|
@ -114,13 +115,18 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|||
if xtlsConn, ok := iConn.(*xtls.Conn); ok {
|
||||
xtlsConn.RPRX = true
|
||||
xtlsConn.SHOW = trojanXTLSShow
|
||||
connWriter.Flow = account.Flow
|
||||
xtlsConn.MARK = "XTLS"
|
||||
if account.Flow == XRS {
|
||||
sctx = ctx
|
||||
account.Flow = XRD
|
||||
}
|
||||
if account.Flow == XRD {
|
||||
xtlsConn.DirectMode = true
|
||||
if sc, ok := xtlsConn.Connection.(syscall.Conn); ok {
|
||||
rawConn, _ = sc.SyscallConn()
|
||||
}
|
||||
}
|
||||
if sc, ok := xtlsConn.Connection.(syscall.Conn); ok {
|
||||
rawConn, _ = sc.SyscallConn()
|
||||
}
|
||||
connWriter.Flow = account.Flow
|
||||
} else {
|
||||
return newError(`failed to use ` + account.Flow + `, maybe "security" is not "xtls"`).AtWarning()
|
||||
}
|
||||
|
@ -185,7 +191,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|||
if statConn != nil {
|
||||
counter = statConn.ReadCounter
|
||||
}
|
||||
return ReadV(reader, link.Writer, timer, iConn.(*xtls.Conn), rawConn, counter)
|
||||
return ReadV(reader, link.Writer, timer, iConn.(*xtls.Conn), rawConn, counter, sctx)
|
||||
}
|
||||
return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue