1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00
v2fly/proxy/vmess/inbound/command.go

36 lines
1.0 KiB
Go
Raw Normal View History

2016-01-19 23:41:40 +01:00
package inbound
import (
2016-01-22 16:48:17 +01:00
"github.com/v2ray/v2ray-core/common/log"
2016-02-27 17:28:21 +01:00
"github.com/v2ray/v2ray-core/common/protocol"
2016-01-19 23:41:40 +01:00
"github.com/v2ray/v2ray-core/common/serial"
)
2016-02-27 17:28:21 +01:00
func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
2016-01-19 23:41:40 +01:00
if this.features != nil && this.features.Detour != nil {
2016-01-25 00:43:55 +01:00
2016-01-19 23:41:40 +01:00
tag := this.features.Detour.ToTag
2016-01-31 17:01:28 +01:00
if this.inboundHandlerManager != nil {
handler, availableMin := this.inboundHandlerManager.GetHandler(tag)
2016-01-19 23:41:40 +01:00
inboundHandler, ok := handler.(*VMessInboundHandler)
if ok {
if availableMin > 255 {
availableMin = 255
2016-01-19 23:41:40 +01:00
}
2016-02-27 17:28:21 +01:00
2016-01-22 16:48:17 +01:00
log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
2016-02-25 14:38:41 +01:00
user := inboundHandler.GetUser(request.User.Email)
2016-02-27 17:28:21 +01:00
return &protocol.CommandSwitchAccount{
2016-01-19 23:41:40 +01:00
Port: inboundHandler.Port(),
ID: user.ID.UUID(),
AlterIds: serial.Uint16Literal(len(user.AlterIDs)),
Level: user.Level,
ValidMin: byte(availableMin),
2016-01-19 23:41:40 +01:00
}
}
}
}
2016-02-27 17:28:21 +01:00
return nil
2016-01-19 23:41:40 +01:00
}