mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
refactor
This commit is contained in:
parent
8b15b32126
commit
eab2f1effc
@ -31,8 +31,21 @@ const (
|
||||
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 {
|
||||
SessionId uint16
|
||||
SessionID uint16
|
||||
SessionStatus SessionStatus
|
||||
Target net.Destination
|
||||
}
|
||||
@ -41,7 +54,7 @@ func (f FrameMetadata) AsSupplier() buf.Supplier {
|
||||
return func(b []byte) (int, error) {
|
||||
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 */)
|
||||
length := 4
|
||||
|
||||
@ -84,7 +97,7 @@ func ReadFrameFrom(b []byte) (*FrameMetadata, error) {
|
||||
}
|
||||
|
||||
f := &FrameMetadata{
|
||||
SessionId: serial.BytesToUint16(b[:2]),
|
||||
SessionID: serial.BytesToUint16(b[:2]),
|
||||
SessionStatus: SessionStatus(b[2]),
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,18 @@ package mux
|
||||
|
||||
import "v2ray.com/core/common/net"
|
||||
|
||||
const (
|
||||
maxParallel = 8
|
||||
maxTotal = 128
|
||||
)
|
||||
|
||||
type mergerWorker struct {
|
||||
}
|
||||
|
||||
func (w *mergerWorker) isFull() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type Merger struct {
|
||||
sessions map[net.Destination]mergerWorker
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package mux
|
||||
|
||||
import "v2ray.com/core/common/buf"
|
||||
import "v2ray.com/core/common/serial"
|
||||
import (
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
type muxWriter struct {
|
||||
meta *FrameMetadata
|
||||
|
Loading…
Reference in New Issue
Block a user