[package]
name = "srunc"
version = "0.4.3"
edition = "2021"
license = "MIT"
repository = "https://github.com/WangYihang/srunc"
homepage = "https://github.com/WangYihang/srunc"
authors = ["Yihang Wang <wangyihanger@gmail.com>"]
rust-version = "1.74"
description = "Generic, auto-configuring srun (深澜) captive-portal auth client (CLI + library). Static musl binary suitable for OpenWrt routers; library API for embedding in Rust apps."
keywords = ["srun", "captive-portal", "campus-network", "auth", "cli"]
categories = ["command-line-utilities", "network-programming", "authentication"]
readme = "README.md"

[[bin]]
name = "srunc"
path = "src/main.rs"
required-features = ["cli"]

[features]
default = ["cli"]
# Toggle off (`--no-default-features`) for library-only consumers who don't
# need argv parsing, terminal styling, or TOML config loading.
cli = [
    "dep:clap",
    "dep:anstream",
    "dep:anstyle",
    "dep:env_logger",
    "dep:rpassword",
    "dep:ctrlc",
    "dep:basic-toml",
    "dep:anyhow",
]

[dependencies]
# Library-always:
serde = { version = "1", features = ["derive"] }
serde_json = "1"
ureq = "2"
thiserror = "2"
log = "0.4"
sha1 = { version = "0.10", default-features = false }
md-5 = { version = "0.10", default-features = false }

# CLI-only (gated by the `cli` feature):
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "color", "suggestions", "error-context", "wrap_help"], optional = true }
anstream = { version = "0.6", optional = true }
anstyle = { version = "1", optional = true }
env_logger = { version = "0.11", default-features = false, features = ["auto-color"], optional = true }
rpassword = { version = "7", optional = true }
ctrlc = { version = "3", features = ["termination"], optional = true }
basic-toml = { version = "0.1", optional = true }
anyhow = { version = "1", optional = true }

[dev-dependencies]
assert_cmd = "2"
predicates = "3"
tempfile = "3"
httpmock = "0.8"

# Fetched by `cargo binstall srunc` instead of compiling from source.
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.{ archive-suffix }"
bin-dir = "{ name }-{ target }/{ bin }{ binary-ext }"
pkg-fmt = "tgz"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"

# Debian package (cargo-deb). Triggered from CI for the glibc Linux targets.
[package.metadata.deb]
name = "srunc"
maintainer = "Yihang Wang <wangyihanger@gmail.com>"
copyright = "2026, Yihang Wang <wangyihanger@gmail.com>"
license-file = ["LICENSE", "0"]
extended-description = "Generic, auto-configuring srun (深澜) captive-portal auth client. Host and ac_id are auto-discovered from the captive redirect — most setups only need username + password."
section = "net"
priority = "optional"
depends = "$auto"
assets = [
    ["target/release/srunc",                       "usr/bin/",                      "755"],
    ["docs/config.example.toml",                   "usr/share/doc/srunc/",          "644"],
    ["docs/systemd/system/srunc.service",          "lib/systemd/system/",           "644"],
    ["docs/systemd/system/srunc@.service",         "lib/systemd/system/",           "644"],
    ["docs/systemd/user/srunc.service",            "usr/lib/systemd/user/",         "644"],
    ["README.md",                                  "usr/share/doc/srunc/README.md", "644"],
]

# Size-tuned release profile — these binaries ship to routers and other
# flash-constrained boxes.
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
strip = true
