command.go 737 B

1234567891011121314151617181920212223
  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. user := protocol.NewUser(protocol.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value(), "")
  8. dest := v2net.TCPDestination(cmd.Host, cmd.Port)
  9. this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
  10. }
  11. func (this *VMessOutboundHandler) handleCommand(dest v2net.Destination, cmd protocol.ResponseCommand) {
  12. switch typedCommand := cmd.(type) {
  13. case *protocol.CommandSwitchAccount:
  14. if typedCommand.Host == nil {
  15. typedCommand.Host = dest.Address()
  16. }
  17. this.handleSwitchAccount(typedCommand)
  18. default:
  19. }
  20. }