command.go 806 B

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