mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
package inbound
|
|
|
|
import (
|
|
"v2ray.com/core/common/log"
|
|
"v2ray.com/core/common/protocol"
|
|
"v2ray.com/core/proxy/vmess"
|
|
)
|
|
|
|
func (v *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
|
|
if v.detours != nil {
|
|
tag := v.detours.To
|
|
if v.inboundHandlerManager != nil {
|
|
handler, availableMin := v.inboundHandlerManager.GetHandler(tag)
|
|
inboundHandler, ok := handler.(*VMessInboundHandler)
|
|
if ok {
|
|
if availableMin > 255 {
|
|
availableMin = 255
|
|
}
|
|
|
|
log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
|
|
user := inboundHandler.GetUser(request.User.Email)
|
|
if user == nil {
|
|
return nil
|
|
}
|
|
account, _ := user.GetTypedAccount()
|
|
return &protocol.CommandSwitchAccount{
|
|
Port: inboundHandler.Port(),
|
|
ID: account.(*vmess.InternalAccount).ID.UUID(),
|
|
AlterIds: uint16(len(account.(*vmess.InternalAccount).AlterIDs)),
|
|
Level: user.Level,
|
|
ValidMin: byte(availableMin),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|