Browse Source

Removing compression

Armon Dadgar 10 năm trước cách đây
mục cha
commit
3b131e6dd7
5 tập tin đã thay đổi với 2 bổ sung28 xóa
  1. 0 4
      README.md
  2. 0 4
      const.go
  3. 2 5
      const_test.go
  4. 0 5
      mux.go
  5. 0 10
      stream.go

+ 0 - 4
README.md

@@ -9,7 +9,6 @@ interoperable with it.
 Yamux features include:
 * Bi-directional streams created by either client or server
 * Flow control, this prevents a single flow from starving others
-* Transparent compression
 
 # Framing
 
@@ -64,9 +63,6 @@ to the message type. The following flags are supported:
 
 * 0x8 RST - Reset a stream immediately. Sent with a data message only.
 
-* 0x 16 LZW - Indicates the payload is LZW compressed. Sent with a data message
-  only.
-
 ## StreamID Field
 
 The StreamID field is used to identify the logical stream the frame

+ 0 - 4
const.go

@@ -86,10 +86,6 @@ const (
 
 	// RST is used to hard close a given stream.
 	flagRST
-
-	// LZW is used to indicate that the payload is
-	// compressed with the LZW algorithm
-	flagLZW
 )
 
 const (

+ 2 - 5
const_test.go

@@ -34,9 +34,6 @@ func TestConst(t *testing.T) {
 	if flagRST != 8 {
 		t.Fatalf("bad: %v", flagRST)
 	}
-	if flagLZW != 16 {
-		t.Fatalf("bad: %v", flagLZW)
-	}
 
 	if goAwayNormal != 0 {
 		t.Fatalf("bad: %v", goAwayNormal)
@@ -55,7 +52,7 @@ func TestConst(t *testing.T) {
 
 func TestEncodeDecode(t *testing.T) {
 	hdr := header(make([]byte, headerSize))
-	hdr.encode(typeWindowUpdate, flagACK|flagLZW, 1234, 4321)
+	hdr.encode(typeWindowUpdate, flagACK|flagRST, 1234, 4321)
 
 	if hdr.Version() != protoVersion {
 		t.Fatalf("bad: %v", hdr)
@@ -63,7 +60,7 @@ func TestEncodeDecode(t *testing.T) {
 	if hdr.MsgType() != typeWindowUpdate {
 		t.Fatalf("bad: %v", hdr)
 	}
-	if hdr.Flags() != flagACK|flagLZW {
+	if hdr.Flags() != flagACK|flagRST {
 		t.Fatalf("bad: %v", hdr)
 	}
 	if hdr.StreamID() != 1234 {

+ 0 - 5
mux.go

@@ -12,10 +12,6 @@ type Config struct {
 	// waiting an accept.
 	AcceptBacklog int
 
-	// EnableCompression is used to control if we compress
-	// outgoing data. We have no control over incoming data.
-	EnableCompression bool
-
 	// EnableKeepalive is used to do a period keep alive
 	// messages using a ping.
 	EnableKeepAlive bool
@@ -32,7 +28,6 @@ type Config struct {
 func DefaultConfig() *Config {
 	return &Config{
 		AcceptBacklog:       256,
-		EnableCompression:   true,
 		EnableKeepAlive:     true,
 		KeepAliveInterval:   30 * time.Second,
 		MaxStreamWindowSize: initialStreamWindow,

+ 0 - 10
stream.go

@@ -2,7 +2,6 @@ package yamux
 
 import (
 	"bytes"
-	"compress/lzw"
 	"io"
 	"sync"
 	"time"
@@ -150,8 +149,6 @@ START:
 	max = min(s.sendWindow, uint32(len(b)))
 	body = bytes.NewReader(b[:max])
 
-	// TODO: Compress
-
 	// Send the header
 	s.sendHdr.encode(typeData, flags, s.id, max)
 	if err := s.session.waitForSend(s.sendHdr, body); err != nil {
@@ -337,13 +334,6 @@ func (s *Stream) readData(hdr header, flags uint16, conn io.Reader) error {
 	// Wrap in a limited reader
 	conn = &io.LimitedReader{R: conn, N: int64(length)}
 
-	// Handle potential data compression
-	if flags&flagLZW == flagLZW {
-		cr := lzw.NewReader(conn, lzw.MSB, 8)
-		defer cr.Close()
-		conn = cr
-	}
-
 	// Copy to our buffer
 	if _, err := io.Copy(&s.recvBuf, conn); err != nil {
 		return err