mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-22 17:24:26 +00:00
Compare commits
2
Commits
e4e7614c62
...
QUIC-sniff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1d4a04fb4 | ||
|
|
1aabe7ea78 |
@@ -143,7 +143,9 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(b) < hdrLen+4+block.BlockSize() {
|
||||
return nil, errNotQuic
|
||||
}
|
||||
cache.Clear()
|
||||
mask := cache.Extend(int32(block.BlockSize()))
|
||||
block.Encrypt(mask, b[hdrLen+4:hdrLen+4+len(mask)])
|
||||
|
||||
@@ -24,8 +24,11 @@ func (c *Config) GetNormalizedPath() string {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
if path[len(path)-1] != '/' {
|
||||
path = path + "/"
|
||||
if c.GetNormalizedSessionPlacement() == PlacementPath ||
|
||||
c.GetNormalizedSeqPlacement() == PlacementPath {
|
||||
if path[len(path)-1] != '/' {
|
||||
path = path + "/"
|
||||
}
|
||||
}
|
||||
|
||||
return path
|
||||
|
||||
@@ -3,16 +3,77 @@ package splithttp_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
. "github.com/xtls/xray-core/transport/internet/splithttp"
|
||||
)
|
||||
|
||||
func Test_GetNormalizedPath(t *testing.T) {
|
||||
c := Config{
|
||||
Path: "/?world",
|
||||
tests := []struct {
|
||||
TestName string
|
||||
Path string
|
||||
SessionIDPlacement string
|
||||
SeqPlacement string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
TestName: "default placement keeps trailing slash",
|
||||
Path: "/sh",
|
||||
Expected: "/sh/",
|
||||
},
|
||||
{
|
||||
TestName: "query string is stripped",
|
||||
Path: "/?world",
|
||||
Expected: "/",
|
||||
},
|
||||
{
|
||||
TestName: "both off path drops trailing slash",
|
||||
Path: "/stream",
|
||||
SessionIDPlacement: "query",
|
||||
SeqPlacement: "query",
|
||||
Expected: "/stream",
|
||||
},
|
||||
{
|
||||
TestName: "both off path keeps file-like path",
|
||||
Path: "/stream/filename.extension",
|
||||
SessionIDPlacement: "query",
|
||||
SeqPlacement: "header",
|
||||
Expected: "/stream/filename.extension",
|
||||
},
|
||||
{
|
||||
TestName: "seq in path keeps trailing slash",
|
||||
Path: "/stream",
|
||||
SessionIDPlacement: "query",
|
||||
Expected: "/stream/",
|
||||
},
|
||||
{
|
||||
TestName: "session in path keeps trailing slash",
|
||||
Path: "/stream",
|
||||
SeqPlacement: "cookie",
|
||||
Expected: "/stream/",
|
||||
},
|
||||
{
|
||||
TestName: "existing trailing slash preserved",
|
||||
Path: "/stream/",
|
||||
SessionIDPlacement: "query",
|
||||
SeqPlacement: "query",
|
||||
Expected: "/stream/",
|
||||
},
|
||||
{
|
||||
TestName: "root unchanged",
|
||||
Path: "/",
|
||||
SessionIDPlacement: "query",
|
||||
SeqPlacement: "query",
|
||||
Expected: "/",
|
||||
},
|
||||
}
|
||||
|
||||
path := c.GetNormalizedPath()
|
||||
if path != "/" {
|
||||
t.Error("Unexpected: ", path)
|
||||
for _, test := range tests {
|
||||
t.Run(test.TestName, func(t *testing.T) {
|
||||
c := Config{
|
||||
Path: test.Path,
|
||||
SessionIDPlacement: test.SessionIDPlacement,
|
||||
SeqPlacement: test.SeqPlacement,
|
||||
}
|
||||
assert.Equal(t, test.Expected, c.GetNormalizedPath())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user