core,test: fix multiplxing for wss and h2

This commit is contained in:
Micooz 2018-06-17 14:31:26 +08:00
parent f463a5ae60
commit 79882e1421
2 changed files with 32 additions and 2 deletions

@ -5,6 +5,8 @@ import {
TcpInbound, TcpOutbound,
TlsInbound, TlsOutbound,
WsInbound, WsOutbound,
WssInbound, WssOutbound,
Http2Inbound, Http2Outbound,
MuxInbound, MuxOutbound,
} from '../transports';
@ -25,6 +27,8 @@ export class MuxRelay extends Relay {
'tcp': [TcpInbound, TcpOutbound],
'tls': [TlsInbound, TlsOutbound],
'ws': [WsInbound, WsOutbound],
'wss': [WssInbound, WssOutbound],
'h2': [Http2Inbound, Http2Outbound],
};
const [Inbound, Outbound] = this._config.is_client ? [MuxInbound, mapping[transport][1]] : [mapping[transport][0], MuxOutbound];
return { Inbound, Outbound };

@ -50,6 +50,19 @@ test('multiplexing over tcp', async () => {
await run({ clientJson, serverJson, repeat: 10, isUdp: true });
});
test('multiplexing over tls', async () => {
const service = 'tls://localhost:1082';
const clientJson = clone(client);
const serverJson = clone(server);
clientJson.server.service = service;
serverJson.service = service;
await run({ clientJson, serverJson, repeat: 10 });
await run({ clientJson, serverJson, repeat: 10, isUdp: true });
});
test('multiplexing over ws', async () => {
const service = 'ws://127.0.0.1:1082';
@ -63,8 +76,21 @@ test('multiplexing over ws', async () => {
await run({ clientJson, serverJson, repeat: 10, isUdp: true });
});
test('multiplexing over tls', async () => {
const service = 'tls://localhost:1082';
test('multiplexing over wss', async () => {
const service = 'wss://localhost:1082';
const clientJson = clone(client);
const serverJson = clone(server);
clientJson.server.service = service;
serverJson.service = service;
await run({ clientJson, serverJson, repeat: 10 });
await run({ clientJson, serverJson, repeat: 10, isUdp: true });
});
test('multiplexing over h2', async () => {
const service = 'h2://localhost:1082';
const clientJson = clone(client);
const serverJson = clone(server);