command.go 1.0 KB

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