Several compounding bugs were blocking end-to-end TollGate provisioning
on OpenWrt 25.x (apk-native) routers:
- install_ipk's non-ar fallback assumed a flat tarball, but some .ipks are
a gzip tar of the three classic ipk members one level deep; it was
dumping debian-binary/data.tar.gz/control.tar.gz straight into / instead
of unpacking the real payload.
- Manually-extracted packages never ran their pending /etc/uci-defaults/*
scripts (that only happens through opkg/apk's own postinst bookkeeping),
so nothing ever created /etc/config/tollgate.
- uci_apply() never ensured the target config file existed first — `uci
set` fails outright on a config namespace nothing has created yet, which
is true for a package-defined one like "tollgate" (unlike wireless/
network/dhcp, which ship by default).
- The installed-check and restart_services looked for a binary/init script
named after the opkg package ("tollgate-module-basic-go"/"tollgate"),
but the real on-disk names are tollgate-wrt — so status always reported
"not installed" and service restarts silently no-op'd.
- provision_ssid used `uci add`, creating a new wifi-iface section (and
therefore a new duplicate broadcast SSID) on every provision call instead
of updating one in place.
Also adds a TollGateConfig.enabled field so the enable/disable state is
actually applied to the running service and the SSID's own broadcast
(stop + disable at boot, or start + enable), not just written to UCI.
On the frontend, the OpenWrt Gateway page's TollGate panel was read-only
once installed — add an edit form (price, step size, min steps, mint URL,
enabled toggle) that reuses the same idempotent provision-tollgate call.
60 lines
2.0 KiB
Rust
60 lines
2.0 KiB
Rust
use anyhow::Result;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::Router;
|
|
|
|
/// TollGate provisioning parameters.
|
|
///
|
|
/// `mint_url` must be the externally-reachable URL of the Archy Cashu mint —
|
|
/// TollGate customers connect from outside the Archy node's loopback, so
|
|
/// localhost URLs will not work. Resolve this from the running mint app before
|
|
/// calling `provision`.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TollGateConfig {
|
|
/// SSID name for the pay-as-you-go network.
|
|
pub ssid: String,
|
|
/// Externally-reachable URL of the Archy Cashu mint.
|
|
pub mint_url: String,
|
|
/// Price in satoshis per `step_size` interval.
|
|
pub price_sats: u64,
|
|
/// Step size in milliseconds (default: 60000 = 1 minute).
|
|
pub step_size_ms: u64,
|
|
/// Minimum steps a customer must purchase at once.
|
|
pub min_steps: u32,
|
|
/// Whether the TollGate service should be running and enabled at boot.
|
|
pub enabled: bool,
|
|
}
|
|
|
|
impl Default for TollGateConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
ssid: "archipelago".to_string(),
|
|
mint_url: String::new(), // must be set by caller from the running mint app
|
|
price_sats: 10,
|
|
step_size_ms: 60_000,
|
|
min_steps: 1,
|
|
enabled: true,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Write TollGate UCI configuration and commit.
|
|
///
|
|
/// Maps TIP-01 / TIP-02 fields onto UCI keys used by tollgate-module-basic-go.
|
|
pub fn apply(router: &Router, cfg: &TollGateConfig) -> Result<()> {
|
|
router.uci_apply(
|
|
"tollgate",
|
|
&[
|
|
("tollgate.main", "tollgate"),
|
|
("tollgate.main.enabled", if cfg.enabled { "1" } else { "0" }),
|
|
("tollgate.main.metric", "milliseconds"),
|
|
("tollgate.main.step_size", &cfg.step_size_ms.to_string()),
|
|
("tollgate.main.min_steps", &cfg.min_steps.to_string()),
|
|
("tollgate.main.price_per_step", &cfg.price_sats.to_string()),
|
|
("tollgate.main.currency", "sat"),
|
|
("tollgate.main.mint_url", &cfg.mint_url),
|
|
],
|
|
)?;
|
|
Ok(())
|
|
}
|