1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 18:00:43 +00:00
v2fly/proxy/vmess/outbound/command.go

26 lines
798 B
Go
Raw Normal View History

package outbound
import (
v2net "github.com/v2ray/v2ray-core/common/net"
2016-02-27 15:41:21 +00:00
"github.com/v2ray/v2ray-core/common/protocol"
)
2016-02-27 15:41:21 +00:00
func (this *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
2016-05-07 19:07:46 +00:00
primary := protocol.NewID(cmd.ID)
2016-05-24 19:55:46 +00:00
alters := protocol.NewAlterIDs(primary, cmd.AlterIds)
2016-05-07 19:07:46 +00:00
user := protocol.NewUser(primary, alters, cmd.Level, "")
dest := v2net.TCPDestination(cmd.Host, cmd.Port)
this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
}
2016-02-27 15:41:21 +00:00
func (this *VMessOutboundHandler) handleCommand(dest v2net.Destination, cmd protocol.ResponseCommand) {
switch typedCommand := cmd.(type) {
2016-02-27 15:41:21 +00:00
case *protocol.CommandSwitchAccount:
2016-01-21 16:22:56 +00:00
if typedCommand.Host == nil {
typedCommand.Host = dest.Address()
}
this.handleSwitchAccount(typedCommand)
default:
}
}