Novo pipeline de video: scripts/screencast/render.py roda uma fase em um pty,
emula o terminal com pyte, gera frames PNG e mux com ffmpeg (H.264,
yuv420p, +faststart, sem trilha de audio). Fallback de encoder: libx264 ->
libopenh264 -> VP9.
Fases (scripts/screencast/phases/, uma sessao real contra o lab por video):
1. implementacao no kernel - fontes OpenBSD + compat + build limpo do pf.ko
2. ativacao - insmod, /dev/pf, pfctl -e, pfctl -s info
3. regras basicas - tabela, anchor, keep state, block drop
4. roteamento - route-to e reply-to (provado com tcpdump nas 2 interfaces)
5. balanceamento - pool round-robin, pool source-hash, dup-to
6. QOS - filas hfsc, pfctl -s queue -v, transferencia de 2 MB pela fila
Os videos ficam versionados em out/screencast/ (.gitignore ajustado para
nao ignorar *.mp4) e o indice/texto de descricao do YouTube em
docs/{en,pt-BR}/screencast.md.
Correcoes na propria demo (encontradas gravando): a acao de uma regra no pf
e pass OU block (nunca os dois); as regras de um anchor vivem em um ruleset
proprio (pfctl -a <anchor> -f); o nc do QOS precisa rodar na VM do servidor,
nao no firewall; o rotulo 'FASE x/6' vem do numero da fase, nao da posicao
na lista de gravacao.
73 lines
1.9 KiB
Bash
Executable File
73 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Shared helpers for the screencast phase scripts.
|
|
#
|
|
# Everything printed by a phase is the REAL output of the lab: Alpine VMs
|
|
# under libvirt running the kernel built from source with pf.ko. Only the
|
|
# framing (prompts, banners) is scripted.
|
|
set -u
|
|
|
|
DEB=${DEB:-root@192.168.1.242}
|
|
KEY=${KEY:-$HOME/.ssh/pflab_ed}
|
|
CLI_IP=${CLI_IP:-10.0.1.10}
|
|
SRV_IP=${SRV_IP:-10.0.2.20}
|
|
GW2_IP=${GW2_IP:-10.0.3.2}
|
|
REPO=${REPO:-$(cd "$(dirname "$0")/../../.." && pwd)}
|
|
|
|
cyan() { printf '\033[1;36m%s\033[0m\n' "$*"; }
|
|
green() { printf '\033[1;32m%s\033[0m\n' "$*"; }
|
|
yellow(){ printf '\033[1;33m%s\033[0m\n' "$*"; }
|
|
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
|
|
dim() { printf '\033[2m%s\033[0m\n' "$*"; }
|
|
|
|
banner() {
|
|
echo
|
|
bold "==============================================================="
|
|
bold " $*"
|
|
bold "==============================================================="
|
|
echo
|
|
}
|
|
|
|
mgmt() {
|
|
ssh -o ConnectTimeout=8 "$DEB" "virsh domifaddr $1 | awk '/vnet/{print \$4}' | cut -d/ -f1" \
|
|
2>/dev/null | tr -d '\r' | head -1
|
|
}
|
|
|
|
PF0_MGMT=${PF0_MGMT:-$(mgmt pftest-pf0)}
|
|
CLI_MGMT=${CLI_MGMT:-$(mgmt pftest-cli)}
|
|
SRV_MGMT=${SRV_MGMT:-$(mgmt pftest-srv)}
|
|
[ -n "$PF0_MGMT" ] || PF0_MGMT=192.168.122.8
|
|
[ -n "$CLI_MGMT" ] || CLI_MGMT=192.168.122.230
|
|
[ -n "$SRV_MGMT" ] || SRV_MGMT=192.168.122.202
|
|
|
|
onvm() {
|
|
local ip=$1; shift
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new -o LogLevel=ERROR \
|
|
-o ProxyJump=root@192.168.1.242 -i "$KEY" root@"$ip" "$@" 2>&1
|
|
}
|
|
|
|
# run on the firewall VM, showing the command as a prompt
|
|
p0() {
|
|
cyan "pf0# $*"
|
|
onvm "$PF0_MGMT" "$@"
|
|
sleep 0.7
|
|
}
|
|
|
|
# run on the client VM
|
|
vmc() {
|
|
cyan "cli# $*"
|
|
onvm "$CLI_MGMT" "$@"
|
|
sleep 0.7
|
|
}
|
|
|
|
# run on the server VM
|
|
vms() {
|
|
cyan "srv# $*"
|
|
onvm "$SRV_MGMT" "$@"
|
|
sleep 0.7
|
|
}
|
|
|
|
# upload a local file to the firewall VM
|
|
put() {
|
|
scp -q -o ProxyJump=root@192.168.1.242 -i "$KEY" "$1" "root@$PF0_MGMT:/tmp/" 2>/dev/null
|
|
}
|