command.go 784 B

123456789101112131415161718192021222324
  1. package outbound
  2. import (
  3. v2net "github.com/v2ray/v2ray-core/common/net"
  4. "github.com/v2ray/v2ray-core/common/protocol"
  5. proto "github.com/v2ray/v2ray-core/common/protocol"
  6. )
  7. func (this *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
  8. user := proto.NewUser(proto.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value(), "")
  9. dest := v2net.TCPDestination(cmd.Host, cmd.Port)
  10. this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
  11. }
  12. func (this *VMessOutboundHandler) handleCommand(dest v2net.Destination, cmd protocol.ResponseCommand) {
  13. switch typedCommand := cmd.(type) {
  14. case *protocol.CommandSwitchAccount:
  15. if typedCommand.Host == nil {
  16. typedCommand.Host = dest.Address()
  17. }
  18. this.handleSwitchAccount(typedCommand)
  19. default:
  20. }
  21. }