Commit ec5052e5 authored by ginuerzh's avatar ginuerzh

obfs: tls max data length limitation

parent c1bac99a
...@@ -25,6 +25,10 @@ import ( ...@@ -25,6 +25,10 @@ import (
dissector "github.com/ginuerzh/tls-dissector" dissector "github.com/ginuerzh/tls-dissector"
) )
const (
maxTLSDataLen = 16384
)
type obfsHTTPTransporter struct { type obfsHTTPTransporter struct {
tcpTransporter tcpTransporter
} }
...@@ -544,10 +548,18 @@ func (c *obfsTLSConn) Write(b []byte) (n int, err error) { ...@@ -544,10 +548,18 @@ func (c *obfsTLSConn) Write(b []byte) (n int, err error) {
} }
} }
for len(b) > 0 {
data := b
if len(b) > maxTLSDataLen {
data = b[:maxTLSDataLen]
b = b[maxTLSDdataLen:]
} else {
b = b[:0]
}
record := &dissector.Record{ record := &dissector.Record{
Type: dissector.AppData, Type: dissector.AppData,
Version: tls.VersionTLS12, Version: tls.VersionTLS12,
Opaque: b, Opaque: data,
} }
if c.wbuf.Len() > 0 { if c.wbuf.Len() > 0 {
...@@ -560,6 +572,7 @@ func (c *obfsTLSConn) Write(b []byte) (n int, err error) { ...@@ -560,6 +572,7 @@ func (c *obfsTLSConn) Write(b []byte) (n int, err error) {
if _, err = record.WriteTo(c.Conn); err != nil { if _, err = record.WriteTo(c.Conn); err != nil {
return return
} }
}
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment