| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package inbound
- import (
- "v2ray.com/core/common/log"
- "v2ray.com/core/common/protocol"
- "v2ray.com/core/proxy/vmess"
- )
- func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
- if this.detours != nil {
- tag := this.detours.To
- if this.inboundHandlerManager != nil {
- handler, availableMin := this.inboundHandlerManager.GetHandler(tag)
- inboundHandler, ok := handler.(*VMessInboundHandler)
- if ok {
- if availableMin > 255 {
- availableMin = 255
- }
- log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
- user := inboundHandler.GetUser(request.User.Email)
- if user == nil {
- return nil
- }
- account, _ := user.GetTypedAccount()
- return &protocol.CommandSwitchAccount{
- Port: inboundHandler.Port(),
- ID: account.(*vmess.InternalAccount).ID.UUID(),
- AlterIds: uint16(len(account.(*vmess.InternalAccount).AlterIDs)),
- Level: user.Level,
- ValidMin: byte(availableMin),
- }
- }
- }
- }
- return nil
- }
|