1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-16 18:24:36 -04:00
v2fly/proxy/vmess/inbound/command.go

39 lines
1.1 KiB
Go
Raw Normal View History

2016-01-19 17:41:40 -05:00
package inbound
import (
2016-08-20 14:55:45 -04:00
"v2ray.com/core/common/log"
"v2ray.com/core/common/protocol"
"v2ray.com/core/proxy/vmess"
2016-01-19 17:41:40 -05:00
)
2016-02-27 11:28:21 -05:00
func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
2016-06-01 16:45:12 -04:00
if this.detours != nil {
2016-09-24 17:11:58 -04:00
tag := this.detours.To
2016-01-31 11:01:28 -05:00
if this.inboundHandlerManager != nil {
handler, availableMin := this.inboundHandlerManager.GetHandler(tag)
2016-01-19 17:41:40 -05:00
inboundHandler, ok := handler.(*VMessInboundHandler)
if ok {
if availableMin > 255 {
availableMin = 255
2016-01-19 17:41:40 -05:00
}
2016-02-27 11:28:21 -05:00
2016-01-22 10:48:17 -05:00
log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
2016-02-25 08:38:41 -05:00
user := inboundHandler.GetUser(request.User.Email)
if user == nil {
return nil
}
2016-10-16 08:22:21 -04:00
account, _ := user.GetTypedAccount()
2016-02-27 11:28:21 -05:00
return &protocol.CommandSwitchAccount{
2016-01-19 17:41:40 -05:00
Port: inboundHandler.Port(),
2016-10-12 12:43:55 -04:00
ID: account.(*vmess.InternalAccount).ID.UUID(),
AlterIds: uint16(len(account.(*vmess.InternalAccount).AlterIDs)),
Level: user.Level,
ValidMin: byte(availableMin),
2016-01-19 17:41:40 -05:00
}
}
}
}
2016-02-27 11:28:21 -05:00
return nil
2016-01-19 17:41:40 -05:00
}