move fundamental interfaces from vmess to common

pull/82/head
v2ray 2016-02-03 11:58:42 +01:00
parent e8b0505c01
commit 2147ba5ab3
19 changed files with 67 additions and 63 deletions

View File

@ -1,4 +1,4 @@
package vmess package protocol
import ( import (
"crypto/md5" "crypto/md5"

View File

@ -1,11 +1,11 @@
package vmess_test package protocol_test
import ( import (
"testing" "testing"
. "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
. "github.com/v2ray/v2ray-core/proxy/vmess"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )

View File

@ -1,4 +1,4 @@
package vmess package protocol
import ( import (
"github.com/v2ray/v2ray-core/common/dice" "github.com/v2ray/v2ray-core/common/dice"

View File

@ -1,6 +1,6 @@
// +build json // +build json
package vmess package protocol
import ( import (
"encoding/json" "encoding/json"

View File

@ -154,7 +154,9 @@ func (this *Shadowsocks) handleConnection(conn *hub.TCPConn) {
buffer := alloc.NewSmallBuffer() buffer := alloc.NewSmallBuffer()
defer buffer.Release() defer buffer.Release()
_, err := io.ReadFull(conn, buffer.Value[:this.config.Cipher.IVSize()]) timedReader := v2net.NewTimeOutReader(16, conn)
_, err := io.ReadFull(timedReader, buffer.Value[:this.config.Cipher.IVSize()])
if err != nil { if err != nil {
log.Access(conn.RemoteAddr(), serial.StringLiteral(""), log.AccessRejected, serial.StringLiteral(err.Error())) log.Access(conn.RemoteAddr(), serial.StringLiteral(""), log.AccessRejected, serial.StringLiteral(err.Error()))
log.Error("Shadowsocks: Failed to read IV: ", err) log.Error("Shadowsocks: Failed to read IV: ", err)
@ -164,7 +166,7 @@ func (this *Shadowsocks) handleConnection(conn *hub.TCPConn) {
iv := buffer.Value[:this.config.Cipher.IVSize()] iv := buffer.Value[:this.config.Cipher.IVSize()]
key := this.config.Key key := this.config.Key
reader, err := this.config.Cipher.NewDecodingStream(key, iv, conn) reader, err := this.config.Cipher.NewDecodingStream(key, iv, timedReader)
if err != nil { if err != nil {
log.Error("Shadowsocks: Failed to create decoding stream: ", err) log.Error("Shadowsocks: Failed to create decoding stream: ", err)
return return
@ -177,6 +179,8 @@ func (this *Shadowsocks) handleConnection(conn *hub.TCPConn) {
return return
} }
timedReader.SetTimeOut(300)
dest := v2net.TCPDestination(request.Address, request.Port) dest := v2net.TCPDestination(request.Address, request.Port)
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, serial.StringLiteral("")) log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, serial.StringLiteral(""))
log.Info("Shadowsocks: Tunnelling request to ", dest) log.Info("Shadowsocks: Tunnelling request to ", dest)

View File

@ -4,9 +4,9 @@ import (
"io" "io"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
"github.com/v2ray/v2ray-core/proxy/vmess"
"github.com/v2ray/v2ray-core/transport" "github.com/v2ray/v2ray-core/transport"
) )
@ -27,7 +27,7 @@ type SwitchAccount struct {
Port v2net.Port Port v2net.Port
ID *uuid.UUID ID *uuid.UUID
AlterIds serial.Uint16Literal AlterIds serial.Uint16Literal
Level vmess.UserLevel Level proto.UserLevel
ValidMin byte ValidMin byte
} }
@ -83,7 +83,7 @@ func (this *SwitchAccount) Unmarshal(data []byte) error {
if len(data) < levelStart+1 { if len(data) < levelStart+1 {
return transport.ErrorCorruptedPacket return transport.ErrorCorruptedPacket
} }
this.Level = vmess.UserLevel(data[levelStart]) this.Level = proto.UserLevel(data[levelStart])
timeStart := levelStart + 1 timeStart := levelStart + 1
if len(data) < timeStart { if len(data) < timeStart {
return transport.ErrorCorruptedPacket return transport.ErrorCorruptedPacket

View File

@ -1,7 +1,7 @@
package inbound package inbound
import ( import (
"github.com/v2ray/v2ray-core/proxy/vmess" proto "github.com/v2ray/v2ray-core/common/protocol"
) )
type DetourConfig struct { type DetourConfig struct {
@ -13,6 +13,6 @@ type FeaturesConfig struct {
} }
type Config struct { type Config struct {
AllowedUsers []*vmess.User AllowedUsers []*proto.User
Features *FeaturesConfig Features *FeaturesConfig
} }

View File

@ -5,8 +5,8 @@ package inbound
import ( import (
"encoding/json" "encoding/json"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/proxy/internal/config" "github.com/v2ray/v2ray-core/proxy/internal/config"
"github.com/v2ray/v2ray-core/proxy/vmess"
) )
func (this *DetourConfig) UnmarshalJSON(data []byte) error { func (this *DetourConfig) UnmarshalJSON(data []byte) error {
@ -35,7 +35,7 @@ func (this *FeaturesConfig) UnmarshalJSON(data []byte) error {
func (this *Config) UnmarshalJSON(data []byte) error { func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct { type JsonConfig struct {
Users []*vmess.User `json:"clients"` Users []*proto.User `json:"clients"`
Features *FeaturesConfig `json:"features"` Features *FeaturesConfig `json:"features"`
} }
jsonConfig := new(JsonConfig) jsonConfig := new(JsonConfig)

View File

@ -13,10 +13,10 @@ import (
v2io "github.com/v2ray/v2ray-core/common/io" v2io "github.com/v2ray/v2ray-core/common/io"
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy"
"github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/internal"
"github.com/v2ray/v2ray-core/proxy/vmess"
vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io" vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io"
"github.com/v2ray/v2ray-core/proxy/vmess/protocol" "github.com/v2ray/v2ray-core/proxy/vmess/protocol"
"github.com/v2ray/v2ray-core/transport/hub" "github.com/v2ray/v2ray-core/transport/hub"
@ -28,7 +28,7 @@ type VMessInboundHandler struct {
packetDispatcher dispatcher.PacketDispatcher packetDispatcher dispatcher.PacketDispatcher
inboundHandlerManager proxyman.InboundHandlerManager inboundHandlerManager proxyman.InboundHandlerManager
clients protocol.UserSet clients protocol.UserSet
user *vmess.User user *proto.User
accepting bool accepting bool
listener *hub.TCPHub listener *hub.TCPHub
features *FeaturesConfig features *FeaturesConfig
@ -49,7 +49,7 @@ func (this *VMessInboundHandler) Close() {
} }
} }
func (this *VMessInboundHandler) GetUser() *vmess.User { func (this *VMessInboundHandler) GetUser() *proto.User {
return this.user return this.user
} }
@ -97,7 +97,7 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.TCPConn) {
readFinish.Lock() readFinish.Lock()
writeFinish.Lock() writeFinish.Lock()
userSettings := vmess.GetUserSettings(request.User.Level) userSettings := proto.GetUserSettings(request.User.Level)
connReader.SetTimeOut(userSettings.PayloadReadTimeout) connReader.SetTimeOut(userSettings.PayloadReadTimeout)
go handleInput(request, connReader, input, &readFinish) go handleInput(request, connReader, input, &readFinish)

View File

@ -5,13 +5,13 @@ import (
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/proxy/vmess"
"github.com/v2ray/v2ray-core/proxy/vmess/command" "github.com/v2ray/v2ray-core/proxy/vmess/command"
) )
func (this *VMessOutboundHandler) handleSwitchAccount(cmd *command.SwitchAccount) { func (this *VMessOutboundHandler) handleSwitchAccount(cmd *command.SwitchAccount) {
user := vmess.NewUser(vmess.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value()) user := proto.NewUser(proto.NewID(cmd.ID), cmd.Level, cmd.AlterIds.Value())
dest := v2net.TCPDestination(cmd.Host, cmd.Port) dest := v2net.TCPDestination(cmd.Host, cmd.Port)
this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin) this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)
} }

View File

@ -6,23 +6,23 @@ import (
"github.com/v2ray/v2ray-core/common/dice" "github.com/v2ray/v2ray-core/common/dice"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/proxy/vmess" proto "github.com/v2ray/v2ray-core/common/protocol"
) )
type Receiver struct { type Receiver struct {
sync.RWMutex sync.RWMutex
Destination v2net.Destination Destination v2net.Destination
Accounts []*vmess.User Accounts []*proto.User
} }
func NewReceiver(dest v2net.Destination, users ...*vmess.User) *Receiver { func NewReceiver(dest v2net.Destination, users ...*proto.User) *Receiver {
return &Receiver{ return &Receiver{
Destination: dest, Destination: dest,
Accounts: users, Accounts: users,
} }
} }
func (this *Receiver) HasUser(user *vmess.User) bool { func (this *Receiver) HasUser(user *proto.User) bool {
this.RLock() this.RLock()
defer this.RUnlock() defer this.RUnlock()
for _, u := range this.Accounts { for _, u := range this.Accounts {
@ -34,7 +34,7 @@ func (this *Receiver) HasUser(user *vmess.User) bool {
return false return false
} }
func (this *Receiver) AddUser(user *vmess.User) { func (this *Receiver) AddUser(user *proto.User) {
if this.HasUser(user) { if this.HasUser(user) {
return return
} }
@ -43,7 +43,7 @@ func (this *Receiver) AddUser(user *vmess.User) {
this.Unlock() this.Unlock()
} }
func (this *Receiver) PickUser() *vmess.User { func (this *Receiver) PickUser() *proto.User {
return this.Accounts[dice.Roll(len(this.Accounts))] return this.Accounts[dice.Roll(len(this.Accounts))]
} }
@ -125,7 +125,7 @@ func (this *ReceiverManager) pickStdReceiver() *Receiver {
return this.receivers[dice.Roll(len(this.receivers))] return this.receivers[dice.Roll(len(this.receivers))]
} }
func (this *ReceiverManager) PickReceiver() (v2net.Destination, *vmess.User) { func (this *ReceiverManager) PickReceiver() (v2net.Destination, *proto.User) {
rec := this.pickDetour() rec := this.pickDetour()
if rec == nil { if rec == nil {
rec = this.pickStdReceiver() rec = this.pickStdReceiver()

View File

@ -7,15 +7,15 @@ import (
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/internal"
"github.com/v2ray/v2ray-core/proxy/vmess"
) )
func (this *Receiver) UnmarshalJSON(data []byte) error { func (this *Receiver) UnmarshalJSON(data []byte) error {
type RawConfigTarget struct { type RawConfigTarget struct {
Address *v2net.AddressJson `json:"address"` Address *v2net.AddressJson `json:"address"`
Port v2net.Port `json:"port"` Port v2net.Port `json:"port"`
Users []*vmess.User `json:"users"` Users []*proto.User `json:"users"`
} }
var rawConfig RawConfigTarget var rawConfig RawConfigTarget
if err := json.Unmarshal(data, &rawConfig); err != nil { if err := json.Unmarshal(data, &rawConfig); err != nil {

View File

@ -4,8 +4,8 @@ import (
"testing" "testing"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
"github.com/v2ray/v2ray-core/proxy/vmess"
. "github.com/v2ray/v2ray-core/proxy/vmess/outbound" . "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
@ -14,14 +14,14 @@ import (
func TestReceiverUser(t *testing.T) { func TestReceiverUser(t *testing.T) {
v2testing.Current(t) v2testing.Current(t)
id := vmess.NewID(uuid.New()) id := proto.NewID(uuid.New())
user := vmess.NewUser(id, vmess.UserLevel(0), 100) user := proto.NewUser(id, proto.UserLevel(0), 100)
rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user) rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user)
assert.Bool(rec.HasUser(user)).IsTrue() assert.Bool(rec.HasUser(user)).IsTrue()
assert.Int(len(rec.Accounts)).Equals(1) assert.Int(len(rec.Accounts)).Equals(1)
id2 := vmess.NewID(uuid.New()) id2 := proto.NewID(uuid.New())
user2 := vmess.NewUser(id2, vmess.UserLevel(0), 100) user2 := proto.NewUser(id2, proto.UserLevel(0), 100)
assert.Bool(rec.HasUser(user2)).IsFalse() assert.Bool(rec.HasUser(user2)).IsFalse()
rec.AddUser(user2) rec.AddUser(user2)

View File

@ -1,22 +1,22 @@
package mocks package mocks
import ( import (
"github.com/v2ray/v2ray-core/proxy/vmess" proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/proxy/vmess/protocol" "github.com/v2ray/v2ray-core/proxy/vmess/protocol"
) )
type MockUserSet struct { type MockUserSet struct {
Users []*vmess.User Users []*proto.User
UserHashes map[string]int UserHashes map[string]int
Timestamps map[string]protocol.Timestamp Timestamps map[string]protocol.Timestamp
} }
func (us *MockUserSet) AddUser(user *vmess.User) error { func (us *MockUserSet) AddUser(user *proto.User) error {
us.Users = append(us.Users, user) us.Users = append(us.Users, user)
return nil return nil
} }
func (us *MockUserSet) GetUser(userhash []byte) (*vmess.User, protocol.Timestamp, bool) { func (us *MockUserSet) GetUser(userhash []byte) (*proto.User, protocol.Timestamp, bool) {
idx, found := us.UserHashes[string(userhash)] idx, found := us.UserHashes[string(userhash)]
if found { if found {
return us.Users[idx], us.Timestamps[string(userhash)], true return us.Users[idx], us.Timestamps[string(userhash)], true

View File

@ -1,21 +1,21 @@
package mocks package mocks
import ( import (
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
"github.com/v2ray/v2ray-core/proxy/vmess"
"github.com/v2ray/v2ray-core/proxy/vmess/protocol" "github.com/v2ray/v2ray-core/proxy/vmess/protocol"
) )
type StaticUserSet struct { type StaticUserSet struct {
} }
func (us *StaticUserSet) AddUser(user *vmess.User) error { func (us *StaticUserSet) AddUser(user *proto.User) error {
return nil return nil
} }
func (us *StaticUserSet) GetUser(userhash []byte) (*vmess.User, protocol.Timestamp, bool) { func (us *StaticUserSet) GetUser(userhash []byte) (*proto.User, protocol.Timestamp, bool) {
id, _ := uuid.ParseString("703e9102-eb57-499c-8b59-faf4f371bb21") id, _ := uuid.ParseString("703e9102-eb57-499c-8b59-faf4f371bb21")
return &vmess.User{ return &proto.User{
ID: vmess.NewID(id), ID: proto.NewID(id),
}, 0, true }, 0, true
} }

View File

@ -4,8 +4,8 @@ import (
"sync" "sync"
"time" "time"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/proxy/vmess"
) )
const ( const (
@ -30,19 +30,19 @@ func (this Timestamp) HashBytes() []byte {
} }
type idEntry struct { type idEntry struct {
id *vmess.ID id *proto.ID
userIdx int userIdx int
lastSec Timestamp lastSec Timestamp
lastSecRemoval Timestamp lastSecRemoval Timestamp
} }
type UserSet interface { type UserSet interface {
AddUser(user *vmess.User) error AddUser(user *proto.User) error
GetUser(timeHash []byte) (*vmess.User, Timestamp, bool) GetUser(timeHash []byte) (*proto.User, Timestamp, bool)
} }
type TimedUserSet struct { type TimedUserSet struct {
validUsers []*vmess.User validUsers []*proto.User
userHash map[[16]byte]indexTimePair userHash map[[16]byte]indexTimePair
ids []*idEntry ids []*idEntry
access sync.RWMutex access sync.RWMutex
@ -55,7 +55,7 @@ type indexTimePair struct {
func NewTimedUserSet() UserSet { func NewTimedUserSet() UserSet {
tus := &TimedUserSet{ tus := &TimedUserSet{
validUsers: make([]*vmess.User, 0, 16), validUsers: make([]*proto.User, 0, 16),
userHash: make(map[[16]byte]indexTimePair, 512), userHash: make(map[[16]byte]indexTimePair, 512),
access: sync.RWMutex{}, access: sync.RWMutex{},
ids: make([]*idEntry, 0, 512), ids: make([]*idEntry, 0, 512),
@ -96,7 +96,7 @@ func (us *TimedUserSet) updateUserHash(tick <-chan time.Time) {
} }
} }
func (us *TimedUserSet) AddUser(user *vmess.User) error { func (us *TimedUserSet) AddUser(user *proto.User) error {
idx := len(us.validUsers) idx := len(us.validUsers)
us.validUsers = append(us.validUsers, user) us.validUsers = append(us.validUsers, user)
@ -124,7 +124,7 @@ func (us *TimedUserSet) AddUser(user *vmess.User) error {
return nil return nil
} }
func (us *TimedUserSet) GetUser(userHash []byte) (*vmess.User, Timestamp, bool) { func (us *TimedUserSet) GetUser(userHash []byte) (*proto.User, Timestamp, bool) {
defer us.access.RUnlock() defer us.access.RUnlock()
us.access.RLock() us.access.RLock()
var fixedSizeHash [16]byte var fixedSizeHash [16]byte

View File

@ -11,8 +11,8 @@ import (
v2crypto "github.com/v2ray/v2ray-core/common/crypto" v2crypto "github.com/v2ray/v2ray-core/common/crypto"
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy"
"github.com/v2ray/v2ray-core/proxy/vmess"
"github.com/v2ray/v2ray-core/transport" "github.com/v2ray/v2ray-core/transport"
) )
@ -36,7 +36,7 @@ const (
// streaming. // streaming.
type VMessRequest struct { type VMessRequest struct {
Version byte Version byte
User *vmess.User User *proto.User
RequestIV []byte RequestIV []byte
RequestKey []byte RequestKey []byte
ResponseHeader byte ResponseHeader byte
@ -76,7 +76,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
buffer := alloc.NewSmallBuffer() buffer := alloc.NewSmallBuffer()
defer buffer.Release() defer buffer.Release()
nBytes, err := io.ReadFull(reader, buffer.Value[:vmess.IDBytesLen]) nBytes, err := io.ReadFull(reader, buffer.Value[:proto.IDBytesLen])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read request ID (", nBytes, " bytes): ", err) log.Debug("VMess: Failed to read request ID (", nBytes, " bytes): ", err)
return nil, err return nil, err

View File

@ -8,8 +8,8 @@ import (
"time" "time"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
"github.com/v2ray/v2ray-core/proxy/vmess"
. "github.com/v2ray/v2ray-core/proxy/vmess/protocol" . "github.com/v2ray/v2ray-core/proxy/vmess/protocol"
protocoltesting "github.com/v2ray/v2ray-core/proxy/vmess/protocol/testing" protocoltesting "github.com/v2ray/v2ray-core/proxy/vmess/protocol/testing"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
@ -30,13 +30,13 @@ func TestVMessSerialization(t *testing.T) {
id, err := uuid.ParseString("2b2966ac-16aa-4fbf-8d81-c5f172a3da51") id, err := uuid.ParseString("2b2966ac-16aa-4fbf-8d81-c5f172a3da51")
assert.Error(err).IsNil() assert.Error(err).IsNil()
userId := vmess.NewID(id) userId := proto.NewID(id)
testUser := &vmess.User{ testUser := &proto.User{
ID: userId, ID: userId,
} }
userSet := protocoltesting.MockUserSet{[]*vmess.User{}, make(map[string]int), make(map[string]Timestamp)} userSet := protocoltesting.MockUserSet{[]*proto.User{}, make(map[string]int), make(map[string]Timestamp)}
userSet.AddUser(testUser) userSet.AddUser(testUser)
request := new(VMessRequest) request := new(VMessRequest)
@ -91,10 +91,10 @@ func BenchmarkVMessRequestWriting(b *testing.B) {
id, err := uuid.ParseString("2b2966ac-16aa-4fbf-8d81-c5f172a3da51") id, err := uuid.ParseString("2b2966ac-16aa-4fbf-8d81-c5f172a3da51")
assert.Error(err).IsNil() assert.Error(err).IsNil()
userId := vmess.NewID(id) userId := proto.NewID(id)
userSet := protocoltesting.MockUserSet{[]*vmess.User{}, make(map[string]int), make(map[string]Timestamp)} userSet := protocoltesting.MockUserSet{[]*proto.User{}, make(map[string]int), make(map[string]Timestamp)}
testUser := &vmess.User{ testUser := &proto.User{
ID: userId, ID: userId,
} }
userSet.AddUser(testUser) userSet.AddUser(testUser)

View File

@ -8,11 +8,11 @@ import (
"github.com/v2ray/v2ray-core/app/dispatcher" "github.com/v2ray/v2ray-core/app/dispatcher"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
proto "github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
"github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy"
proxytesting "github.com/v2ray/v2ray-core/proxy/testing" proxytesting "github.com/v2ray/v2ray-core/proxy/testing"
proxymocks "github.com/v2ray/v2ray-core/proxy/testing/mocks" proxymocks "github.com/v2ray/v2ray-core/proxy/testing/mocks"
vmess "github.com/v2ray/v2ray-core/proxy/vmess"
_ "github.com/v2ray/v2ray-core/proxy/vmess/inbound" _ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
_ "github.com/v2ray/v2ray-core/proxy/vmess/outbound" _ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
"github.com/v2ray/v2ray-core/shell/point" "github.com/v2ray/v2ray-core/shell/point"
@ -26,7 +26,7 @@ func TestVMessInAndOut(t *testing.T) {
id, err := uuid.ParseString("ad937d9d-6e23-4a5a-ba23-bce5092a7c51") id, err := uuid.ParseString("ad937d9d-6e23-4a5a-ba23-bce5092a7c51")
assert.Error(err).IsNil() assert.Error(err).IsNil()
testAccount := vmess.NewID(id) testAccount := proto.NewID(id)
portA := v2nettesting.PickPort() portA := v2nettesting.PickPort()
portB := v2nettesting.PickPort() portB := v2nettesting.PickPort()