2016-01-19 17:41:40 -05:00
|
|
|
package inbound
|
|
|
|
|
|
|
|
import (
|
2016-01-22 10:48:17 -05:00
|
|
|
"github.com/v2ray/v2ray-core/common/log"
|
2016-02-27 11:28:21 -05:00
|
|
|
"github.com/v2ray/v2ray-core/common/protocol"
|
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-01-19 17:41:40 -05:00
|
|
|
if this.features != nil && this.features.Detour != nil {
|
2016-01-24 18:43:55 -05:00
|
|
|
|
2016-01-19 17:41:40 -05:00
|
|
|
tag := this.features.Detour.ToTag
|
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 {
|
2016-01-20 11:31:43 -05:00
|
|
|
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)
|
2016-02-27 11:28:21 -05:00
|
|
|
return &protocol.CommandSwitchAccount{
|
2016-01-19 17:41:40 -05:00
|
|
|
Port: inboundHandler.Port(),
|
|
|
|
ID: user.ID.UUID(),
|
2016-05-24 15:55:46 -04:00
|
|
|
AlterIds: uint16(len(user.AlterIDs)),
|
2016-01-20 11:31:43 -05:00
|
|
|
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
|
|
|
}
|