mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
clean imports
This commit is contained in:
@@ -3,14 +3,14 @@ package net_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/testing/assert"
|
||||
)
|
||||
|
||||
func TestTCPDestination(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
|
||||
dest := net.TCPDestination(net.IPAddress([]byte{1, 2, 3, 4}), 80)
|
||||
assert.Destination(dest).IsTCP()
|
||||
assert.Destination(dest).IsNotUDP()
|
||||
assert.Destination(dest).EqualsString("tcp:1.2.3.4:80")
|
||||
@@ -19,7 +19,7 @@ func TestTCPDestination(t *testing.T) {
|
||||
func TestUDPDestination(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
dest := v2net.UDPDestination(v2net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53)
|
||||
dest := net.UDPDestination(net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53)
|
||||
assert.Destination(dest).IsNotTCP()
|
||||
assert.Destination(dest).IsUDP()
|
||||
assert.Destination(dest).EqualsString("udp:[2001:4860:4860::8888]:53")
|
||||
|
||||
@@ -3,7 +3,7 @@ package protocol
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/uuid"
|
||||
)
|
||||
|
||||
@@ -58,16 +58,16 @@ type RequestHeader struct {
|
||||
Command RequestCommand
|
||||
Option RequestOption
|
||||
Security Security
|
||||
Port v2net.Port
|
||||
Address v2net.Address
|
||||
Port net.Port
|
||||
Address net.Address
|
||||
User *User
|
||||
}
|
||||
|
||||
func (v *RequestHeader) Destination() v2net.Destination {
|
||||
func (v *RequestHeader) Destination() net.Destination {
|
||||
if v.Command == RequestCommandUDP {
|
||||
return v2net.UDPDestination(v.Address, v.Port)
|
||||
return net.UDPDestination(v.Address, v.Port)
|
||||
}
|
||||
return v2net.TCPDestination(v.Address, v.Port)
|
||||
return net.TCPDestination(v.Address, v.Port)
|
||||
}
|
||||
|
||||
type ResponseOption byte
|
||||
@@ -96,8 +96,8 @@ type ResponseHeader struct {
|
||||
}
|
||||
|
||||
type CommandSwitchAccount struct {
|
||||
Host v2net.Address
|
||||
Port v2net.Port
|
||||
Host net.Address
|
||||
Port net.Port
|
||||
ID *uuid.UUID
|
||||
AlterIds uint16
|
||||
Level uint32
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common/dice"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
type ValidationStrategy interface {
|
||||
@@ -45,12 +45,12 @@ func (v *TimeoutValidStrategy) Invalidate() {
|
||||
|
||||
type ServerSpec struct {
|
||||
sync.RWMutex
|
||||
dest v2net.Destination
|
||||
dest net.Destination
|
||||
users []*User
|
||||
valid ValidationStrategy
|
||||
}
|
||||
|
||||
func NewServerSpec(dest v2net.Destination, valid ValidationStrategy, users ...*User) *ServerSpec {
|
||||
func NewServerSpec(dest net.Destination, valid ValidationStrategy, users ...*User) *ServerSpec {
|
||||
return &ServerSpec{
|
||||
dest: dest,
|
||||
users: users,
|
||||
@@ -59,11 +59,11 @@ func NewServerSpec(dest v2net.Destination, valid ValidationStrategy, users ...*U
|
||||
}
|
||||
|
||||
func NewServerSpecFromPB(spec ServerEndpoint) *ServerSpec {
|
||||
dest := v2net.TCPDestination(spec.Address.AsAddress(), v2net.Port(spec.Port))
|
||||
dest := net.TCPDestination(spec.Address.AsAddress(), net.Port(spec.Port))
|
||||
return NewServerSpec(dest, AlwaysValid(), spec.User...)
|
||||
}
|
||||
|
||||
func (v *ServerSpec) Destination() v2net.Destination {
|
||||
func (v *ServerSpec) Destination() net.Destination {
|
||||
return v.dest
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user