2015-12-04 06:42:56 -05:00
|
|
|
package outbound
|
|
|
|
|
2016-01-20 11:31:43 -05:00
|
|
|
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-03 05:58:42 -05:00
|
|
|
proto "github.com/v2ray/v2ray-core/common/protocol"
|
2016-01-20 11:31:43 -05:00
|
|
|
)
|
|
|
|
|
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(), "")
|
2016-01-20 11:31:43 -05:00
|
|
|
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) {
|
2016-01-20 11:31:43 -05:00
|
|
|
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()
|
|
|
|
}
|
2016-01-20 11:31:43 -05:00
|
|
|
this.handleSwitchAccount(typedCommand)
|
|
|
|
default:
|
|
|
|
}
|
2015-12-04 06:42:56 -05:00
|
|
|
}
|