netbridge
Reverse SSH tunnels through a relay, no inbound port needed.
Two tunnel kinds, both plain ssh -R: a reverse port-forward (relay:PORT -> a service on this machine, e.g. your own sshd for remote-shell access) or a reverse dynamic/SOCKS5 forward (one tunnel reaches your whole reachable network). ssh -N is silent on success, so it detects failure by scanning for known error markers, not by waiting for an exit code that may never come.
What you get
- Reverse port-forward or whole-network SOCKS5
- Exact ssh -R command construction, both kinds
- Error-marker detection (ssh -N is silent on success)
- Exponential-backoff auto-reconnect
Try it
import "netbridge" as netbridge
let srv = netbridge.default_server()
srv["host"] = "relay.example.com"
srv["identity"] = "~/.ssh/netbridge_key"
let shell = netbridge.tunnel_forward("my-shell", 2200, "127.0.0.1", 22)
print(netbridge.route_label(shell))
print(netbridge.build_ssh_command(srv, shell))
let net = netbridge.tunnel_socks("internal-net", 1080)
print(netbridge.route_label(net))
print(netbridge.effective_shell_port({"tunnels": [net]}))relay:2200 -> 127.0.0.1:22 'ssh' -N -T -p 22 -i '~/.ssh/netbridge_key' -R '2200:127.0.0.1:22' -o BatchMode=yes -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile='known_hosts' 'tunnel@relay.example.com' SOCKS5 @ relay:1080 -> (whole reachable network) 2200
One script, one password, done - same file on Linux, macOS, or Windows
examples/native_ssh_setup.lz - the one script to reach for, on any of them. Fill in 6 lines at the top (relay host/port, root password, the port/service to expose), run it: generates its own client key, uses the password once to create a locked-down tunnel user on the relay, verifies the relay's host key on every connection (ssh.verify_host_trust_on_first_use() - trusts it the first time, fails closed the moment it ever changes), then connects and stays connected with real reverse-forwarding. Uses the ssh package (real SSH via libssh, bound into the interpreter itself) for everything - nothing external runs at any point on any platform, no ssh binary, no sshpass, no WSL.
# native_ssh_setup.lz - ONE script, same file, for Linux, macOS, AND
# Windows - fill in 6 lines, run it, done, on whichever you're on. Uses
# the `ssh` package (real SSH via libssh, bound into the interpreter
# itself) for EVERYTHING - the one-time password-authenticated relay
# setup AND the tunnel connection both go through
# ssh.connect()/ssh.run()/ssh.forward_remote_port(), with real host-key
# verification (ssh.verify_host_trust_on_first_use()) on both. No
# shelling out to the `ssh` binary, no `sshpass` dependency, no WSL, no
# per-OS variant to maintain - nothing external at all beyond
# `larzscript` and two Stack packages, on any of them.
#
# By default this exposes whatever real service is already listening on
# TARGET_HOST:TARGET_PORT (a real sshd, RDP, etc.) - if the machine
# you're exposing has NO real SSH server installed at all and you want
# one anyway, see native_ssh_server_and_bridge.lz instead: same "no
# external dependencies" story, but the "service" being exposed is
# ITSELF a native larzscript SSH server (real interactive shell
# included) rather than something you had to install separately.
#
# Needs the `ssh` package's native libssh binding, which - as of this
# writing - covers every native target larzscript builds for: Linux
# (x86_64 + aarch64), macOS (x86_64 + arm64), and Windows x86_64, all
# CI-verified against a real independent sshd/ssh client (see `ssh`'s
# own README for exact platform status). On wasm (the one platform it
# doesn't cover, permanently - no raw TCP in that sandbox)? Use
# password_setup.lz instead (shells to the real `ssh`/`sshpass`
# binaries, works everywhere those do, just needs those installed).
#
# larzscript pkg install netbridge
# larzscript pkg install ssh
# nohup larzscript native_ssh_setup.lz > ~/netbridge.log 2>&1 &
# (on Windows: just `larzscript native_ssh_setup.lz`, no nohup/&)
import "ssh" as ssh
# ---- fill these in ----
let RELAY_HOST = "203.0.113.10" # your relay's address or IP
let RELAY_SSH_PORT = 22 # whatever port sshd listens on there
let RELAY_ROOT_USER = "root"
let RELAY_ROOT_PASSWORD = "change-me" # only used once, for setup
let TUNNEL_PORT = 2200 # the port on the relay that will reach this machine
let TARGET_HOST = "127.0.0.1" # the local service to expose...
let TARGET_PORT = 22 # ...and its port (e.g. 3389 for Windows RDP)
# ------------------------
# HOME isn't set by default in plain cmd/PowerShell - USERPROFILE is
# Windows' equivalent. Forward slashes work fine in paths passed to
# larzscript's own file/ssh-keygen calls on all three platforms.
let SSH_DIR = env("HOME", env("USERPROFILE", ".")) + "/.ssh"
let KEY_PATH = SSH_DIR + "/netbridge_key"
let KNOWN_HOSTS_PATH = SSH_DIR + "/known_hosts"
fn step(msg) { print("==> " + msg) }
# ---- 1. client key - generated fresh here, unique per machine ----
# Double-quoted path + double-quoted empty passphrase (-N "") rather
# than single quotes: `run()` shells out via the OS's own shell
# (/bin/sh on Linux/macOS, cmd.exe on Windows) - single-quote emptiness
# is a POSIX-only convention (cmd.exe treats '' as two literal
# characters, not nothing), but "" for an empty argument, and double
# quotes around a path that might contain spaces, both work identically
# on all three - the one quoting style that needed no per-OS branch.
step("client key")
if not file_exists(KEY_PATH) {
run("ssh-keygen -t ed25519 -f \"" + KEY_PATH + "\" -N \"\" -C netbridge-client -q")
print("generated " + KEY_PATH)
} else {
print("already have " + KEY_PATH)
}
let pubkey = read_file(KEY_PATH + ".pub").strip()
# ---- 2. one-time relay setup, authenticated with your password - via
# ssh.run(), not a shelled-out `sshpass ssh ...` command ----
step("setting up the relay (password, one time only, via ssh.run())")
let relay_script = "#!/bin/sh\nset -e\n" +
"TUNNEL_USER=tunnel\n" +
"PUBKEY='" + pubkey + "'\n" +
"id -u \"$TUNNEL_USER\" >/dev/null 2>&1 || useradd -m -s /usr/sbin/nologin \"$TUNNEL_USER\"\n" +
"install -d -m 700 -o \"$TUNNEL_USER\" -g \"$TUNNEL_USER\" \"/home/$TUNNEL_USER/.ssh\"\n" +
"touch \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"chmod 600 \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"chown \"$TUNNEL_USER:$TUNNEL_USER\" \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"grep -qF \"$PUBKEY\" \"/home/$TUNNEL_USER/.ssh/authorized_keys\" 2>/dev/null || " +
"printf 'no-pty,no-X11-forwarding,no-agent-forwarding,command=\"echo netbridge: no interactive shell\" %s\\n' \"$PUBKEY\" >> \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"echo RELAY_SETUP_OK\n"
# Trust-on-first-use is the right call here specifically: this is a
# relay you just built, with no separate side-channel to verify a
# fingerprint against. It still fails closed - throws, refuses to
# proceed - the moment a previously-trusted key CHANGES, which is what
# actually matters (catches a relay swap/MITM on every run AFTER the
# first, not just blind trust forever).
let setup_session = ssh.connect(RELAY_HOST, RELAY_SSH_PORT)
ssh.verify_host_trust_on_first_use(setup_session, KNOWN_HOSTS_PATH)
ssh.authenticate_with_password(setup_session, RELAY_ROOT_USER, RELAY_ROOT_PASSWORD)
let setup_result = ssh.run(setup_session, relay_script)
print(setup_result["stdout"])
if not setup_result["stdout"].contains("RELAY_SETUP_OK") {
print("FAIL: could not set up the relay - check RELAY_HOST/RELAY_SSH_PORT/RELAY_ROOT_PASSWORD.")
print(setup_result["stderr"])
exit(1)
}
ssh.disconnect(setup_session)
# ---- 3. connect - real ssh -R forwarding, stays up ----
step("connecting (real ssh -R through libssh - no external ssh process)")
let session = ssh.connect(RELAY_HOST, RELAY_SSH_PORT)
ssh.verify_host_trust_on_first_use(session, KNOWN_HOSTS_PATH)
ssh.authenticate_with_key(session, "tunnel", KEY_PATH)
print("relay:" + str(TUNNEL_PORT) + " -> " + TARGET_HOST + ":" + str(TARGET_PORT))
ssh.forward_remote_port(session, TUNNEL_PORT, TARGET_HOST, TARGET_PORT)Needs the ssh package's native libssh binding, which covers every native target larzscript builds for - Linux (x86_64 + aarch64), macOS (x86_64 + arm64), and Windows x86_64 - all CI-verified end to end against a real independent sshd/ssh client (see the ssh page for exact status). On the one platform it doesn't cover (wasm, permanently - no raw TCP in that sandbox), use examples/password_setup.lz instead - same 4-field flow, shells out to the real ssh/sshpass binaries instead, works wherever those are installed.
Nothing to install at all - not even a real sshd on the exposed machine
examples/native_ssh_server_and_bridge.lz - for when the machine you're exposing has no real SSH server running at all (or you just don't want to set one up). Instead of forwarding to something that already exists, the "service" being exposed is this machine's OWN native ssh.listen()/ssh.serve() server - a real interactive shell (ssh -p 2200 you@127.0.0.1 lands on an actual login shell with a real pty, not just single commands), still nothing external anywhere. Two larzscript processes cooperate under one command (this interpreter has no OS threads, so the server's accept loop and the tunnel's forward loop can't share a process) - one nohup ... & still starts both.
Dynamic and resilient, not a one-shot attempt - found needed during real end-to-end testing against a live relay: real connect timeouts (won't hang forever on an unreachable relay), auto-picks the next free port if TUNNEL_PORT/LOCAL_SERVER_PORT are already taken, a real worker-readiness check instead of a blind sleep, auto-reconnects with exponential backoff on any drop (same shape as netbridge's own supervise()), and specific error messages per failure mode (unreachable relay, bad password, changed host key, relay-script failure) instead of one generic failure.
# native_ssh_server_and_bridge.lz - the FULLY self-contained version of
# native_ssh_setup.lz: instead of exposing a real sshd/RDP/whatever you
# already have running on TARGET_HOST:TARGET_PORT, this machine's OWN
# native SSH server (ssh.listen()/ssh.serve() - real interactive shell,
# not just exec) IS the thing being exposed. Nothing to install on this
# machine at all, on any of Linux/macOS/Windows - not OpenSSH, not
# dropbear, not Windows' OpenSSH Server feature, nothing.
#
# Why two Larzscript processes, not one: this interpreter has no OS
# threads (see the ssh/netbridge packages' own docs on why serve() and
# forward_remote_port() each block forever, one connection at a time) -
# a single process can't run the native SSH server's accept loop AND the
# tunnel's forward loop at the same time. This script generates a small
# companion script with your chosen port/password baked in, launches it
# as a background OS process (the actual server), then this process
# itself becomes the tunnel - one user-facing command still does both.
#
# Dynamic and resilient, not a one-shot attempt:
# - real connect timeouts (won't hang forever on an unreachable/
# firewalled relay - fails fast and retries instead)
# - auto-picks the next free port if TUNNEL_PORT/LOCAL_SERVER_PORT are
# already taken, instead of just erroring out
# - waits for the native server to actually be listening before
# connecting the tunnel to it (a real readiness check, not a blind
# fixed sleep)
# - auto-reconnects with exponential backoff if the relay connection
# ever drops (same backoff shape as netbridge's own supervise()) -
# restarts the native server too if it died in the meantime
# - clear, specific error messages per failure mode (unreachable relay,
# bad password, host key changed, relay script failure) instead of a
# single generic failure
#
# larzscript pkg install netbridge
# larzscript pkg install ssh
# nohup larzscript native_ssh_server_and_bridge.lz > ~/netbridge.log 2>&1 &
# (on Windows: just `larzscript native_ssh_server_and_bridge.lz`, no nohup/&)
#
# Stopping this does NOT stop the background native server (by design -
# it's meant to keep answering local connections even if you stop the
# tunnel). To stop both: kill this process, then find and kill the
# `larzscript .../_native_ssh_server_worker.lz` process separately.
import "ssh" as ssh
# ---- fill these in ----
let RELAY_HOST = "203.0.113.10" # your relay's address or IP
let RELAY_SSH_PORT = 22 # whatever port sshd listens on there
let RELAY_ROOT_USER = "root"
let RELAY_ROOT_PASSWORD = "change-me" # only used once, for setup
let TUNNEL_PORT = 2200 # the port on the relay that will reach this machine (auto-tries the next few if taken)
let LOCAL_SERVER_PORT = 2201 # this machine's OWN native ssh server listens here (same auto-fallback)
let LOCAL_SERVER_USER = "you" # whatever username you want to log in as
let LOCAL_SERVER_PASSWORD = "change-me-too" # picks who can use the native server
# (avoid a literal " in USER/PASSWORD - both get baked into a generated
# .lz file as string literals below, and a stray quote would break that)
# ------------------------
# ---- tuning - sane defaults, change if you know you need to ----
let CONNECT_TIMEOUT_SECONDS = 15 # fail fast on an unreachable/firewalled relay rather than hang
let RETRY_MIN_SECONDS = 5 # first reconnect wait after a drop
let RETRY_MAX_SECONDS = 60 # reconnect backoff never grows past this
let PORT_SCAN_ATTEMPTS = 5 # how many candidate ports to try if the first choice is taken
# ------------------------
let SSH_DIR = env("HOME", env("USERPROFILE", ".")) + "/.ssh"
let KEY_PATH = SSH_DIR + "/netbridge_key"
let KNOWN_HOSTS_PATH = SSH_DIR + "/known_hosts"
let HOST_KEY_PATH = SSH_DIR + "/netbridge_local_server_host_key"
let WORKER_PATH = SSH_DIR + "/_native_ssh_server_worker.lz"
let is_windows = env("OS", "") == "Windows_NT"
fn step(msg) { print("==> " + msg) }
fn log(msg) { print("[" + str(int(time())) + "] " + msg) }
# ---- 1. client key - generated fresh here, unique per machine ----
# Double-quoted path + double-quoted empty passphrase (-N "") rather
# than single quotes: `run()` shells out via the OS's own shell
# (/bin/sh on Linux/macOS, cmd.exe on Windows) - single-quote emptiness
# is a POSIX-only convention (cmd.exe treats '' as two literal
# characters, not nothing), but "" for an empty argument, and double
# quotes around a path that might contain spaces, both work identically
# on all three - the one quoting style that needed no per-OS branch.
step("client key")
if not file_exists(KEY_PATH) {
run("ssh-keygen -t ed25519 -f \"" + KEY_PATH + "\" -N \"\" -C netbridge-client -q")
if not file_exists(KEY_PATH) {
print("FAIL: ssh-keygen did not produce a key at " + KEY_PATH + " - is ssh-keygen installed and on PATH?")
exit(1)
}
print("generated " + KEY_PATH)
} else {
print("already have " + KEY_PATH)
}
let pubkey = read_file(KEY_PATH + ".pub").strip()
# ---- 2. one-time relay setup, authenticated with your password - via
# ssh.run(), not a shelled-out `sshpass ssh ...` command. Each step
# wrapped separately so a failure says exactly what went wrong instead
# of one generic "something broke". ----
fn setup_relay() {
step("setting up the relay (password, one time only, via ssh.run())")
let relay_script = "#!/bin/sh\nset -e\n" +
"TUNNEL_USER=tunnel\n" +
"PUBKEY='" + pubkey + "'\n" +
"id -u \"$TUNNEL_USER\" >/dev/null 2>&1 || useradd -m -s /usr/sbin/nologin \"$TUNNEL_USER\"\n" +
"install -d -m 700 -o \"$TUNNEL_USER\" -g \"$TUNNEL_USER\" \"/home/$TUNNEL_USER/.ssh\"\n" +
"touch \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"chmod 600 \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"chown \"$TUNNEL_USER:$TUNNEL_USER\" \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"grep -qF \"$PUBKEY\" \"/home/$TUNNEL_USER/.ssh/authorized_keys\" 2>/dev/null || " +
"printf 'no-pty,no-X11-forwarding,no-agent-forwarding,command=\"echo netbridge: no interactive shell\" %s\\n' \"$PUBKEY\" >> \"/home/$TUNNEL_USER/.ssh/authorized_keys\"\n" +
"echo RELAY_SETUP_OK\n"
let setup_session = nil
try {
setup_session = ssh.connect(RELAY_HOST, RELAY_SSH_PORT, CONNECT_TIMEOUT_SECONDS)
} catch e {
print("FAIL: could not reach the relay at " + RELAY_HOST + ":" + str(RELAY_SSH_PORT) + " within " + str(CONNECT_TIMEOUT_SECONDS) + "s - " + str(e))
print("check RELAY_HOST/RELAY_SSH_PORT, and that the relay's sshd is actually up.")
exit(1)
}
try {
ssh.verify_host_trust_on_first_use(setup_session, KNOWN_HOSTS_PATH)
} catch e {
print("FAIL: relay host-key check failed - " + str(e))
exit(1)
}
try {
ssh.authenticate_with_password(setup_session, RELAY_ROOT_USER, RELAY_ROOT_PASSWORD)
} catch e {
print("FAIL: password authentication to the relay failed - check RELAY_ROOT_USER/RELAY_ROOT_PASSWORD. (" + str(e) + ")")
exit(1)
}
let setup_result = ssh.run(setup_session, relay_script)
print(setup_result["stdout"])
if not setup_result["stdout"].contains("RELAY_SETUP_OK") {
print("FAIL: the relay setup script did not complete - check RELAY_HOST/RELAY_SSH_PORT/RELAY_ROOT_PASSWORD.")
print(setup_result["stderr"])
exit(1)
}
ssh.disconnect(setup_session)
}
setup_relay()
# ---- 3. helpers: a port is "free" if nothing answers a connect on it;
# pick_free_port() walks forward from a starting port instead of just
# failing the moment the first choice is already taken by something
# else on this machine (a previous run, another app, ...). ----
fn is_port_taken(port) {
try {
let fd = socket_connect("127.0.0.1", port)
socket_close(fd)
return true
} catch e {
return false
}
}
fn pick_free_port(start_port, attempts) {
let port = start_port
for i in range(attempts) {
if not is_port_taken(port) { return port }
port = port + 1
}
return nil
}
# ---- 4. the native SSH server (this machine's own worker process) -
# started once, kept running independently of the tunnel (see file
# header for why); (re)started here if it isn't already up and
# listening, with a real readiness check instead of a blind sleep. ----
fn start_worker_if_needed(port) {
if is_port_taken(port) {
log("native server already listening on " + str(port) + ", reusing it")
return true
}
step("starting this machine's own native SSH server on port " + str(port))
let worker_script = "import \"ssh\" as ssh\n" +
"let server = ssh.listen(" + str(port) + ", \"" + HOST_KEY_PATH + "\")\n" +
"ssh.serve(server,\n" +
" fn(user, password) { return user == \"" + LOCAL_SERVER_USER + "\" and password == \"" + LOCAL_SERVER_PASSWORD + "\" },\n" +
" fn(cmd) { return capture(cmd + \" 2>&1\") },\n" +
" {\"log_fn\": fn(line) { print(\"[native ssh server] \" + line) }})\n"
write_file(WORKER_PATH, worker_script)
if is_windows {
run("start /B \"\" larzscript \"" + WORKER_PATH + "\"")
} else {
run("larzscript \"" + WORKER_PATH + "\" > /dev/null 2>&1 &")
}
# Real readiness check: poll for up to 10s instead of a blind sleep(1)
# (which either wastes time waiting when it's already up, or isn't
# long enough on a slower/loaded machine and races the tunnel step).
let waited = 0.0
while waited < 10.0 {
if is_port_taken(port) { return true }
sleep(0.25)
waited = waited + 0.25
}
return false
}
# ---- 5. connect to the relay and forward - the tunnel itself. Manual
# listen+accept+bridge (the same primitives ssh.forward_remote_port()
# uses internally) instead of the higher-level wrapper, specifically so
# a taken TUNNEL_PORT can fall forward to the next candidate rather than
# just failing. ----
fn run_tunnel_once(local_port) {
let session = nil
try {
session = ssh.connect(RELAY_HOST, RELAY_SSH_PORT, CONNECT_TIMEOUT_SECONDS)
} catch e {
log("could not reach the relay: " + str(e))
return false
}
try {
ssh.verify_host_trust_on_first_use(session, KNOWN_HOSTS_PATH)
ssh.authenticate_with_key(session, "tunnel", KEY_PATH)
} catch e {
log("relay auth/host-key check failed: " + str(e))
ssh.disconnect(session) # otherwise a repeated auth failure inside the reconnect loop leaks a session handle every attempt
return false
}
let bound_port = nil
let candidate = TUNNEL_PORT
for i in range(PORT_SCAN_ATTEMPTS) {
try {
ssh_listen_forward(session, candidate)
bound_port = candidate
break
} catch e {
log("relay port " + str(candidate) + " unavailable (" + str(e) + "), trying " + str(candidate + 1))
candidate = candidate + 1
}
}
if bound_port == nil {
log("could not bind any relay port from " + str(TUNNEL_PORT) + " through " + str(TUNNEL_PORT + PORT_SCAN_ATTEMPTS - 1))
ssh.disconnect(session)
return false
}
print("relay:" + str(bound_port) + " -> this machine's native ssh server on 127.0.0.1:" + str(local_port))
print("from the relay: ssh -p " + str(bound_port) + " " + LOCAL_SERVER_USER + "@127.0.0.1 (real interactive shell, real pty)")
while true {
let channel = nil
try {
channel = ssh_accept_forward(session, 1000)
} catch e {
# the relay session itself died (network drop, relay restart, ...) -
# return cleanly so the outer supervise loop reconnects, rather than
# letting this escape uncaught and crash the whole process.
log("relay session ended: " + str(e))
return false
}
if channel == nil { continue }
if not is_port_taken(local_port) {
log("native server on " + str(local_port) + " isn't responding - restarting it")
if not start_worker_if_needed(local_port) {
log("could not restart the native server - closing this connection")
ssh_channel_free(channel)
continue
}
}
try {
ssh_bridge_forward(channel, "127.0.0.1", local_port)
} catch e {
log("forwarded connection error: " + str(e))
}
ssh_channel_free(channel)
}
}
# ---- 6. supervise: reconnect with exponential backoff on any drop -
# same shape as netbridge's own supervise() (retry_min/retry_max,
# doubling, reset after a long-lived connection) so a relay hiccup or
# network blip doesn't take the whole tunnel down permanently. ----
if not start_worker_if_needed(LOCAL_SERVER_PORT) {
print("FAIL: the native server never started listening on " + str(LOCAL_SERVER_PORT) + " within 10s.")
exit(1)
}
let backoff = RETRY_MIN_SECONDS
while true {
step("connecting (real ssh -R through libssh - no external ssh process)")
let started = clock()
# Belt and suspenders: run_tunnel_once() already catches everything it
# knows how to hit internally, but this outer try/catch is the actual
# guarantee - nothing thrown from in there can ever escape this loop
# and kill the whole process, which would defeat the entire point of
# auto-reconnecting.
try {
run_tunnel_once(LOCAL_SERVER_PORT)
} catch e {
log("unexpected error: " + str(e))
}
let ran_seconds = clock() - started
if ran_seconds > 60 { backoff = RETRY_MIN_SECONDS }
log("tunnel dropped after " + str(ran_seconds) + "s - reconnecting in " + str(backoff) + "s")
sleep(backoff)
backoff = backoff * 2
if backoff > RETRY_MAX_SECONDS { backoff = RETRY_MAX_SECONDS }
}Stopping this does NOT stop the background native server by design - it's meant to keep answering local connections even after you stop the tunnel. To stop both: kill this process, then find and kill the separate _native_ssh_server_worker.lz process.
Why it's in the Larz Stack
netbridge is a real Larzscript package (larzscript pkg install netbridge) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.