SpoofDPI/packet/https.go

40 lines
760 B
Go
Raw Normal View History

2022-01-08 06:35:32 +00:00
package packet
2022-01-07 18:01:54 +00:00
import (
"regexp"
)
2022-01-08 15:09:01 +00:00
type HttpsPacket struct {
2022-01-11 17:15:45 +00:00
raw []byte
2022-01-07 18:01:54 +00:00
}
2022-01-10 19:27:12 +00:00
func NewHttpsPacket(raw []byte) HttpsPacket {
2022-01-08 15:09:01 +00:00
return HttpsPacket{
2022-01-11 17:15:45 +00:00
raw: raw,
2022-01-07 18:01:54 +00:00
}
}
2022-01-11 17:15:45 +00:00
func (p *HttpsPacket) Raw() []byte {
return p.raw
}
var PatternMatcher *regexp.Regexp
var UrlsMatcher *regexp.Regexp
2022-01-11 17:15:45 +00:00
func (p *HttpsPacket) SplitInChunks() [][]byte {
if len(p.Raw()) < 1 {
return [][]byte{p.Raw()}
2022-01-07 18:01:54 +00:00
}
// If the packet matches the pattern or the URLs, we don't split it
if PatternMatcher != nil || UrlsMatcher != nil {
if (PatternMatcher != nil && PatternMatcher.Match(p.Raw())) || (UrlsMatcher != nil && UrlsMatcher.Match(p.Raw())) {
return [][]byte{(p.Raw())[:1], (p.Raw())[1:]}
}
return [][]byte{p.Raw()}
}
2022-01-11 17:15:45 +00:00
return [][]byte{(p.Raw())[:1], (p.Raw())[1:]}
2022-01-07 18:01:54 +00:00
}