pull/432/head
Darien Raymond 2017-03-27 01:47:01 +02:00
parent 8b15b32126
commit eab2f1effc
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 29 additions and 5 deletions

View File

@ -31,8 +31,21 @@ const (
AddressTypeIPv6 AddressType = 0x03 AddressTypeIPv6 AddressType = 0x03
) )
/*
Frame format
2 bytes - length
2 bytes - session id
1 bytes - status
1 bytes - reserved
1 byte - network
2 bytes - port
n bytes - address
*/
type FrameMetadata struct { type FrameMetadata struct {
SessionId uint16 SessionID uint16
SessionStatus SessionStatus SessionStatus SessionStatus
Target net.Destination Target net.Destination
} }
@ -41,7 +54,7 @@ func (f FrameMetadata) AsSupplier() buf.Supplier {
return func(b []byte) (int, error) { return func(b []byte) (int, error) {
b = serial.Uint16ToBytes(uint16(0), b) // place holder for length b = serial.Uint16ToBytes(uint16(0), b) // place holder for length
b = serial.Uint16ToBytes(f.SessionId, b) b = serial.Uint16ToBytes(f.SessionID, b)
b = append(b, byte(f.SessionStatus), 0 /* reserved */) b = append(b, byte(f.SessionStatus), 0 /* reserved */)
length := 4 length := 4
@ -84,7 +97,7 @@ func ReadFrameFrom(b []byte) (*FrameMetadata, error) {
} }
f := &FrameMetadata{ f := &FrameMetadata{
SessionId: serial.BytesToUint16(b[:2]), SessionID: serial.BytesToUint16(b[:2]),
SessionStatus: SessionStatus(b[2]), SessionStatus: SessionStatus(b[2]),
} }

View File

@ -2,9 +2,18 @@ package mux
import "v2ray.com/core/common/net" import "v2ray.com/core/common/net"
const (
maxParallel = 8
maxTotal = 128
)
type mergerWorker struct { type mergerWorker struct {
} }
func (w *mergerWorker) isFull() bool {
return true
}
type Merger struct { type Merger struct {
sessions map[net.Destination]mergerWorker sessions map[net.Destination]mergerWorker
} }

View File

@ -1,7 +1,9 @@
package mux package mux
import "v2ray.com/core/common/buf" import (
import "v2ray.com/core/common/serial" "v2ray.com/core/common/buf"
"v2ray.com/core/common/serial"
)
type muxWriter struct { type muxWriter struct {
meta *FrameMetadata meta *FrameMetadata