websocket_proxy: implement ping/pong support

needed to keep tunnel connections alive.

> The Ping frame contains an opcode of 0x9.
> [...]
> The Pong frame contains an opcode of 0xA.
-- Section 5.5.2 cf. https://tools.ietf.org/html/rfc6455#section-5.5.2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-03-06 11:20:29 +01:00 committed by Thomas Lamprecht
parent c3bd22ec46
commit e6cb79b52c

View File

@ -511,6 +511,11 @@ sub websocket_proxy {
$reqstate->{proxyhdl}->push_shutdown();
}
$hdl->push_shutdown();
} elsif ($opcode == 9) {
# ping received, schedule pong
$reqstate->{hdl}->push_write($encode->(\$payload, "\x8A")) if $reqstate->{hdl};
} elsif ($opcode == 0xA) {
# pong received, continue
} else {
die "received unhandled websocket opcode $opcode\n";
}