command.go 870 B

1234567891011121314151617181920212223242526272829
  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)
  9. account := &protocol.VMessAccount{
  10. ID: primary,
  11. AlterIDs: alters,
  12. }
  13. user := protocol.NewUser(account, cmd.Level, "")
  14. dest := v2net.TCPDestination(cmd.Host, cmd.Port)
  15. this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
  16. }
  17. func (this *VMessOutboundHandler) handleCommand(dest v2net.Destination, cmd protocol.ResponseCommand) {
  18. switch typedCommand := cmd.(type) {
  19. case *protocol.CommandSwitchAccount:
  20. if typedCommand.Host == nil {
  21. typedCommand.Host = dest.Address()
  22. }
  23. this.handleSwitchAccount(typedCommand)
  24. default:
  25. }
  26. }