Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

設定リファレンス

サーバは作業ディレクトリの wpg.toml、または --config / WPG_CONFIG で指定したファイルを読みます。優先順位は低い順に、組み込みの既定値、ファイル、環境変数 WPG_<SECTION>__<KEY> (__ で階層を区切る。例: WPG_SERVER__BIND=0.0.0.0:8080、WPG_TX__ALLOWED_IFACES='["eth1"]')、wpg serve --bind などのコマンドラインオプションです。未知のキーはエラーです。wpg config init で下記のコメント付きの例を書き出し、wpg config show で実効設定を表示し、wpg config validate で検査し、wpg config set-password で管理者パスワードのハッシュを保存します。管理者パスワードそのものはキーではなく、wpg serve --password、--password-file、WPG_PASSWORD が auth.password_hash、auth.password_file より優先されます。このページは設定の型から自動生成しています。

キー一覧

トップレベル

キー型既定値環境変数説明
data_dirstringOS のデータディレクトリ (Linux: ~/.local/share/wpg)WPG_DATA_DIRサーバの状態を置くディレクトリ: ユーザテンプレート、お気に入り、SQLite データベース (ユーザ、セッション、ジョブ履歴)、ドライランのキャプチャ、自己署名 TLS 証明書。

[auth]

認証。

キー型既定値環境変数説明
password_filestringWPG_AUTH__PASSWORD_FILE管理者パスワードを書いたファイル: argon2 PHC 文字列、または起動時にハッシュする平文。
password_hashstringWPG_AUTH__PASSWORD_HASH管理者パスワードの argon2id PHC 文字列。wpg config set-password が書き込みます。
session_ttl_secsinteger86400WPG_AUTH__SESSION_TTL_SECSセッションの有効期間 (秒)。リクエストのたびに延長されます。

[dhcp]

DHCP サーバーツール(1 つのインタフェースで DHCPv4 / DHCPv6。プールとオプションは DHCP 画面で編集)。

キー型既定値環境変数説明
enabledbooleantrueWPG_DHCP__ENABLEDDHCP 画面と /api/dhcp を有効にします。
ifacestring""WPG_DHCP__IFACEDHCP サーバーが応答するインタフェース(例 eth1。deploy.sh --dhcp-iface で設定)。空なら画面で tx.allowed_ifaces から選びます。

[log]

ログ。

キー型既定値環境変数説明
ansibooleantrueWPG_LOG__ANSI端末への出力に色を付けます。
filestringWPG_LOG__FILEこのファイルにも書き出します (ディレクトリは作成されます)。
format"pretty" | "json""pretty"WPG_LOG__FORMAT行の形式: pretty (人が読む形式) または json (1 行に 1 オブジェクト)。
levelstring"info"WPG_LOG__LEVELフィルタ指定 (RUST_LOG が優先)。例: info、wpg_tx=debug,info。
max_filesintegerWPG_LOG__MAX_FILES残すローテーション済みファイルの最大数 (古いものから削除)。
rotation"never" | "hourly" | "daily""never"WPG_LOG__ROTATIONファイルのローテーション: never、hourly、daily。

[protocols]

ユーザ定義プロトコル。

キー型既定値環境変数説明
dirsstring[][]WPG_PROTOCOLS__DIRSユーザ定義プロトコルのファイル (*.yaml: 新しいプロトコル定義と既存プロトコルの下への結び付け) を置くディレクトリ。起動時にファイル名順で読み込みます。wpg serve --protocols-dir で追加できます。

[server]

HTTP リスナ。

