SpoofDPI/packet/https.go

38 lines
644 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 (
2023-05-07 05:57:52 +00:00
"github.com/xvzc/SpoofDPI/util"
)
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
}
func (p *HttpsPacket) SplitInChunks() [][]byte {
if len(p.Raw()) < 1 {
return [][]byte{p.Raw()}
2022-01-07 18:01:54 +00:00
}
2023-05-07 05:57:52 +00:00
config := util.GetConfig()
2022-01-07 18:01:54 +00:00
// If the packet matches the pattern or the URLs, we don't split it
2023-05-07 05:57:52 +00:00
if config.PatternExists() {
if (config.PatternMatches(p.Raw())) {
return [][]byte{(p.Raw())[:1], (p.Raw())[1:]}
}
2023-05-07 05:57:52 +00:00
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
}