示例#1
0
func TestReceiverUser(t *testing.T) {
	v2testing.Current(t)

	id := vmess.NewID(uuid.New())
	user := vmess.NewUser(id, vmess.UserLevel(0), 100)
	rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user)
	assert.Bool(rec.HasUser(user)).IsTrue()
	assert.Int(len(rec.Accounts)).Equals(1)

	id2 := vmess.NewID(uuid.New())
	user2 := vmess.NewUser(id2, vmess.UserLevel(0), 100)
	assert.Bool(rec.HasUser(user2)).IsFalse()

	rec.AddUser(user2)
	assert.Bool(rec.HasUser(user2)).IsTrue()
	assert.Int(len(rec.Accounts)).Equals(2)
}
示例#2
0
func (this *VMessOutboundHandler) handleSwitchAccount(cmd *command.SwitchAccount) {
	user := vmess.NewUser(vmess.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value())
	dest := v2net.TCPDestination(cmd.Host, cmd.Port)
	this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
}