キー型既定値環境変数説明
base_urlstringWPG_SERVER__BASE_URLリバースプロキシ配下で公開する URL (https://wpg.example.net)。絶対リンクに使います。
bindstring"127.0.0.1:8080"WPG_SERVER__BIND待ち受けアドレス。パスワードがなく、セットアップ画面でユーザも作っていない間は、ループバックアドレスだけを受け付けます (--allow-insecure で解除)。
job_historyinteger100WPG_SERVER__JOB_HISTORYメモリに保持し、ジョブ画面と API に一覧表示する終了済みジョブ数 (1–100000)。
job_history_dbinteger1000WPG_SERVER__JOB_HISTORY_DBデータベースに残す終了済みジョブ数。古いものから削除します (1–10000000)。
preview_maxinteger256WPG_SERVER__PREVIEW_MAX1 回のプレビュー (POST /api/render) で生成できる最大パケット数 (1–100000)。
self_signed_tlsbooleanfalseWPG_SERVER__SELF_SIGNED_TLS<data_dir>/tls/ に生成する自己署名証明書で HTTPS を提供します (次回以降も再利用)。wpg serve --tls と同じです。

[server.tls]

HTTPS で使う証明書チェーンと秘密鍵 (PEM)。self_signed_tls より優先します。

キー型既定値環境変数説明
certstringWPG_SERVER__TLS__CERTPEM 形式の証明書チェーン。
keystringWPG_SERVER__TLS__KEYPEM 形式の秘密鍵。

[snmp]

SNMP マネージャツール(Get / Walk / Set / トラップ、MIB アップロード)。

キー型既定値環境変数説明
enabledbooleantrueWPG_SNMP__ENABLEDSNMP ツール画面と /api/snmp を有効にします。
mib_dirstring""WPG_SNMP__MIB_DIRアップロードした MIB ファイルのディレクトリ。空なら <data_dir>/mibs。
trap_listenstring""WPG_SNMP__TRAP_LISTEN起動時からトラップ / インフォーム受信を待ち受けるアドレス(例 0.0.0.0:162。1024 未満のポートには root か CAP_NET_BIND_SERVICE が必要)。空なら起動時は受信しません(画面から開始できます)。

[templates]

テンプレートライブラリ。

キー型既定値環境変数説明
library_pathsstring[]["./templates"]WPG_TEMPLATES__LIBRARY_PATHS読み取り専用のテンプレートライブラリ (Git のチェックアウトなど)。*.wpg.yaml / *.wpg.json を再帰的に読み込み、ファイルが変わると再読み込みします。
user_dirstringWPG_TEMPLATES__USER_DIRGUI で作成・インポートしたテンプレートを書き込むディレクトリ。既定は <data_dir>/templates。

[terminal]

Web ターミナル: ログインしたユーザのためにサーバが開く SSH / Telnet セッション (Web ターミナルのガイドを参照)。

キー型既定値環境変数説明
allowed_targetsstring[][]WPG_TERMINAL__ALLOWED_TARGETSセッションの接続先として許可する宛先: host、host:port、*.domain、IP アドレス、CIDR (10.0.0.0/8、[2001:db8::1]:830)。空ならすべて。
enabledbooleanfalseWPG_TERMINAL__ENABLEDWeb ターミナルを有効にします。既定では無効です。
idle_timeout_secsinteger1800WPG_TERMINAL__IDLE_TIMEOUT_SECS入出力がこの秒数ないセッションを切断します。0 で切断しません。
max_sessionsinteger8WPG_TERMINAL__MAX_SESSIONS同時に開けるセッション数の上限 (全ユーザ合計)。
record_sessionsbooleantrueWPG_TERMINAL__RECORD_SESSIONSセッションログ (接続先からの出力) を <data_dir>/terminal-logs に残すことを許可します。false でサーバ側のログを無効にします。

[tx]

送出のポリシーと既定値。

キー型既定値環境変数説明
allowed_ifacesstring[][]WPG_TX__ALLOWED_IFACESジョブが送出してよいインタフェース。空ならすべて。null バックエンドとドライランは制限しません。
default_backendstringWPG_TX__DEFAULT_BACKENDジョブがバックエンドを指定しないときのバックエンド (null、pcapfile、afpacket、pcap、afxdp、dpdk)。未設定なら Linux は afpacket、それ以外は pcap、使えなければ null。
dpdk_eal_argsstring[][]WPG_TX__DPDK_EAL_ARGSdpdk バックエンドの DPDK EAL 引数 (例: ["-a", "0000:00:04.0"])。指定がなければ wpg が -l <先頭の CPU> と --in-memory を加えます。EAL はプロセスごとに最初の dpdk ジョブで 1 度だけ起動するため、変更には再起動が必要です。
max_ratestringWPG_TX__MAX_RATEジョブが指定できる最大レート (100kpps、1Gbps)。レート指定のないジョブはこのレートで送出します。
prerender_max_bytesinteger268435456WPG_TX__PRERENDER_MAX_BYTESパケット数 × フレーム長がこのバイト数以下のストリームだけを事前生成 (送出前に全フレームを生成) し、超えるものは送出しながら生成します。0 は --plan prerender を指定しない限り事前生成しません。上限 1 TiB。wpg send --prerender-max-bytes で上書きできます。
prerender_max_packetsinteger100000000WPG_TX__PRERENDER_MAX_PACKETSパケット数がこの値以下のストリームだけを事前生成します。wpg send --prerender-max-packets で上書きできます。
ring_bytesinteger16777216WPG_TX__RING_BYTESワーカーごとの afpacket TX リング / afxdp UMEM のメモリ (バイト、1 MiB–1 GiB)。収まるようにリング深さを減らします。このメモリはロックされるため、大きな値では ulimit -l を引き上げてください。--ring-bytes で上書きできます。

設定例 (wpg config init)

有効な行はすべて組み込みの既定値と同じなので、編集するまで動作は変わりません。コメントアウトした行は省略可能なキーの例です。

# wpg.toml — Web Packet Generator configuration.
#
# Precedence (lowest first): built-in defaults < this file < environment variables
# (WPG_<SECTION>__<KEY>, e.g. WPG_SERVER__BIND=0.0.0.0:8080 or
# WPG_TX__ALLOWED_IFACES='["eth1"]') < command line options (wpg serve --bind ...).
# Unknown keys are rejected. Check a file with `wpg config validate`, print the
# effective configuration with `wpg config show`.

# Server state: user templates, favourites, job history, dry-run captures.
# Default: the OS data directory (Linux: ~/.local/share/wpg).
# data_dir = "/var/lib/wpg"

[server]
# Listen address. Without a password keep it on localhost.
bind = "127.0.0.1:8080"
# Public URL when running behind a reverse proxy.
# base_url = "https://wpg.example.net"
# Serve HTTPS with a self-signed certificate generated into <data_dir>/tls/
# (same as `wpg serve --tls`). Ignored when [server.tls] is set.
self_signed_tls = false
# Most packets one preview request may render (1-100000).
preview_max = 256
# Finished jobs listed on the Jobs screen (kept in memory, 1-100000) and kept in
# the database (1-10000000; older ones are deleted).
job_history = 100
job_history_db = 1000

# TLS certificate chain and private key (PEM) to serve HTTPS with.
# [server.tls]
# cert = "/etc/wpg/cert.pem"
# key = "/etc/wpg/key.pem"

[auth]
# Admin password. Without one (and without a user created on the first-run
# setup screen) the server only listens on localhost. Sources, highest first:
# `wpg serve --password`, `--password-file`, $WPG_PASSWORD, password_hash,
# password_file, the setup screen.
# argon2id hash of the admin password (`wpg config set-password` writes it):
# password_hash = "$argon2id$v=19$m=19456,t=2,p=1$..."
# Or a file holding the hash or the plain-text password:
# password_file = "/etc/wpg/password"
# Session lifetime in seconds (extended by every request).
session_ttl_secs = 86400

[templates]
# Read-only template libraries (Git checkouts etc.), scanned recursively for
# *.wpg.yaml / *.wpg.json and reloaded when files change.
library_paths = ["./templates"]
# Writable directory for templates created or imported in the GUI.
# Default: <data_dir>/templates
# user_dir = "/var/lib/wpg/templates"

[protocols]
# Directories of user-defined protocol files (*.yaml), loaded at startup.
# Changes need a restart.
# dirs = ["/etc/wpg/protocols.d"]

[tx]
# Interfaces jobs may send on; empty = all. The null backend and dry runs are
# not restricted.
allowed_ifaces = []
# Highest rate a job may request, e.g. "100kpps" or "1Gbps". Jobs without a rate
# are sent at this rate.
# max_rate = "100kpps"
# Backend when a job names none: null, pcapfile, afpacket, pcap, afxdp, dpdk.
# Default: afpacket on Linux, else pcap, else null.
# default_backend = "afpacket"
# DPDK EAL arguments for the dpdk backend (wpg adds "-l <first CPU>" and
# "--in-memory" unless given). EAL starts with the first dpdk job; changing them
# needs a restart.
# dpdk_eal_args = ["-a", "0000:00:04.0"]
# Streams are pre-rendered (every frame built before sending) when they have at
# most prerender_max_packets packets and packets * frame length is at most
# prerender_max_bytes (default 256 MiB, up to 1 TiB); larger ones are built on
# the fly. `wpg send --prerender-max-bytes / --prerender-max-packets` override.
prerender_max_bytes = 268435456
prerender_max_packets = 100000000
# Memory of one afpacket TX ring / afxdp UMEM per worker in bytes (1 MiB-1 GiB,
# default 16 MiB); --ring-depth is reduced to fit. Locked memory: raise
# `ulimit -l` / LimitMEMLOCK for large values.
ring_bytes = 16777216

[snmp]
# SNMP tool screen and API (Get / Walk / Set / traps, MIB upload).
enabled = true
# Trap / inform receiver started at boot, e.g. "0.0.0.0:162" (ports below 1024
# need root or CAP_NET_BIND_SERVICE). Empty: not started at boot (it can be
# started from the UI).
trap_listen = ""
# Directory of uploaded MIB files. Empty: <data_dir>/mibs
mib_dir = ""

[dhcp]
# DHCP screen and API (DHCPv4 / DHCPv6 server, Linux only). Pools and options
# are edited on the screen and kept in <data_dir>/dhcp.json.
enabled = true
# Interface the server answers on, e.g. "eth1". Empty: chosen on the screen
# among tx.allowed_ifaces. Ports 67 / 547 need root or CAP_NET_BIND_SERVICE.
iface = ""

[log]
# Filter directives (RUST_LOG overrides this), e.g. "info" or "wpg_tx=debug,info".
level = "info"
# "pretty" or "json".
format = "pretty"
# Also write to this file (its directory is created).
# file = "/var/log/wpg/wpg.log"
# Rotation of the file: "never", "hourly" or "daily".
rotation = "never"
# Keep at most this many rotated files.
# max_files = 7
# Colour the console output when it is a terminal.
ansi = true

[terminal]
enabled = false          # Web terminal (SSH / Telnet)
allowed_targets = []     # "host", "host:port" or CIDR; empty = any target
record_sessions = true   # keep session logs under <data_dir>/terminal-logs
idle_timeout_secs = 1800
max_sessions = 8