v2ray-core/proxy/vmess/inbound/command.go

39 lines
1.0 KiB
Go
Raw Normal View History

2016-01-19 22:41:40 +00:00
package inbound
import (
2016-08-20 18:55:45 +00:00
"v2ray.com/core/common/log"
"v2ray.com/core/common/protocol"
"v2ray.com/core/proxy/vmess"
2016-01-19 22:41:40 +00:00
)
2016-11-27 20:39:09 +00:00
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)
2016-01-19 22:41:40 +00:00
inboundHandler, ok := handler.(*VMessInboundHandler)
if ok {
if availableMin > 255 {
availableMin = 255
2016-01-19 22:41:40 +00:00
}
2016-02-27 16:28:21 +00:00
2016-01-22 15:48:17 +00:00
log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
2016-02-25 13:38:41 +00:00
user := inboundHandler.GetUser(request.User.Email)
if user == nil {
return nil
}
2016-10-16 12:22:21 +00:00
account, _ := user.GetTypedAccount()
2016-02-27 16:28:21 +00:00
return &protocol.CommandSwitchAccount{
2016-01-19 22:41:40 +00:00
Port: inboundHandler.Port(),
2016-10-12 16:43:55 +00:00
ID: account.(*vmess.InternalAccount).ID.UUID(),
AlterIds: uint16(len(account.(*vmess.InternalAccount).AlterIDs)),
Level: user.Level,
ValidMin: byte(availableMin),
2016-01-19 22:41:40 +00:00
}
}
}
}
2016-02-27 16:28:21 +00:00
return nil
2016-01-19 22:41:40 +00:00
}