mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Add trojan over xtls support (#334)
* Add trojan over xtls support * Add comments * improve PR quality * improve PR quality * add xtls-rprx-origin-udp443 and xtls-rprx-direct-udp443 Co-authored-by: Eken Chan <maskedeken@yahoo.com>
This commit is contained in:
@@ -185,6 +185,34 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet
|
||||
}
|
||||
|
||||
// handle tcp request
|
||||
account, ok := user.Account.(*MemoryAccount)
|
||||
if !ok {
|
||||
return newError("user account is not valid")
|
||||
}
|
||||
|
||||
switch clientReader.Flow {
|
||||
case XRO, XRD:
|
||||
if account.Flow == clientReader.Flow {
|
||||
if destination.Address.Family().IsDomain() && destination.Address.Domain() == muxCoolAddress {
|
||||
return newError("XTLS doesn't support Mux").AtWarning()
|
||||
}
|
||||
|
||||
if xtlsConn, ok := iConn.(*xtls.Conn); ok {
|
||||
xtlsConn.RPRX = true
|
||||
|
||||
if clientReader.Flow == XRD {
|
||||
xtlsConn.DirectMode = true
|
||||
}
|
||||
} else {
|
||||
return newError(`failed to enable XTLS, maybe "security" is not "xtls"`).AtWarning()
|
||||
}
|
||||
} else {
|
||||
return newError("unable to use ", clientReader.Flow).AtWarning()
|
||||
}
|
||||
case "":
|
||||
default:
|
||||
return newError("unsupported flow type: ", account.Flow).AtWarning()
|
||||
}
|
||||
|
||||
ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
|
||||
From: conn.RemoteAddr(),
|
||||
|
||||
Reference in New Issue
Block a user