diff --git a/common/protocol/encoding.go b/common/protocol/encoding.go deleted file mode 100644 index b3f4da62d..000000000 --- a/common/protocol/encoding.go +++ /dev/null @@ -1,25 +0,0 @@ -package protocol - -import ( - "io" -) - -type RequestEncoder interface { - EncodeRequestHeader(*RequestHeader, io.Writer) - EncodeRequestBody(io.Writer) io.Writer -} - -type RequestDecoder interface { - DecodeRequestHeader(io.Reader) (*RequestHeader, error) - DecodeRequestBody(io.Reader) io.Reader -} - -type ResponseEncoder interface { - EncodeResponseHeader(*ResponseHeader, io.Writer) - EncodeResponseBody(io.Writer) io.Writer -} - -type ResponseDecoder interface { - DecodeResponseHeader(io.Reader) (*ResponseHeader, error) - DecodeResponseBody(io.Reader) io.Reader -} diff --git a/common/protocol/raw/auth.go b/proxy/vmess/encoding/auth.go similarity index 88% rename from common/protocol/raw/auth.go rename to proxy/vmess/encoding/auth.go index 1e3725fd3..885c72529 100644 --- a/common/protocol/raw/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -1,4 +1,4 @@ -package raw +package encoding import ( "hash/fnv" diff --git a/common/protocol/raw/client.go b/proxy/vmess/encoding/client.go similarity index 99% rename from common/protocol/raw/client.go rename to proxy/vmess/encoding/client.go index 8f89d3f34..c04325858 100644 --- a/common/protocol/raw/client.go +++ b/proxy/vmess/encoding/client.go @@ -1,4 +1,4 @@ -package raw +package encoding import ( "crypto/md5" diff --git a/common/protocol/raw/commands.go b/proxy/vmess/encoding/commands.go similarity index 99% rename from common/protocol/raw/commands.go rename to proxy/vmess/encoding/commands.go index 1e6322998..af45ed427 100644 --- a/common/protocol/raw/commands.go +++ b/proxy/vmess/encoding/commands.go @@ -1,4 +1,4 @@ -package raw +package encoding import ( "errors" diff --git a/common/protocol/raw/commands_test.go b/proxy/vmess/encoding/commands_test.go similarity index 92% rename from common/protocol/raw/commands_test.go rename to proxy/vmess/encoding/commands_test.go index ab334e2db..93615c8d4 100644 --- a/common/protocol/raw/commands_test.go +++ b/proxy/vmess/encoding/commands_test.go @@ -1,12 +1,12 @@ -package raw_test +package encoding_test import ( "testing" "github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/protocol" - . "github.com/v2ray/v2ray-core/common/protocol/raw" "github.com/v2ray/v2ray-core/common/uuid" + . "github.com/v2ray/v2ray-core/proxy/vmess/encoding" "github.com/v2ray/v2ray-core/testing/assert" ) diff --git a/common/protocol/raw/const.go b/proxy/vmess/encoding/const.go similarity index 87% rename from common/protocol/raw/const.go rename to proxy/vmess/encoding/const.go index 6731f5c3c..3f2a15031 100644 --- a/common/protocol/raw/const.go +++ b/proxy/vmess/encoding/const.go @@ -1,4 +1,4 @@ -package raw +package encoding const ( Version = byte(1) diff --git a/common/protocol/raw/encoding_test.go b/proxy/vmess/encoding/encoding_test.go similarity index 95% rename from common/protocol/raw/encoding_test.go rename to proxy/vmess/encoding/encoding_test.go index 19c7e3e5c..9cc0b225f 100644 --- a/common/protocol/raw/encoding_test.go +++ b/proxy/vmess/encoding/encoding_test.go @@ -1,4 +1,4 @@ -package raw_test +package encoding_test import ( "testing" @@ -6,8 +6,8 @@ import ( "github.com/v2ray/v2ray-core/common/alloc" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/protocol" - . "github.com/v2ray/v2ray-core/common/protocol/raw" "github.com/v2ray/v2ray-core/common/uuid" + . "github.com/v2ray/v2ray-core/proxy/vmess/encoding" "github.com/v2ray/v2ray-core/testing/assert" ) diff --git a/common/protocol/raw/server.go b/proxy/vmess/encoding/server.go similarity index 99% rename from common/protocol/raw/server.go rename to proxy/vmess/encoding/server.go index 247990406..f63de500b 100644 --- a/common/protocol/raw/server.go +++ b/proxy/vmess/encoding/server.go @@ -1,4 +1,4 @@ -package raw +package encoding import ( "crypto/md5" diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index b71090c5f..1479b0fd7 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -12,10 +12,10 @@ import ( "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/protocol" - "github.com/v2ray/v2ray-core/common/protocol/raw" "github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" + "github.com/v2ray/v2ray-core/proxy/vmess/encoding" vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io" "github.com/v2ray/v2ray-core/transport/internet" ) @@ -142,7 +142,7 @@ func (this *VMessInboundHandler) HandleConnection(connection internet.Connection this.RUnlock() return } - session := raw.NewServerSession(this.clients) + session := encoding.NewServerSession(this.clients) defer session.Release() request, err := session.DecodeRequestHeader(reader) diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index b6b7cdc35..55e9aa807 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -10,10 +10,10 @@ import ( "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/protocol" - "github.com/v2ray/v2ray-core/common/protocol/raw" "github.com/v2ray/v2ray-core/common/retry" "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" + "github.com/v2ray/v2ray-core/proxy/vmess/encoding" vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io" "github.com/v2ray/v2ray-core/transport/internet" "github.com/v2ray/v2ray-core/transport/ray" @@ -52,7 +52,7 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al command = protocol.RequestCommandUDP } request := &protocol.RequestHeader{ - Version: raw.Version, + Version: encoding.Version, User: rec.PickUser(), Command: command, Address: target.Address(), @@ -74,7 +74,7 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al requestFinish.Lock() responseFinish.Lock() - session := raw.NewClientSession(protocol.DefaultIDHash) + session := encoding.NewClientSession(protocol.DefaultIDHash) go this.handleRequest(session, conn, request, payload, input, &requestFinish) go this.handleResponse(session, conn, request, rec.Destination, output, &responseFinish) @@ -84,7 +84,7 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al return nil } -func (this *VMessOutboundHandler) handleRequest(session *raw.ClientSession, conn internet.Connection, request *protocol.RequestHeader, payload *alloc.Buffer, input v2io.Reader, finish *sync.Mutex) { +func (this *VMessOutboundHandler) handleRequest(session *encoding.ClientSession, conn internet.Connection, request *protocol.RequestHeader, payload *alloc.Buffer, input v2io.Reader, finish *sync.Mutex) { defer finish.Unlock() writer := v2io.NewBufferedWriter(conn) @@ -116,7 +116,7 @@ func (this *VMessOutboundHandler) handleRequest(session *raw.ClientSession, conn return } -func (this *VMessOutboundHandler) handleResponse(session *raw.ClientSession, conn internet.Connection, request *protocol.RequestHeader, dest v2net.Destination, output v2io.Writer, finish *sync.Mutex) { +func (this *VMessOutboundHandler) handleResponse(session *encoding.ClientSession, conn internet.Connection, request *protocol.RequestHeader, dest v2net.Destination, output v2io.Writer, finish *sync.Mutex) { defer finish.Unlock() reader := v2io.NewBufferedReader(conn)