command.go 1004 B

123456789101112131415161718192021222324252627282930313233
  1. package inbound
  2. import (
  3. "github.com/v2ray/v2ray-core/common/log"
  4. "github.com/v2ray/v2ray-core/common/protocol"
  5. )
  6. func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
  7. if this.detours != nil {
  8. tag := this.detours.ToTag
  9. if this.inboundHandlerManager != nil {
  10. handler, availableMin := this.inboundHandlerManager.GetHandler(tag)
  11. inboundHandler, ok := handler.(*VMessInboundHandler)
  12. if ok {
  13. if availableMin > 255 {
  14. availableMin = 255
  15. }
  16. log.Info("VMessIn: Pick detour handler for port ", inboundHandler.Port(), " for ", availableMin, " minutes.")
  17. user := inboundHandler.GetUser(request.User.Email)
  18. return &protocol.CommandSwitchAccount{
  19. Port: inboundHandler.Port(),
  20. ID: user.Account.(*protocol.VMessAccount).ID.UUID(),
  21. AlterIds: uint16(len(user.Account.(*protocol.VMessAccount).AlterIDs)),
  22. Level: user.Level,
  23. ValidMin: byte(availableMin),
  24. }
  25. }
  26. }
  27. }
  28. return nil
  29. }