chore: restart the repository with a clean history
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s

Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
This commit is contained in:
fristy committed 2026-11-10 11:31:13 +03:00
commit 650807c1fb
438 files changed
+45070

No files matched your search

+210
View File
@@ -0,0 +1,210 @@
mod api;
mod auth;
mod cli;
mod config;
mod connect;
#[cfg(feature = "gui")]
mod gui;
mod handler;
mod headless;
mod mux;
mod qr;
mod router;
mod serve;
mod service;
mod session;
mod shape;
mod tcp;
mod tls;
mod tui;
mod tunnel;
mod update;
use clap::{Parser, Subcommand};
use console::style;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "frislit", about = "frislit CLI - expose local ports through your own frislit server", version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Login {
link: Option<String>,
#[arg(long, value_name = "KEY", help = "Link with an API key instead of the browser")] token: Option<String>,
#[arg(short, long)] server: Option<String>,
},
Logout,
Http {
target: String,
#[arg(short, long)] name: Option<String>,
#[arg(long, value_name = "PATH|SUBDOMAIN", help = "Forwarding style for this tunnel (default: the server setting)")] mode: Option<String>,
#[arg(long, value_name = "PREFIX=TARGET")] route: Vec<String>,
#[arg(long)] keep_host: bool,
#[command(flatten)] rules: RuleArgs,
#[arg(long, value_name = "PASSWORD")] password: Option<String>,
#[arg(long)] require_login: bool,
#[command(flatten)] shape: ShapeArgs,
#[arg(long, help = "Print plain log lines instead of the terminal UI")] plain: bool,
},
Serve {
#[arg(default_value = ".")] dir: String,
#[arg(short, long)] name: Option<String>,
#[arg(long, value_name = "PATH|SUBDOMAIN", help = "Forwarding style for this tunnel (default: the server setting)")] mode: Option<String>,
#[command(flatten)] rules: RuleArgs,
#[arg(long, value_name = "PASSWORD")] password: Option<String>,
#[arg(long)] require_login: bool,
#[command(flatten)] shape: ShapeArgs,
#[arg(long, help = "Print plain log lines instead of the terminal UI")] plain: bool,
},
Tcp {
target: String,
#[arg(short, long)] name: Option<String>,
#[command(flatten)] rules: RuleArgs,
#[command(flatten)] shape: ShapeArgs,
#[arg(long, help = "Print plain log lines instead of the terminal UI")] plain: bool,
},
Connect {
target: String,
#[arg(short, long)] port: Option<u16>,
#[arg(short, long, default_value = "127.0.0.1")] bind: String,
#[arg(short, long)] server: Option<String>,
},
#[command(alias = "status")]
Ls,
Start {
#[arg(short, long, value_name = "FILE")] config: Option<PathBuf>,
},
Service {
#[command(subcommand)]
action: ServiceAction,
},
#[cfg(feature = "gui")]
Gui {
link: Option<String>,
#[arg(long)] hidden: bool,
},
Config {
#[command(subcommand)]
action: ConfigAction,
},
Update,
Links {
#[command(subcommand)]
action: LinkAction,
},
}
#[derive(clap::Args)]
struct RuleArgs {
#[arg(long, value_name = "CIDR")] allow: Vec<String>,
#[arg(long, value_name = "CODE")] allow_country: Vec<String>,
#[arg(long, value_name = "CIDR")] block_ip: Vec<String>,
#[arg(long, value_name = "CODE")] block_country: Vec<String>,
#[arg(long, value_name = "CATEGORY", help = "tor, vpn, datacenter or blocklist")] block: Vec<String>,
}
impl RuleArgs {
fn parse(self) -> anyhow::Result<tunnel::Rules> {
tunnel::Rules::new(self.allow, self.allow_country, self.block_ip, self.block_country, self.block)
}
}
#[derive(clap::Args)]
struct ShapeArgs {
#[arg(long, value_name = "DURATION")] latency: Option<String>,
#[arg(long, value_name = "DURATION")] jitter: Option<String>,
#[arg(long, value_name = "RATE")] bandwidth: Option<String>,
#[arg(long, value_name = "PERCENT")] loss: Option<String>,
}
impl ShapeArgs {
fn parse(&self) -> anyhow::Result<shape::Shape> {
shape::Shape::parse(self.latency.as_deref(), self.jitter.as_deref(), self.bandwidth.as_deref(), self.loss.as_deref())
}
}
#[derive(Subcommand)]
enum ServiceAction {
Install,
Uninstall,
}
#[derive(Subcommand)]
enum LinkAction {
Register,
Forget,
}
#[derive(Subcommand)]
enum ConfigAction {
Set { key: String, value: String },
Get { key: String },
Show,
}
fn main() {
tls::install_provider();
if cfg!(windows) { update::cleanup(); }
let cli = Cli::parse();
let runtime = tokio::runtime::Builder::new_multi_thread().worker_threads(4).enable_all().build().unwrap_or_else(|err| fail(err.into()));
#[cfg(feature = "gui")]
if let Commands::Gui { link, hidden } = cli.command {
gui::launch(runtime.handle().clone(), link, hidden).unwrap_or_else(|err| fail(err));
return;
}
runtime.block_on(run(cli)).unwrap_or_else(|err| fail(err));
}
fn fail(err: anyhow::Error) -> ! {
eprintln!("{} {err:#}", style("✗").red().bold());
std::process::exit(1)
}
async fn run(cli: Cli) -> anyhow::Result<()> {
match cli.command {
Commands::Login { link, token, server } => cli::login(link, token, server).await,
Commands::Logout => cli::logout(),
Commands::Http { target, name, mode, route, keep_host, rules, password, require_login, shape, plain } =>
cli::tunnel(tunnel::Options::http(tunnel::TargetSpec::with_routes(&target, &route)?, name, keep_host, tunnel::Access::new(rules.parse()?, password, require_login)?).http_mode(mode).shaped(shape.parse()?), plain).await,
Commands::Serve { dir, name, mode, rules, password, require_login, shape, plain } =>
cli::tunnel(tunnel::Options::http(tunnel::TargetSpec::dir(&dir)?, name, false, tunnel::Access::new(rules.parse()?, password, require_login)?).http_mode(mode).shaped(shape.parse()?), plain).await,
Commands::Tcp { target, name, rules, shape, plain } =>
cli::tunnel(tunnel::Options::tcp(tunnel::Target::parse(&target)?, name, tunnel::Access::new(rules.parse()?, None, false)?).shaped(shape.parse()?), plain).await,
Commands::Connect { target, port, bind, server } => cli::connect(target, port, bind, server).await,
Commands::Ls => cli::list().await,
Commands::Start { config } => headless::run(config).await,
Commands::Service { action } => match action {
ServiceAction::Install => service::install(),
ServiceAction::Uninstall => service::uninstall(),
},
#[cfg(feature = "gui")]
Commands::Gui { .. } => unreachable!("handled before the runtime starts"),
Commands::Links { action } => match action {
LinkAction::Register => {
let where_ = handler::install()?;
println!("{} {} links now open in this frislit", style("✓").green().bold(), style(format!("{}://", handler::SCHEME)).cyan().bold());
println!(" {}", style(where_.to_string_lossy()).dim());
println!(" Your browser will ask before it opens one.");
Ok(())
}
LinkAction::Forget => {
handler::remove()?;
println!("{} {} links are no longer handled by frislit", style("✓").green().bold(), style(format!("{}://", handler::SCHEME)).bold());
Ok(())
}
},
Commands::Update => cli::update().await,
Commands::Config { action } => match action {
ConfigAction::Set { key, value } => config::set(&key, &value),
ConfigAction::Get { key } => config::get(&key),
ConfigAction::Show => config::show(),
},
}
}