mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-07-20 02:18:02 +00:00
XPlus obfs & don't frag
This commit is contained in:
31
pkg/obfs/xplus_test.go
Normal file
31
pkg/obfs/xplus_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package obfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestXPlusObfuscator(t *testing.T) {
|
||||
x := NewXPlusObfuscator([]byte("Vaundy"))
|
||||
tests := []struct {
|
||||
name string
|
||||
p []byte
|
||||
}{
|
||||
{name: "1", p: []byte("HelloWorld")},
|
||||
{name: "2", p: []byte("Regret is just a horrible attempt at time travel that ends with you feeling like crap")},
|
||||
{name: "3", p: []byte("To be, or not to be, that is the question:\nWhether 'tis nobler in the mind to suffer\n" +
|
||||
"The slings and arrows of outrageous fortune,\nOr to take arms against a sea of troubles\n" +
|
||||
"And by opposing end them. To die—to sleep,\nNo more; and by a sleep to say we end")},
|
||||
{name: "empty", p: []byte("")},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
bs := x.Obfuscate(tt.p)
|
||||
outBs := make([]byte, len(bs))
|
||||
n := x.Deobfuscate(bs, outBs)
|
||||
if !bytes.Equal(tt.p, outBs[:n]) {
|
||||
t.Errorf("Inconsistent deobfuscate result: got %v, want %v", outBs[:n], tt.p)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user