Files
v2fly/proxy/vmess/outbound/command.go
T

30 lines
870 B
Go
Raw Normal View History

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