mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-24 08:31:47 +00:00
Some checks failed
Build and Release for Windows 7 / check-assets (push) Has been cancelled
Build and Release / check-assets (push) Has been cancelled
Tests and Checkings / check-assets (push) Has been cancelled
Tests and Checkings / check-proto (push) Has been cancelled
Tests and Checkings / check-format (push) Has been cancelled
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Has been cancelled
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Has been cancelled
Build and Release / build (386, freebsd, ) (push) Has been cancelled
Build and Release / build (386, linux, ) (push) Has been cancelled
Build and Release / build (386, openbsd, ) (push) Has been cancelled
Build and Release / build (386, windows, ) (push) Has been cancelled
Build and Release / build (amd64, android, android-amd64) (push) Has been cancelled
Build and Release / build (amd64, darwin, ) (push) Has been cancelled
Build and Release / build (amd64, freebsd, ) (push) Has been cancelled
Build and Release / build (amd64, linux, ) (push) Has been cancelled
Build and Release / build (amd64, openbsd, ) (push) Has been cancelled
Build and Release / build (amd64, windows, ) (push) Has been cancelled
Build and Release / build (arm, 5, linux) (push) Has been cancelled
Build and Release / build (arm, 6, linux) (push) Has been cancelled
Build and Release / build (arm, 7, freebsd) (push) Has been cancelled
Build and Release / build (arm, 7, linux) (push) Has been cancelled
Build and Release / build (arm, 7, openbsd) (push) Has been cancelled
Build and Release / build (arm64, android) (push) Has been cancelled
Build and Release / build (arm64, darwin) (push) Has been cancelled
Build and Release / build (arm64, freebsd) (push) Has been cancelled
Build and Release / build (arm64, linux) (push) Has been cancelled
Build and Release / build (arm64, openbsd) (push) Has been cancelled
Build and Release / build (arm64, windows) (push) Has been cancelled
Build and Release / build (loong64, linux) (push) Has been cancelled
Build and Release / build (mips, linux) (push) Has been cancelled
Build and Release / build (mips64, linux) (push) Has been cancelled
Build and Release / build (mips64le, linux) (push) Has been cancelled
Build and Release / build (mipsle, linux) (push) Has been cancelled
Build and Release / build (ppc64, linux) (push) Has been cancelled
Build and Release / build (ppc64le, linux) (push) Has been cancelled
Build and Release / build (riscv64, linux) (push) Has been cancelled
Build and Release / build (s390x, linux) (push) Has been cancelled
Tests and Checkings / test (macos-latest) (push) Has been cancelled
Tests and Checkings / test (ubuntu-latest) (push) Has been cancelled
Tests and Checkings / test (windows-latest) (push) Has been cancelled
https://github.com/XTLS/Xray-core/pull/6810#issuecomment-5842441136 https://github.com/XTLS/Xray-core/pull/6878#issuecomment-6095112915 https://github.com/XTLS/Xray-core/pull/7121#issuecomment-6117636043 --------- Co-authored-by: SVLAVR <skugorov.s@gmail.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package masque
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/splithttp"
|
|
)
|
|
|
|
func newTestClient(newConn func(c *Client) splithttp.XmuxConn) *Client {
|
|
c := &Client{ctx: context.Background()}
|
|
c.xmux = splithttp.NewXmuxManager(splithttp.XmuxConfig{
|
|
MaxConnections: &splithttp.RangeConfig{From: 3, To: 3},
|
|
}, func() splithttp.XmuxConn {
|
|
return newConn(c)
|
|
})
|
|
return c
|
|
}
|
|
|
|
func TestGetTunnelFallsBack(t *testing.T) {
|
|
refused := errors.New("refused")
|
|
healthy := &tunnel{done: make(chan struct{})}
|
|
dials := 0
|
|
c := newTestClient(func(c *Client) splithttp.XmuxConn {
|
|
if dials++; dials == 1 {
|
|
return healthy
|
|
}
|
|
c.lastErr, c.lastErrAt = refused, time.Now()
|
|
return failedTunnel(refused)
|
|
})
|
|
for i := 0; i < 5; i++ {
|
|
if _, got, err := c.getTunnel(context.Background(), nil); err != nil || got != healthy {
|
|
t.Fatalf("flow %d: got %p, %v instead of the healthy tunnel", i, got, err)
|
|
}
|
|
}
|
|
if dials != 2 {
|
|
t.Errorf("dialed %d times, a failed tunnel should not be retried within %v", dials, retryInterval)
|
|
}
|
|
}
|
|
|
|
func TestGetTunnelFailsWithoutTunnels(t *testing.T) {
|
|
refused := errors.New("refused")
|
|
c := newTestClient(func(c *Client) splithttp.XmuxConn {
|
|
c.lastErr, c.lastErrAt = refused, time.Now()
|
|
return failedTunnel(refused)
|
|
})
|
|
for i := 0; i < 2; i++ {
|
|
if _, _, err := c.getTunnel(context.Background(), nil); err != refused {
|
|
t.Fatalf("flow %d: got %v instead of %v", i, err, refused)
|
|
}
|
|
}
|
|
}
|