1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/proxy/vmess/outbound/command.go

25 lines
784 B
Go
Raw Normal View History

package outbound
import (
v2net "github.com/v2ray/v2ray-core/common/net"
2016-02-27 10:41:21 -05:00
"github.com/v2ray/v2ray-core/common/protocol"
proto "github.com/v2ray/v2ray-core/common/protocol"
)
2016-02-27 10:41:21 -05:00
func (this *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
2016-02-25 08:38:41 -05:00
user := proto.NewUser(proto.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value(), "")
dest := v2net.TCPDestination(cmd.Host, cmd.Port)
this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
}
2016-02-27 10:41:21 -05:00
func (this *VMessOutboundHandler) handleCommand(dest v2net.Destination, cmd protocol.ResponseCommand) {
switch typedCommand := cmd.(type) {
2016-02-27 10:41:21 -05:00
case *protocol.CommandSwitchAccount:
2016-01-21 11:22:56 -05:00
if typedCommand.Host == nil {
typedCommand.Host = dest.Address()
}
this.handleSwitchAccount(typedCommand)
default:
}
}