fix: sync same-port transport detection
This commit is contained in:
parent
840ef6237c
commit
2289a31f46
10 changed files with 851 additions and 83 deletions
|
|
@ -232,13 +232,13 @@ func TestServerAcceptObfuscatedAbridgedQuickAckFrame(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServerSamePortWebSocketAndObfuscatedTCP(t *testing.T) {
|
||||
func TestServerSamePortWebSocketAndMixedTCP(t *testing.T) {
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("listen: %v", err)
|
||||
}
|
||||
|
||||
frames := make(chan int, 2)
|
||||
frames := make(chan int, 3)
|
||||
srv := New(Options{Logger: zaptest.NewLogger(t), ObfuscatedTCP: true, WebSocket: true})
|
||||
srv.onFrame = func(n int) {
|
||||
select {
|
||||
|
|
@ -302,6 +302,27 @@ func TestServerSamePortWebSocketAndObfuscatedTCP(t *testing.T) {
|
|||
expectFrameLen(t, frames, tcpPayload.Len())
|
||||
_ = tcpConn.Close()
|
||||
|
||||
plainRaw, err := net.Dial("tcp", ln.Addr().String())
|
||||
if err != nil {
|
||||
t.Fatalf("plain tcp dial: %v", err)
|
||||
}
|
||||
plainConn, err := transport.Intermediate.Handshake(plainRaw)
|
||||
if err != nil {
|
||||
_ = plainRaw.Close()
|
||||
t.Fatalf("plain tcp transport handshake: %v", err)
|
||||
}
|
||||
var plainPayload bin.Buffer
|
||||
plainPayload.PutInt32(0x33445566)
|
||||
plainPayload.PutInt32(0x77889900)
|
||||
sendCtx, sc = context.WithTimeout(context.Background(), 5*time.Second)
|
||||
if err := plainConn.Send(sendCtx, &plainPayload); err != nil {
|
||||
sc()
|
||||
t.Fatalf("plain tcp send: %v", err)
|
||||
}
|
||||
sc()
|
||||
expectFrameLen(t, frames, plainPayload.Len())
|
||||
_ = plainConn.Close()
|
||||
|
||||
cancel()
|
||||
select {
|
||||
case err := <-serveErr:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue