1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-29 23:36:25 -04:00
v2fly/proxy/vmess/outbound/command.go

26 lines
806 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"
)
2016-02-27 10:41:21 -05:00
func (this *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
2016-05-07 15:07:46 -04:00
primary := protocol.NewID(cmd.ID)
alters := protocol.NewAlterIDs(primary, cmd.AlterIds.Value())
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 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:
}
}