mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-09 05:49:54 +00:00
fix: use random chars for padding to avoid unwanted header compression
This commit is contained in:
parent
ebb9b3217e
commit
41f10a22c4
@ -2,7 +2,10 @@ package protocol
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
paddingChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
)
|
)
|
||||||
|
|
||||||
// padding specifies a half-open range [Min, Max).
|
// padding specifies a half-open range [Min, Max).
|
||||||
@ -13,7 +16,11 @@ type padding struct {
|
|||||||
|
|
||||||
func (p padding) String() string {
|
func (p padding) String() string {
|
||||||
n := p.Min + rand.Intn(p.Max-p.Min)
|
n := p.Min + rand.Intn(p.Max-p.Min)
|
||||||
return strings.Repeat("a", n) // No need to randomize since everything is encrypted anyway
|
bs := make([]byte, n)
|
||||||
|
for i := range bs {
|
||||||
|
bs[i] = paddingChars[rand.Intn(len(paddingChars))]
|
||||||
|
}
|
||||||
|
return string(bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user