mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
40 lines
760 B
Go
40 lines
760 B
Go
package packet
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
type HttpsPacket struct {
|
|
raw []byte
|
|
}
|
|
|
|
func NewHttpsPacket(raw []byte) HttpsPacket {
|
|
return HttpsPacket{
|
|
raw: raw,
|
|
}
|
|
}
|
|
|
|
func (p *HttpsPacket) Raw() []byte {
|
|
return p.raw
|
|
}
|
|
|
|
var PatternMatcher *regexp.Regexp
|
|
var UrlsMatcher *regexp.Regexp
|
|
|
|
func (p *HttpsPacket) SplitInChunks() [][]byte {
|
|
if len(p.Raw()) < 1 {
|
|
return [][]byte{p.Raw()}
|
|
}
|
|
|
|
// 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()}
|
|
}
|
|
|
|
return [][]byte{(p.Raw())[:1], (p.Raw())[1:]}
|
|
}
|