Darien Raymond hace 8 años
padre
commit
eab2f1effc
Se han modificado 3 ficheros con 29 adiciones y 5 borrados
  1. 16 3
      app/proxyman/mux/frame.go
  2. 9 0
      app/proxyman/mux/mux.go
  3. 4 2
      app/proxyman/mux/writer.go

+ 16 - 3
app/proxyman/mux/frame.go

@@ -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]),
 	}
 

+ 9 - 0
app/proxyman/mux/mux.go

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

+ 4 - 2
app/proxyman/mux/writer.go

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