move encoding to vmess

pull/219/head
v2ray 8 years ago
parent e304e2761d
commit 6f5b54747e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -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
}

@ -1,4 +1,4 @@
package raw
package encoding
import (
"hash/fnv"

@ -1,4 +1,4 @@
package raw
package encoding
import (
"crypto/md5"

@ -1,4 +1,4 @@
package raw
package encoding
import (
"errors"

@ -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"
)

@ -1,4 +1,4 @@
package raw
package encoding
const (
Version = byte(1)

@ -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"
)

@ -1,4 +1,4 @@
package raw
package encoding
import (
"crypto/md5"

@ -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)

@ -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)

Loading…
Cancel
Save