mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-04 20:08:38 +00:00
Compress if it's gzip chunk (probably wrong!)
This commit is contained in:
parent
308d3cfd87
commit
094a7c3da4
@ -3,6 +3,7 @@ package tlstapper
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
@ -161,8 +162,22 @@ func (p *tlsPoller) pollGolangReadWrite(rd *ringbuf.Reader, emitter api.Emitter,
|
|||||||
connection = _connection.(*golangConnection)
|
connection = _connection.(*golangConnection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data := []byte(b.Data[:])
|
||||||
|
|
||||||
if b.IsGzipChunk {
|
if b.IsGzipChunk {
|
||||||
|
// Compress if it's gzip chunk (probably wrong!)
|
||||||
connection.Gzipped = true
|
connection.Gzipped = true
|
||||||
|
var buf bytes.Buffer
|
||||||
|
gz := gzip.NewWriter(&buf)
|
||||||
|
if _, err := gz.Write(data); err != nil {
|
||||||
|
log.Printf("gzip write: %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := gz.Close(); err != nil {
|
||||||
|
log.Printf("gzip close: %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
data = buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.IsRequest {
|
if b.IsRequest {
|
||||||
@ -184,12 +199,12 @@ func (p *tlsPoller) pollGolangReadWrite(rd *ringbuf.Reader, emitter api.Emitter,
|
|||||||
go dissect(p.extension, connection.ClientReader, options)
|
go dissect(p.extension, connection.ClientReader, options)
|
||||||
go dissect(p.extension, connection.ServerReader, options)
|
go dissect(p.extension, connection.ServerReader, options)
|
||||||
|
|
||||||
request := make([]byte, len(b.Data[:b.Len]))
|
request := make([]byte, len(data[:b.Len]))
|
||||||
copy(request, b.Data[:b.Len])
|
copy(request, data[:b.Len])
|
||||||
connection.ClientReader.send(request)
|
connection.ClientReader.send(request)
|
||||||
} else {
|
} else {
|
||||||
response := make([]byte, len(b.Data[:b.Len]))
|
response := make([]byte, len(data[:b.Len]))
|
||||||
copy(response, b.Data[:b.Len])
|
copy(response, data[:b.Len])
|
||||||
connection.ServerReader.send(response)
|
connection.ServerReader.send(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user