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

34 lines
1004 B
Go
Raw Normal View History

2016-01-19 22:41:40 +00:00
package inbound
import (
2016-01-22 15:48:17 +00:00
"github.com/v2ray/v2ray-core/common/log"
2016-02-27 16:28:21 +00:00
"github.com/v2ray/v2ray-core/common/protocol"
2016-01-19 22:41:40 +00:00
)
2016-02-27 16:28:21 +00:00
func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
2016-06-01 20:45:12 +00:00
if this.detours != nil {
tag := this.detours.ToTag
2016-01-31 16:01:28 +00:00
if this.inboundHandlerManager != nil {
handler, availableMin := this.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)
2016-02-27 16:28:21 +00:00
return &protocol.CommandSwitchAccount{
2016-01-19 22:41:40 +00:00
Port: inboundHandler.Port(),
2016-05-28 11:44:11 +00:00
ID: user.Account.(*protocol.VMessAccount).ID.UUID(),
AlterIds: uint16(len(user.Account.(*protocol.VMessAccount).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
}