mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-24 00:21:00 +00:00
XHTTP transport: Do not force trailing path / when both sessionID and seq are placed elsewhere (#6307)
Some checks are pending
Build and Release for Windows 7 / check-assets (push) Waiting to run
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Blocked by required conditions
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Blocked by required conditions
Build and Release / check-assets (push) Waiting to run
Build and Release / build (386, freebsd, ) (push) Blocked by required conditions
Build and Release / build (386, linux, ) (push) Blocked by required conditions
Build and Release / build (386, openbsd, ) (push) Blocked by required conditions
Build and Release / build (386, windows, ) (push) Blocked by required conditions
Build and Release / build (amd64, android, android-amd64) (push) Blocked by required conditions
Build and Release / build (amd64, darwin, ) (push) Blocked by required conditions
Build and Release / build (amd64, freebsd, ) (push) Blocked by required conditions
Build and Release / build (amd64, linux, ) (push) Blocked by required conditions
Build and Release / build (amd64, openbsd, ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, ) (push) Blocked by required conditions
Build and Release / build (arm, 5, linux) (push) Blocked by required conditions
Build and Release / build (arm, 6, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, freebsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, android) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, freebsd) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / build (loong64, linux) (push) Blocked by required conditions
Build and Release / build (mips, linux) (push) Blocked by required conditions
Build and Release / build (mips64, linux) (push) Blocked by required conditions
Build and Release / build (mips64le, linux) (push) Blocked by required conditions
Build and Release / build (mipsle, linux) (push) Blocked by required conditions
Build and Release / build (ppc64, linux) (push) Blocked by required conditions
Build and Release / build (ppc64le, linux) (push) Blocked by required conditions
Build and Release / build (riscv64, linux) (push) Blocked by required conditions
Build and Release / build (s390x, linux) (push) Blocked by required conditions
Tests and Checkings / check-assets (push) Waiting to run
Tests and Checkings / check-proto (push) Waiting to run
Tests and Checkings / check-format (push) Waiting to run
Tests and Checkings / test (macos-latest) (push) Blocked by required conditions
Tests and Checkings / test (ubuntu-latest) (push) Blocked by required conditions
Tests and Checkings / test (windows-latest) (push) Blocked by required conditions
Some checks are pending
Build and Release for Windows 7 / check-assets (push) Waiting to run
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Blocked by required conditions
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Blocked by required conditions
Build and Release / check-assets (push) Waiting to run
Build and Release / build (386, freebsd, ) (push) Blocked by required conditions
Build and Release / build (386, linux, ) (push) Blocked by required conditions
Build and Release / build (386, openbsd, ) (push) Blocked by required conditions
Build and Release / build (386, windows, ) (push) Blocked by required conditions
Build and Release / build (amd64, android, android-amd64) (push) Blocked by required conditions
Build and Release / build (amd64, darwin, ) (push) Blocked by required conditions
Build and Release / build (amd64, freebsd, ) (push) Blocked by required conditions
Build and Release / build (amd64, linux, ) (push) Blocked by required conditions
Build and Release / build (amd64, openbsd, ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, ) (push) Blocked by required conditions
Build and Release / build (arm, 5, linux) (push) Blocked by required conditions
Build and Release / build (arm, 6, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, freebsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, android) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, freebsd) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / build (loong64, linux) (push) Blocked by required conditions
Build and Release / build (mips, linux) (push) Blocked by required conditions
Build and Release / build (mips64, linux) (push) Blocked by required conditions
Build and Release / build (mips64le, linux) (push) Blocked by required conditions
Build and Release / build (mipsle, linux) (push) Blocked by required conditions
Build and Release / build (ppc64, linux) (push) Blocked by required conditions
Build and Release / build (ppc64le, linux) (push) Blocked by required conditions
Build and Release / build (riscv64, linux) (push) Blocked by required conditions
Build and Release / build (s390x, linux) (push) Blocked by required conditions
Tests and Checkings / check-assets (push) Waiting to run
Tests and Checkings / check-proto (push) Waiting to run
Tests and Checkings / check-format (push) Waiting to run
Tests and Checkings / test (macos-latest) (push) Blocked by required conditions
Tests and Checkings / test (ubuntu-latest) (push) Blocked by required conditions
Tests and Checkings / test (windows-latest) (push) Blocked by required conditions
https://github.com/XTLS/Xray-core/discussions/6385#discussioncomment-17454120 https://github.com/XTLS/Xray-core/pull/6307#issuecomment-4917498294 Closes https://github.com/XTLS/Xray-core/issues/6410
This commit is contained in:
parent
e4e7614c62
commit
1aabe7ea78
2 changed files with 72 additions and 8 deletions
|
|
@ -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())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue