mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 22:36:53 +00:00
re-add legacy style fragmentaion
This commit is contained in:
parent
f50beaa3fe
commit
23f160d37b
@ -89,22 +89,34 @@ func (pxy *Proxy) splitInChunks(bytes []byte, size int) [][]byte {
|
|||||||
var chunks [][]byte
|
var chunks [][]byte
|
||||||
var raw []byte = bytes
|
var raw []byte = bytes
|
||||||
|
|
||||||
for {
|
if pxy.windowSize > 0 {
|
||||||
if len(raw) == 0 {
|
log.Debug("[HTTPS] Chunking client hello.")
|
||||||
break
|
|
||||||
|
for {
|
||||||
|
if len(raw) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// necessary check to avoid slicing beyond
|
||||||
|
// slice capacity
|
||||||
|
if len(raw) < size {
|
||||||
|
size = len(raw)
|
||||||
|
}
|
||||||
|
|
||||||
|
chunks = append(chunks, raw[0:size])
|
||||||
|
raw = raw[size:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// necessary check to avoid slicing beyond
|
return chunks
|
||||||
// slice capacity
|
|
||||||
if len(raw) < size {
|
|
||||||
size = len(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
chunks = append(chunks, raw[0:size])
|
|
||||||
raw = raw[size:]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunks
|
if len(raw) < 1 {
|
||||||
|
return [][]byte{raw}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("[HTTPS] Using legacy fragmentation.")
|
||||||
|
|
||||||
|
return [][]byte{raw[:1], raw[1:]}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pxy *Proxy) patternExists() bool {
|
func (pxy *Proxy) patternExists() bool {
|
||||||
|
@ -47,23 +47,26 @@ func GetConfig() *Config {
|
|||||||
|
|
||||||
func ParseArgs() {
|
func ParseArgs() {
|
||||||
config = &Config{}
|
config = &Config{}
|
||||||
config.Addr = flag.String("addr", "127.0.0.1", "Listen addr")
|
config.Addr = flag.String("addr", "127.0.0.1", "listen address")
|
||||||
config.Port = flag.Int("port", 8080, "port")
|
config.Port = flag.Int("port", 8080, "port")
|
||||||
config.DnsAddr = flag.String("dns-addr", "8.8.8.8", "DNS addr")
|
config.DnsAddr = flag.String("dns-addr", "8.8.8.8", "dns address")
|
||||||
config.DnsPort = flag.Int("dns-port", 53, "DNS port")
|
config.DnsPort = flag.Int("dns-port", 53, "port number for dns")
|
||||||
config.EnableDoh = flag.Bool("enable-doh", false, "Enable DOH")
|
config.EnableDoh = flag.Bool("enable-doh", false, "enable 'dns over https'")
|
||||||
config.Debug = flag.Bool("debug", false, "Enable debug output")
|
config.Debug = flag.Bool("debug", false, "enable debug output")
|
||||||
config.NoBanner = flag.Bool("no-banner", false, "Disable banner")
|
config.NoBanner = flag.Bool("no-banner", false, "disable banner")
|
||||||
config.Timeout = flag.Int("timeout", 2000, "timeout in milliseconds")
|
config.Timeout = flag.Int("timeout", 2000, "timeout in milliseconds")
|
||||||
config.WindowSize = flag.Int("window-size", 50, "window-size for fragmented client hello")
|
config.WindowSize = flag.Int("window-size", 50, `chunk size, in number of bytes, for fragmented client hello,
|
||||||
config.Version = flag.Bool("v", false, "print version")
|
try lower values if the default value doesn't bypass the DPI;
|
||||||
|
set to 0 to use old (pre v0.10.0) client hello splitting method:
|
||||||
|
fragmentation for the first data packet and the rest`)
|
||||||
flag.Var(&allowedHosts, "url", "Bypass DPI only on this url, can be passed multiple times")
|
flag.Var(&allowedHosts, "url", "Bypass DPI only on this url, can be passed multiple times")
|
||||||
allowedPattern = flag.String(
|
allowedPattern = flag.String(
|
||||||
"pattern",
|
"pattern",
|
||||||
"",
|
"",
|
||||||
"Bypass DPI only on packets matching this regex pattern",
|
"bypass DPI only on packets matching this regex pattern",
|
||||||
)
|
)
|
||||||
|
config.Version = flag.Bool("v", false, "print spoof-dpi's version. this may contain some other relevant information")
|
||||||
|
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user